fmri.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:modl 作者: arthurmensch 项目源码 文件源码
def score(self, imgs, confounds=None):
        """
        Score the images on the learning spatial pipelining, based on the
        objective function value that is minimized by the algorithm. Lower
        means better fit.

        Parameters
        ----------
        imgs: list of Niimg-like objects
            See http://nilearn.github.io/building_blocks/manipulating_mr_images.html#niimg.
            Data on which PCA must be calculated. If this is a list,
            the affine is considered the same for all.

        confounds: CSV file path or 2D matrix
            This parameter is passed to nilearn.signal.clean. Please see the
            related documentation for details

        Returns
        -------
        score: float
            Average score on all input data
        """
        if (isinstance(imgs, str) or not hasattr(imgs, '__iter__')):
            imgs = [imgs]
        if confounds is None:
            confounds = itertools.repeat(None)
        scores = Parallel(n_jobs=self.n_jobs, verbose=self.verbose)(
            delayed(self._cache(_score_img, func_memory_level=1))(
                self.coder_, self.masker_, img, these_confounds)
            for img, these_confounds in zip(imgs, confounds))
        scores = np.array(scores)
        try:
            len_imgs = np.array([check_niimg(img).get_shape()[3]
                                 for img in imgs])
        except ImageFileError:
            len_imgs = np.array([np.load(img, mmap_mode='r').shape[0]
                                 for img in imgs])
        score = np.sum(scores * len_imgs) / np.sum(len_imgs)
        return score
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号