Error when converting t1w to BIDS: t1w file with too many dimensions

Hi everyone,

I’m trying to convert my MRI (mostly t1w) database into BIDS, from the nifti files (i don’t have any DICOM).
For half of the subjects (130), i’m facing an error when i try to validate my dataset using BIDS validator:

Error 3: [Code 95] T1W_FILE_WITH_TOO_MANY_DIMENSIONS.
sub-0XXX_ses-1_T1w.nii.gz
11054.205 KB | application/gzip
Location:
BIDS/sub-0XXX/ses-1/anat/sub-0XXX_ses-1_T1w.nii.gz
Reason:
_T1w.nii[.gz] files must have exactly three dimensions.
Evidence:
this T1w file does not have exactly three dimensions.

I checked the header of one problematic t1w compared to a valid one with fslinfo. Here are the logs:

Problematic t1w:

data_type INT16
dim1 256
dim2 256
dim3 182
dim4 1
datatype 4
pixdim1 1.000000
pixdim2 1.000000
pixdim3 1.000000
pixdim4 0.009861
cal_max 0.0000
cal_min 0.0000
file_type NIFTI-1+

Valid t1w:

data_type INT16
dim1 512
dim2 512
dim3 120
dim4 1
datatype 4
pixdim1 0.498047
pixdim2 0.498047
pixdim3 1.000000
pixdim4 0.015000
cal_max 0.0000
cal_min 0.0000
file_type NIFTI-1+

We can see that, for both, dim4=1.

Do you have any idea of what is happening ? Any solutions ?

Thanks a lot,

mprl

That is weird. Could you share the example files?

Try fslhd $IMG | grep dim0. I suspect that you’ll find your valid image has dim0 = 3 while your invalid has some larger value.

@ChrisGorgolewski Here is one problematic t1w

@effigies It’s giving this output:

dim0 3
pixdim0 0.000000

for both valid and non-valid mri.

Could not replicate with the web and CLI validators. Are you using the latest version?

Nevermind. I was indeed using the wrong version of the web validator.
Thanks a lot for your help. It is working now.

1 Like

@mprl I’m facing the same issue. Which validator version did you use later?

Hi @Praitayini_Kanakaraj

We have made several enhancements to the BIDS Validator in the meantime. Are you using the latest version?

Thank you,
Franklin

I’m having the same problem when using fmriprep docker latest. Here’s the error message:

bids-validator@1.4.0

1: [ERR] _T1w.nii[.gz] files must have exactly three dimensions. (code: 95 - T1W_FILE_WITH_TOO_MANY_DIMENSIONS)
./sub-06/anat/sub-06_T1w.nii
Evidence: this T1w file does not have exactly three dimensions.

Here’s an example of the problematic t1w file: t1w

Many thanks for your help.

dim0 is 4.

$ fslhd Downloads/sub-06_T1w.nii 
filename       Downloads/sub-06_T1w.nii

sizeof_hdr     348
data_type      INT16
dim0           4
dim1           240
dim2           256
dim3           176
dim4           1
dim5           1
dim6           0
dim7           0
[...]

You can clean this up with fslroi:

fslroi <input> <output> 0 1

Rerunning fslhd:

sizeof_hdr     348
data_type      INT16
dim0           3
dim1           240
dim2           256
dim3           176
dim4           1
dim5           1
dim6           1
dim7           1

Difference:

1c1
< filename       Downloads/sub-06_T1w.nii
---
> filename       sub-06_T1w.nii.gz
5c5
< dim0           4
---
> dim0           3
11,12c11,12
< dim6           0
< dim7           0
---
> dim6           1
> dim7           1
66c66
< descrip        MPRAGE P2_ND
---
> descrip        5.0.11

It works fine now, many thanks for your help!