From fMRIPrep outputs to stat analysis in MATLAB

Hi everyone !

After hours of reading on forums, I end up writing here to find an answer ^^

I preprocessed my fMRI data using fMRIPrep and we decided to switch to MATLAB for the statistical analyses but none of us understand how to make fmriprep outputs fit matlab requirements. Biggest problem is how to go from 1 file containing all images to 1 file per image ?
Is it necessary to do it or does it depend on the matlab script we use ?

We found some scripts but never really understood how to make them work.
It seems that many people are actually doing it, so we were hoping for a clearer and somehow “more widely used” solution.

Sorry if this is unclear, and thank you for your help !

Best,

Samantha

When you mean matlab, you mean SPM?

If so you do not need to convert your 4D nifti to a 3D nifti, SPM can handle those just fine.

1 Like

Thank ! That’s what I was thinking ! It would have been strange otherwise. :smile:
I don’t know matlab/spm at all, always have been coding on python so I have no idea how to handle this. I was a bit afraid to try things from nowhere ^^

Actually when we try to feed our batch with the file, we get an error like “not enough scans”… And I just saw the “1” beside the file name ? Could it be it takes only the first image from the file ? Should I somehow select also the other images ? :thinking:

yup SPM default is to expect 3D nifti images so it will try to select a specific volume.

Often appears in a batch as

sub-1_task-foo_bold.nii, 1

where the , 1 indicates the first volume.

When selecting files with the GUI, you can change which volume or range of volumes to select (in this example from volume 2 to 10. If you want to see all the volumes replaces this with Inf)

Screenshot from 2022-04-27 14-37-51

When scripting have a look at spm_select where the frames parameter allows you filter and select only specific volumes.

  FORMAT [files,dirs] = spm_select('ExtList',direc,filt,frames)
  As above, but for selecting frames of 4D NIfTI files
  frames - vector of frames to select (defaults to 1, if not specified).
           If the frame number is Inf, all frames for the matching images
           are listed. 

Thank you so much ! You saved my day ! :pray: :pray:
It is way clearer now ! :sweat_smile: