Trying to load first-level contrasts that were generated with an SPM workflow.
contrasts = ['01']
cont_list = 
for contrast in contrasts:
con_file_list = glob('./results/l1spm_resp/_subject_id_*/contrastestimate/con_00'+contrast+'.nii')
con_dat = Brain_Data(con_file_list)
Results in this resampling warning:
.conda_envs/py37_dev/lib/python3.7/site-packages/nilearn/image/resampling.py:602: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
Printing cont_list gives:
[nltools.data.brain_data.Brain_Data(data=(238955,), Y=0, X=(0, 0), mask=MNI152_T1_2mm_brain_mask.nii.gz, output_file=)]
And plotting cont_list.iplot() gives:
This is my first time working with first-level analyses, and I’m not sure what is generating these resampling RuntimeWarnings, in addition to whether this type of output looks reasonable. Would appreciate any help. Thanks!
Hi @cyx203 ,
Thanks for reaching out ! Could you please include the information requested in the topic template, incl the version of the software you’re using ?
In particular, it looks like you’ve tagged this topic with the
nilearn software but you’re using the
nltools software in your code snippets. nltools is calling nilearn internally, but I’m not sure from that API how best to pass an
ensure_finite=True argument to your image loading.
I don’t think that we have an
nltools tag right now, but @ejolly and @ljchang might be able to point you in the right direction – or let us know if we should add a new tag to the forum
Hi @cyx203 & @emdupre, nltools uses nilearn to automatically resample data into a default 2x2x2mm space. Every software stores their data in slightly different ways and this is a fairly common warning when loading data from SPM. Everything seems like it is working based on your picture, but my guess is that it was fairly slow to load. You can write out new images that have been resampled once this is done using
Brain_Data(cont_list).write('file_name') if you use
.nii.gz as the file name extension it will write out a gzipped nifti file. you can also use
.hdf5 which will save the object as an hdf5 file, which is much faster to read and write, but not compatible with other software.