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
评论列表
文章目录