MIR.statistical_analysis.GLM¶
- MIR.statistical_analysis.GLM(X, Y, mask=None)[source]¶
Perform voxel-wise General Linear Model (GLM) fitting by ordinary least squares.
betas = pinv(X^T X) X^T Y; the residual variance usesdf = N - rank(X)(at least 1) and the t-statistic of coefficientjisbeta_j / sqrt(sigma2 * pinv(X^T X)[j, j]).- Parameters:
X (torch.Tensor) – (N, P) design matrix.
Y (torch.Tensor) – (N, V) data matrix.
mask (torch.Tensor | None) – (H, W, D) boolean mask to select voxels (optional); if given,
Vmust equalH*W*Dand only masked columns ofYare fitted.
- Returns:
Tuple
(betas, t_maps)–betas(P, V’) estimated coefficients andt_maps, a list of P tensors (V’,) with the t-statistic of each coefficient (V'= number of fitted voxels).- Return type:
Tuple[torch.Tensor, List[torch.Tensor]]