When passing a 4D image to SecondLevelModel.fit(), no error is raise although the documentation says that possible input values are either a list of FirstLevelModel, a list of images, or a pandas dataframe. When computing contrasts, this raises the following error:
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]
See this Neurostars post
When passing a 4D image to
SecondLevelModel.fit()
, no error is raise although the documentation says that possible input values are either a list ofFirstLevelModel
, a list of images, or a pandas dataframe. When computing contrasts, this raises the following error:which occurs when indexing the inputs here:
https://github.com/nilearn/nilearn/blob/5a740b1ce92da9c646cb6812f559ed73c2036f43/nilearn/glm/second_level/second_level.py#L124-L128
Nilearn version: 0.8.2.dev
Steps and code to reproduce bug
Fix
If 4D images are allowed, update the docs and fix the indexing. Otherwise raise an error when checking the inputs in
fit