Spatial Mask for Permutation Clustering Test

Hello,

I’m currently trying to run the spatio_temporal_cluster_test on an a priori region of the brain; however I’m not quite sure how to get the list of spatial indices for the spatial_exclude parameter. I’m working in volumetric source space and all the help I’ve been able to find has focused on surface source space and used .label files to find the indices which doesn’t appear to work for volumetric source space.

Any advice on how to take a nifti of a mask and get the spatial indices to exclude from that would be appreciated.

Best,
Chris

Hi @cpirrung,
mne has support for checking if volumetric points are contained in specified atlas labels. An example of this can be found in this tutorial (search for “volumetric” on this page to find the relevant part) and some overview in this pull request.
We were doing a bit permutation cluster testing in volumetric source space with @nruban and, if I remember correctly, picking the correct indices by hand was not straightforward because the order of src volumetric data in mne is Fortran-way, not the default C-way, which we found out only later with trial and error. Nastia do you have a piece of code to share to help @cpirrung with selecting volume indices for cluster-based test?

Hi @mmagnuski,
Thank you for the help! That tutorial was very helpful. If you happen to have that code, that would be greatly appreciated!

This is an example of code we used to find vertices corresponding to labels (the problem with array ordering appeared later, when simulating sources in volume space):

labels = mne.read_labels_from_annot('fsaverage')

labels_list = ['ctx-rh-caudalanteriorcingulate',
               'ctx-lh-caudalanteriorcingulate',
               'ctx-rh-rostralanteriorcingulate',
               'ctx-lh-rostralanteriorcingulate']
verts_sel = list()

for label in labels_list:
    vol_stc_label = stc.in_label(label,
                                 mri, src)
    verts_sel.append(vol_stc_label.vertices)

verts_sel = np.concatenate(verts_sel, axis=1)