NiftiMasker
only accepts a binary mask, however, I would like to return the voxel timeseries separated by ROIs. There is too much overhead involved with resampling the image if I instantiate a new mask for each region. For example, the code below takes about 1 hour per image:
for roi in rois:
atlas_roi = math_img('img == %d" %roi, img=atlas_img)
roi_mask = NiftiMasker(mask_img=atlas_roi, standardize=True)
roi_timeseries = roi_mask.fit_transform(fmri_img)
If I binarize my current atlas, I can efficiently retrieve all of the voxels for the entire atlas, but I lose information as to which ROI each voxel belongs to. atlas_timeseries
has shape (n_timesteps, n_voxels). This code takes only 3 minutes per image:
atlas_mask = NiftiMasker(mask_img=binarized_atlas_img, standardize=True)
atlas_timeseries = atlas_mask.fit_transform(fmri_img)
Ideally, I would like to only call NiftiMasker
once with a non-binary mask, and return a list with dimensions (n_rois, n_timesteps, n_voxels_in_roi_i). How would this be achievable?