geneticalgorithm.py 文件源码

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

项目:neurodesign 作者: neuropower 项目源码 文件源码
def CreateLmComp(self):
        '''
        This function generates components for the linear model: hrf, whitening matrix, autocorrelation matrix and CX
        '''

        # hrf
        self.canonical(0.1)

        # contrasts
        # expand contrasts to resolution of HRF (?)
        prec = int(self.laghrf/(self.hrf_precision/self.resolution))
        self.CX = np.kron(self.C, np.eye(prec))

        # drift
        self.S = self.drift(np.arange(0, self.n_scans))  # [tp x 1]
        self.S = np.matrix(self.S)

        # square of the whitening matrix
        base = [1 + self.rho**2, -1 * self.rho] + [0] * (self.n_scans - 2)
        self.V2 = scipy.linalg.toeplitz(base)
        self.V2[0, 0] = 1
        self.V2 = np.matrix(self.V2)
        self.V2[self.n_scans - 1, self.n_scans - 1] = 1

        self.white = self.V2 - self.V2 * \
            t(self.S) * np.linalg.pinv(self.S *
                                       self.V2 * t(self.S)) * self.S * self.V2

        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号