當前位置: 首頁>>代碼示例>>Python>>正文


Python Image.from_image方法代碼示例

本文整理匯總了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
開發者ID:ecastrow,項目名稱:pl2mind,代碼行數:31,代碼來源:MRI.py

示例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)
開發者ID:caitlynralph,項目名稱:mrn2016,代碼行數:27,代碼來源:sources_to_nifti.py

示例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
開發者ID:Jeremy-E-Johnson,項目名稱:cortex,代碼行數:15,代碼來源:mri.py

示例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
開發者ID:nidl,項目名稱:cortex,代碼行數:7,代碼來源:fmri.py


注:本文中的nipy.core.api.Image.from_image方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。