Last active
September 11, 2018 14:24
-
-
Save kchawla-pi/92104b885f6106e56867ec2fa6b3955d to your computer and use it in GitHub Desktop.
Gist to replicate an error in param checks for nistats.second_level_model.SecondLevelModel.fit()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nilearn | |
import os | |
import pandas | |
from nistats.second_level_model import SecondLevelModel | |
# 4D images paths | |
img1 = nilearn.image.load_img(os.path.expanduser('~/nilearn_data/adhd/data/0010128/0010128_rest_tshift_RPI_voreg_mni.nii.gz')) | |
img2 = nilearn.image.load_img(os.path.expanduser('~/nilearn_data/adhd/data/2497695/2497695_rest_tshift_RPI_voreg_mni.nii.gz')) | |
# Single 4D image | |
c = pandas.DataFrame([[1]] * img1.shape[3], columns=['intercept']) | |
second_level_model = SecondLevelModel(smoothing_fwhm=2.0) | |
second_level_model.fit(img1, design_matrix=c) | |
# Single element list with 4D image | |
c = pandas.DataFrame([[1]] * img1.shape[3], columns=['intercept']) | |
second_level_model = SecondLevelModel(smoothing_fwhm=2.0) | |
second_level_model.fit(img1, design_matrix=c) | |
# Multiple elements list with 4D image | |
imgs = [img1, img2] | |
c = pandas.DataFrame([[1]] * len(imgs), columns=['intercept']) | |
second_level_model = SecondLevelModel(smoothing_fwhm=2.0) | |
second_level_model.fit(imgs, design_matrix=c) # This one is caught by the new behaviour I programmed in. List of multiple 4D niimgs fails with a ValueError | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment