Dear SPM experts,
I have started using SPM recently and I am stuck on a procedure I would like to solve as soon as possible.
Basically I have:
- a nifti image with all the active clusters from a 1st level model's contrast (SPM → Results → SPM.mat → select contrast → save... all clusters (n-ary)) in native space.
- a binary mask of the inferior temporal lobe in native space.
I would like to modify my mask so that it includes only the 500 most active voxels from the clusters within the mask (hope it is clear).
So far I proceeded like that:
% load the image and check if headers are the same (specifically dim and mat)
con_image = spm_vol(contrast_image_name);
mask_image = spm_vol(mask_image_name);
con = spm_read_vols(con_image);
mask = spm_read_vols(mask_image);
% all voxels of the contrast image that are outside the mask become nan
con(image==0) = nan;
sortcon = con(:);
sortcon = sortrows(sortcon); % order the voxels
threshcon = sortcon(1:500); % select the 500 most active contrasts
At this point I stopped, and I am also unsure what I did is correct...
I would like now to select the voxels of the mask that correspond to the 500 most active voxels (within the mask) of the contrast image, and then resample the mask so that it becomes a binary mask containing only these 500 voxels.
I need this mask functionally-defined to extract beta values for other analyses.
Hope I explained my issue clearly and I would really appreciate your expertise on that!
Best wishes,
Alessio
|