本文整理汇总了Python中nipy.core.api.Image.from_image方法的典型用法代码示例。如果您正苦于以下问题:Python Image.from_image方法的具体用法?Python Image.from_image怎么用?Python Image.from_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nipy.core.api.Image
的用法示例。
在下文中一共展示了Image.from_image方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_nifti
# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import from_image [as 别名]
def get_nifti(self, topo_view, base_nifti=None, **kwargs):
"""
Process the nifti
Parameters
----------
topo_view: array-like
Topological view to create nifti. 3D.
Returns
-------
image: nipy image
Nifti image from topological view.
"""
if base_nifti is None:
assert self.base_nifti is not None, ("`base.nii` not in dataset "
"directory. You may need to "
"reprocess.")
base_nifti = self.base_nifti
image = Image.from_image(base_nifti, data=topo_view)
else:
if isinstance(base_nifti, str):
base_nifti = load_image(base_nifti)
base2new_affine = np.linalg.inv(
base_nifti.affine).dot(self.base_nifti.affine)
cmap = AffineTransform("kji", "zxy", base2new_affine)
image = Image.from_image(base_nifti, data=topo_view, coordmap=cmap)
return image
示例2: sources_to_nifti
# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import from_image [as 别名]
def sources_to_nifti(CHECKPOINT, MASKMAT, BASENIFTI, ONAME, savepath, voxels, win):
bnifti = load_image(BASENIFTI)
mask = loadmat(MASKMAT)['mask']
model = np.load(CHECKPOINT) # Numpy array of sources from Infomax ICA
for i in range(len(model)): # Goes component by component
W = model[i,:].reshape([voxels,win])
f = zeros(len(mask))
idx = where(mask==1)
data = zeros((bnifti.shape[0],bnifti.shape[1],bnifti.shape[2],W.shape[1]))
f[idx[0].tolist()] = detrend(W)/std(W)
for j in range(0,W.shape[1]):
data[:,:,:,j] = reshape(f,(bnifti.shape[0],bnifti.shape[1],bnifti.shape[2] ), order='F')
img = Image.from_image(bnifti,data=data)
os.chdir(savepath)
fn = ONAME + "%s.nii" % (str(i)) # Where result should be saved and under what name
save_image(img,fn)
示例3: make_image
# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import from_image [as 别名]
def make_image(self, X, base_nifti):
'''Create a nitfi image from array.
Args:
X (numpy.array): array from which to make nifti image.
base_nifti (nipy.core.api.Image): nifti image template.
Returns:
nipy.core.api.Image
'''
image = Image.from_image(base_nifti, data=X)
return image
示例4: make_image
# 需要导入模块: from nipy.core.api import Image [as 别名]
# 或者: from nipy.core.api.Image import from_image [as 别名]
def make_image(self, X, base_nifti, do_pca=True):
if self.pca is not None and do_pca and self.pca_components:
X = self.pca.inverse_transform(X)
image = Image.from_image(base_nifti, data=X)
return image