After fmriprep, some files have a datatype float32 while others have int16

Hi all,

Just noticed that most of my fmriprep preprocessed files have a datatype in the nifty header listed as float32 but some have int16 – why would this be? They were all int16 before fmriprep.
I only realised while trying to bandpass filter with Matlab and they were being read in differently with niftiread.

Any help is appreciated!


1 Like

Hi, could you post a listing of files and their types? If you have nibabel installed:

nib-ls /path/to/data/**/*.nii.gz

I believe we save BOLD series as float32, label files as int16, and mask files as uint8. The decision was that consistent outputs are more important than maintaining storage parity with the inputs.


Sure! Only a few subjects files after preprocessing including ica aroma are int16 (first one being sub-04 in the first file and sub-05 in the second file).

Also, thought it would be worth mentioning, I was running some test analyses (with just the first few subjects) and extracting signal for a few networks using reference maps and found that only sub-04 (the first sub with the int16 format) had something weird going on – the signal for all four networks was negative only for sub-04 and the values for this subject ranged from -4000 to -11000 while the other subs ranged from 400-900 – which seemed sort of weird to me. Not sure if its related though, could be something else I guess!

nib-ls_list_of_output_files.txt (178.9 KB)

nib-ls_list_of_output_files_t4.txt (139.0 KB)

Really appreaciate your help!

Hi @effigies,

Small update, I just extracted signal from more subjects (for the same rois) to see if it was happening consistently. Did it for 58 subjects and all the ones which have the int16 initial format are read in wrongly with niftiread, but when I check the images with fsleyes or mricron, the values are floats in the regular range and aren’t all negative, so something is going wrong when reading them in with niftiread in matlab because of the header information I think.

Thanks for the nib-ls outputs. What version of fMRIPrep were you using, by the way?

Also, yes, it sounds like niftiread is not applying the scale factors in scl_slope and scl_inter. I would not recommend using this tool, if it doesn’t correctly interpret NIfTI files.

Edit: It looks like niftiread is non-conformant in other ways ( If you need to use MATLAB, it’s probably better to use the IO functions provided by SPM or FreeSurfer.

Hi, sorry for the slow reply!

I’m using 1.3.2.

Thanks for that! Good to know, didn’t know that scale factors are being incorrectly applied.

I was very concerned when niftiread did that, and I thought it was my data, but when I viewed it in fsleyes/mricron and imported it with python and nibabel, it was completely fine. Niftiread had made me super skeptical, going to switch to python I think as python-nibabel was also significantly faster.

:+1: Glad to hear it. This community is pretty well-versed in Python, so feel free to come back for questions. Another good place is the BrainHack Mattermost (it’s like Slack, but the Slack got too big for the free tier) python_pals channel.

1 Like

Thanks for the advice :slight_smile:
Just joined python pals!