Repository navigation
no parcellation for GLM with Freesurfer. #343
Description
Activity
Can you also please add Desikan-Killiany Atlas from Freesurfer to fetch parcellation.
Hi @knutj — a couple of things bundled here, let me address them separately.
1. GLM on FreeSurfer
.mghdata with parcellation output (MATLAB). You can use BrainStat's MATLAB stack directly; the input just needs to be ann_subjects × n_verticesmatrix onfsaverage(or whichever template you used). Rough sketch:% Load thickness for each subject onto fsaverage Y = zeros(numel(subjects), 327684); % both hemispheres, fsaverage for i = 1:numel(subjects) [lh, ~] = SurfStatReadData1(fullfile(subjects{i}, 'surf', 'lh.thickness.fsaverage.mgh')); [rh, ~] = SurfStatReadData1(fullfile(subjects{i}, 'surf', 'rh.thickness.fsaverage.mgh')); Y(i, :) = [lh; rh]'; end % Build the model age = FixedEffect(tbl.age); sex = FixedEffect(tbl.sex); group = FixedEffect(tbl.group); M = 1 + age + sex + group; contrast = tbl.group == 'patient'; % Fit, with FDR correction slm = SLM(M, contrast, 'surf', 'fsaverage', 'correction', {'fdr'}); slm.fit(Y); % Per-vertex p-values are in slm.Q. To roll them up to a parcellation: parc = fetch_parcellation('fsaverage', 'schaefer', 400); % or 'aparc' for DK roi_mean_p = accumarray(parc(parc>0), slm.Q(parc>0), [], @mean);
The "parcellation for each p-value" part isn't a built-in helper — you aggregate the per-vertex
slm.Q(FDR-corrected) over whichever parcellation you load.2. Adding the Desikan–Killiany (
aparc) atlas tofetch_parcellation. Reasonable ask; todayfetch_parcellationships Schaefer / Glasser / Yeo / economo. DK is already onfsaverageas?h.aparc.annotso it would be a small loader addition rather than a new download. PRs welcome — the relevant function isbrainstat.datasets.parcellation.fetch_parcellation(Python) andfetch_parcellation.min the MATLAB tree.3. MATLAB tutorial gap. Confirmed — the Sphinx tutorials are Python-only; MATLAB users currently have to translate by reading the function help. A short MATLAB walkthrough alongside the Python ones would be a useful addition; happy to take PRs.
- addedDocumentationImprovements or additions to documentationImprovements or additions to documentationMATLABOn the MATLAB implementationOn the MATLAB implementationquestionFurther information is requestedFurther information is requested
on May 4, 2026 Partially addressed in #380:
fetch_parcellation(template, "destrieux", ...)now returns the FreeSurfer aparc.a2009s parcellation via nilearn (fsaverage5 native; other fsaverage templates resampled nearest-neighbour). The original ask also included aparc/Desikan-Killiany; that one needs a hosted .annot file, so it's left as a follow-up tracked here. The MATLAB-tutorial gap from your third point is still open and would be a useful contribution.- added a commit that references this issue
on May 4, 2026
I am trying to run GLM on Freesurfer mgh and get out parcellation for each p-values after FDR
I used the example and use fsaverage ad template and used SurfStatReadSurf1 to read in mgh.
Matlab 2022b and Ubuntu 22.04
The tutorial lack example that used matlab.