I am using nilearn for decoding my data. I’ve been following this tutorial: ROI-based decoding analysis in Haxby et al. dataset - Nilearn
However, this line gives me an error:
mask_filename = func_img_run1[mask_name]
I am using my own data (single subject) instead of Haxby dataset. I am attaching the error message below:
TypeError Traceback (most recent call last)
in
7 print(“working on %s” % mask_name)
8
----> 9 mask_filename = func_img_run1[mask_name]
10 masker = NiftiMasker(mask_img=mask_filename, standardize = True)
11 mask_scores[mask_name] = {}
~/opt/anaconda3/lib/python3.8/site-packages/nibabel/spatialimages.py in getitem(self, idx)
583 own risk.
584 “”"
→ 585 raise TypeError(
586 "Cannot slice image objects; consider using img.slicer[slice]
"
587 "to generate a sliced image (see documentation for caveats) or "
TypeError: Cannot slice image objects; consider using img.slicer[slice]
to generate a sliced image (see documentation for caveats) or slicing image array data with img.dataobj[slice]
or img.get_fdata()[slice]
func_img_run1.shape returns (64, 64, 40, 75). Any help or insight into this issue would be greatly appreciated. Thanks.