MAGNITUDE FILE WITH TOO MANY DIMENSIONS - getting from B0 field maps magnitude1.nii.gz

Hi,

I am getting following error when I try process fMRI data using fMRIprep 20.1.1. These magnitude files are B0 field maps files. Has anyone seen these issue before? How can I fix it.

It’s providing me link to find more details regarding this issue which is not working.

1: [ERR] _magnitude1.nii[.gz] and _magnitude2.nii[.gz] files must have exactly three dimensions. (code: 94 - MAGNITUDE_FILE_WITH_TOO_MANY_DIMENSIONS)
./sub-50015/ses-1/fmap/sub-50015_ses-1_run-1_magnitude1.nii.gz
Evidence: this magnitude file has more than three dimensions.
./sub-50015/ses-2/fmap/sub-50015_ses-2_run-1_magnitude1.nii.gz
Evidence: this magnitude file has more than three dimensions.

:Please visit [https://neurostars.org/search?q=MAGNITUDE_FILE_WITH_TOO_MANY_DIMENSIONS]

Thanks in advance.

Sameera

What is the shape of the data in the file?

@tsalo, the shape of the data in the file is - (128, 128, 66, 2)

It sounds like there are two volumes in your file. Do you know what they correspond to? There should be only 1, and there should be no fourth dimension.

@tsalo, Our data was collected using a SIEMENS scanner. SIEMENS scanner takes the form of one phase difference image and two magnitude images (one for each echo time) . I split the 4D image using fslsplit and named them as magnitude1 and magnitude2. Now no issue with bids-validation. However, I am getting a new error when processing data with fMRIprep

Here are the files inside bids - fmap folder.
sub-50010_ses-1_run-1_magnitude1.nii.gz
sub-50010_ses-1_run-1_phase1.json
sub-50010_ses-1_run-1_phase1.nii.gz
sub-50010_ses-1_run-2_magnitude2.nii.gz

fMRIPrep failed: Each element of the ‘in_files’ trait of a _IntraModalMergeInputSpec instance must be a pathlike object or string representing an existing file, but a value of ‘/mnt/fMRIprep/scR21_B0_fieldmaps/sub-50010/ses-1/fmap/sub-50010_ses-1_run-1_magnitude2.nii.gz’ <class ‘str’> was specified.

Thank you so much
Sameera

I’m glad you were able to resolve the main issue. Now it looks like you just have two small things that need to be fixed.

  1. sub-50010_ses-1_run-1_phase1.[nii.gz|json] --> sub-50010_ses-1_run-1_phasediff.[nii.gz|json]
    • The appropriate suffix for a phase-difference map is phasediff.
  2. sub-50010_ses-1_run-2_magnitude2.nii.gz --> sub-50010_ses-1_run-1_magnitude2.nii.gz
    • The two magnitude volumes are from the same run.
    • The error is because it’s looking for the magnitude2 file for run-1 (which doesn’t exist), not run-2.

@tsalo, Yes, it worked. Thank you so much for helping me to fix these issues.

I was able finish FreeSurfer preprocessing. However, I am getting new error for all the sessions/func-runs. I am only pasting ses-1_task-RSFC_run-1 error,

Node Name: fmriprep_wf.single_subject_50010_wf.func_preproc_ses_1_task_RSFC_run_1_wf.sdc_estimate_wf.phdiff_wf.phmap2rads

File: /mnt/fMRIprep/scR21_outputs_B0/fmriprep/sub-50010/log/20200704-005807_29d61ea4-0206-4416-a055-4c80773b3969/crash-20200704-010743-sameera-phmap2rads-f8ac2ff0-ee7f-4dcf-8dbb-c7ecb722e764.txt
Working Directory: /mnt/fMRIprep/scR21_outputs_B0/derivatives/scratch/fmriprep_wf/single_subject_50010_wf/func_preproc_ses_1_task_RSFC_run_1_wf/sdc_estimate_wf/phdiff_wf/phmap2rads
Inputs:
in_file:
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/plugins/multiproc.py”, line 292, in _send_procs_to_workers
num_subnodes = self.procs[jobid].num_subnodes()
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 1309, in num_subnodes
self._get_inputs()
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 1323, in _get_inputs
super(MapNode, self)._get_inputs()
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 609, in _get_inputs
self.set_input(key, deepcopy(output_value))
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 1158, in set_input
self._set_mapnode_input(parameter, deepcopy(val))
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py”, line 1165, in _set_mapnode_input
setattr(self._inputs, name, newvalue)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/traits_extension.py”, line 426, in validate
value = super(MultiObject, self).validate(objekt, name, newvalue)
File “/usr/local/miniconda/lib/python3.7/site-packages/traits/trait_types.py”, line 2336, in validate
return TraitListObject( self, object, name, value )
File “/usr/local/miniconda/lib/python3.7/site-packages/traits/trait_handlers.py”, line 2313, in init
raise excp
File “/usr/local/miniconda/lib/python3.7/site-packages/traits/trait_handlers.py”, line 2305, in init
value = [ validate( object, name, val ) for val in value ]
File “/usr/local/miniconda/lib/python3.7/site-packages/traits/trait_handlers.py”, line 2305, in
value = [ validate( object, name, val ) for val in value ]
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/traits_extension.py”, line 330, in validate
value = super(File, self).validate(objekt, name, value, return_pathlike=True)
File “/usr/local/miniconda/lib/python3.7/site-packages/nipype/interfaces/base/traits_extension.py”, line 135, in validate
self.error(objekt, name, str(value))
File “/usr/local/miniconda/lib/python3.7/site-packages/traits/trait_handlers.py”, line 172, in error
value )
traits.trait_errors.TraitError: Each element of the ‘in_file’ trait of a DynamicTraitedSpec instance must be a pathlike object or string representing an existing file, but a value of ‘/mnt/fMRIprep/scR21_B0_fieldmaps/sub-50010/ses-1/fmap/sub-50010_ses-1_run-1_phase2.nii.gz’ was specified.

Error setting node input:
Node: phmap2rads
input: in_file
results_file: /mnt/fMRIprep/scR21_outputs_B0/derivatives/scratch/fmriprep_wf/single_subject_50010_wf/func_preproc_ses_1_task_RSFC_run_1_wf/sdc_estimate_wf/phdiff_wf/split/result_split.pklz
value: [’/mnt/fMRIprep/scR21_B0_fieldmaps/sub-50010/ses-1/fmap/sub-50010_ses-1_run-1_phase1.nii.gz’, ‘/mnt/jxvs02/fMRIprep/scR21_B0_fieldmaps/sub-50010/ses-1/fmap/sub-50010_ses-1_run-1_phase2.nii.gz’]

When creating this crashfile, the results file corresponding
to the node could not be found.

Can you please help me to fix this issue?

Thank you
Best Regards
Sameera

It looks like it is looking for a phase2 file, which it should only need if it is trying to calculate a phase-difference map from two separate phase files. Did you rename your phase1 file to phasediff?

@tsalo, yes I tried that way (rename phase1 file to phasediff) and then I got following error

^[[31m1: [ERR] You have to define ‘EchoTime1’ and ‘EchoTime2’ for this file. (code: 15 - ECHO_TIME1-2_NOT_DEFINED)^[[39m
./sub-50010/ses-1/fmap/sub-50010_ses-1_run-1_phasediff.nii.gz
./sub-50010/ses-2/fmap/sub-50010_ses-2_run-1_phasediff.nii.gz

When I renamed the file back to phase1 then, I was able to run fMRIprep until I got the last error. I will find the ‘EchoTime1’ and ‘EchoTime2’ for phasediff file and try to rerun it again.

Thank you so much
Sameera

Yes, the specification supports either phasediff + magnitude1 (and optionally magnitude2) or phase1 + phase2 + magnitude1+ magnitude2. As you said before, Siemens field maps are generally phase-difference ones, I think.

The good news is that you can get the two echo times from the two magnitude files since they weren’t written into the phasediff image’s json file automatically your conversion software.

Hi @tsalo, I was able to find two echos from the two magnitude files and run fMRIprep without any errors.

Thank you so much for helping me to solve these issues.

Best Regards
Sameera

1 Like

Hello, I have philips fieldmap which upon conversion resulted in what appears to be a magnitude1 and a phasediff image. However, when I run BIDSvalidator before running fmriprep it still gives the echo 1 and echo 2 error. How can I get it to work without supplying a second echo for the first use case example you gave?

Is the validator error saying that the phase-difference file is missing the EchoTime1 and EchoTime2 metadata fields? If so, then the that information should be available somewhere. What do the phase-difference and magnitude files have for their standard EchoTime fields?

EDIT: I see that this issue is linked to Converting Philips Fieldmaps to BIDS and finding Echo time 1 and Echo time 2, in which you say that the echo times for both the phase-difference and magnitude images are 0.0032.

I noticed that the PAR/REC metadata included delta TE (ms) = 1;, which would indicate to me that the second echo time is 4.2 ms (since we know that 3.2 ms is the shortest TE). However, I need to warn you that I have zero experience with PAR/REC files or Philips data in general, so you should take that with a big grain of salt. I didn’t read the other topic in detail, but I did see that @Chris_Rorden responded there. If he has something different to say about the issue, then I’d trust him.

Hi Tsalo, thanks for the quick response. It turns out that the value for Echo_Time from the PAR header file for the second image was actually zero (which I guess would make sense if it’s a phasediff and not a magnitude image). So that doesn’t help.

EDIT: I should emphasize here that I do not know for sure that the second image is a phasediff. As I mention at the end of the other topic, the image_type_mr field in the PAR file indicates a numeric value which seems to be linked to a “B0” label. If someone with knowledge of PAR/REC files could chime in, that would be one less source uncertainty.

I also noted the delta TE value (from the scanner settings) but couln’t find any info on it, and wasn’t sure how to interpret it, but your interpretation seems plausible.

Do you think a good strategy would be testing it with those values to see if fMRIprep seems to perform a distortion correction correctly? Would this be evident in a visual inspection comparing the images?

And indeed, Chris had some excellent pointers.

I am not sure. I think it would be best to ask a distortion correction expert, so I will ping @oesteban to see if he has any thoughts on that approach.

Great!! Hopefully with the information I provide in the other post from both the scanner settings and PAR file, someone with experience might be able to decode the necessary values. I tried to extract/highlight what I thought may be important fields.

Thanks again!

4 posts were merged into an existing topic: Converting Philips Fieldmaps to BIDS and finding Echo time 1 and Echo time 2

A post was merged into an existing topic: Converting Philips Fieldmaps to BIDS and finding Echo time 1 and Echo time 2