Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N4BiasFieldCorrection fails on multiple run dataset #3314

Open
mariagiuliat opened this issue Jun 20, 2024 · 1 comment
Open

N4BiasFieldCorrection fails on multiple run dataset #3314

mariagiuliat opened this issue Jun 20, 2024 · 1 comment
Labels

Comments

@mariagiuliat
Copy link

mariagiuliat commented Jun 20, 2024

What happened?

We are running fmriprep on a dataset composed by two different sessions, each one with two tasks and two resting-state. Each task has 5 runs.
The pipeline crashes when doing the N4BiasFieldCorrection. Anyone knows why is this happening?
The error reported is referring only to one run but it happens for all of them.
I also tried to run fmriprep with and without the -u $UID flag

This is my bids tree:

Nifti
├── CHANGES
├── README
├── dataset_description.json
├── participants.tsv
├── sub-01
│   └── ses-post
│   │   ├── anat
│   │    |   ├── sub-01_ses-post_T1w.json
│   │    |   └── sub-01_ses-post_T1w.nii.gz
│   │   └── func
│   │       ├── sub-01_ses-post_task-episodicpost_run1_bold.json
│   │       └── sub-01_ses-post_task-episodicpost_run1_bold.nii.gz
│   │       ├── sub-01_ses-post_task-episodicpost_run2_bold.json
│   │       └── sub-01_ses-post_task-episodicpost_run2_bold.nii.gz
│   │       ├── sub-01_ses-post_task-episodicpost_run3_bold.json
│   │       └── sub-01_ses-post_task-episodicpost_run3_bold.nii.gz
│   │       ├── sub-01_ses-post_task-episodicpost_run4_bold.json
│   │       └── sub-01_ses-post_task-episodicpost_run4_bold.nii.gz
│   │       ├── sub-01_ses-post_task-episodicpost_run5_bold.json
│   │       └── sub-01_ses-post_task-episodicpost_run5_bold.nii.gz
│   │       ├── sub-01_ses-post_task-semanticpost_run1_bold.json
│   │       └── sub-01_ses-post_task-semanticpost_run1_bold.nii.gz
│   │       ├── sub-01_ses-post_task-semanticpost_run2_bold.json
│   │       └── sub-01_ses-post_task-semanticpost_run2_bold.nii.gz
│   │       ├── sub-01_ses-post_task-semanticpost_run3_bold.json
│   │       └── sub-01_ses-post_task-semanticpost_run3_bold.nii.gz
│   │       ├── sub-01_ses-post_task-semanticpost_run4_bold.json
│   │       └── sub-01_ses-post_task-semanticpost_run4_bold.nii.gz
│   │       ├── sub-01_ses-post_task-semanticpost_run5_bold.json
│   │       └── sub-01_ses-post_task-semanticpost_run5_bold.nii.gz
│   │       ├── sub-01_ses-post_task-restpost_run1_bold.json
│   │       └── sub-01_ses-post_task-restpost_run1_bold.nii.gz
│   │       ├── sub-01_ses-post_task-restpost_run2_bold.json
│   │       └── sub-01_ses-post_task-restpost_run2_bold.nii.gz
│   └── ses-pre
│       ├── anat
│        |   ├── sub-01_ses-pre_T1w.json
│        |   └── sub-01_ses-pre_T1w.nii.gz
│       └── func
│           ├── sub-01_ses-pre_task-episodicpre_run1_bold.json
│           └── sub-01_ses-pre_task-episodicpre_run1_bold.nii.gz
│           ├── sub-01_ses-pre_task-episodicpre_run2_bold.json
│           └── sub-01_ses-pre_task-episodicpre_run2_bold.nii.gz
│           ├── sub-01_ses-pre_task-episodicpre_run3_bold.json
│           └── sub-01_ses-pre_task-episodicpre_run3_bold.nii.gz
│           ├── sub-01_ses-pre_task-episodicpre_run4_bold.json
│           └── sub-01_ses-pre_task-episodicpre_run4_bold.nii.gz
│           ├── sub-01_ses-pre_task-episodicpre_run5_bold.json
│           └── sub-01_ses-pre_task-episodicpre_run5_bold.nii.gz
│           ├── sub-01_ses-pre_task-semanticpre_run1_bold.json
│           └── sub-01_ses-pre_task-semanticpre_run1_bold.nii.gz
│           ├── sub-01_ses-pre_task-semanticpre_run2_bold.json
│           └── sub-01_ses-pre_task-semanticpre_run2_bold.nii.gz
│           ├── sub-01_ses-pre_task-semanticpre_run3_bold.json
│           └── sub-01_ses-pre_task-semanticpre_run3_bold.nii.gz
│           ├── sub-01_ses-pre_task-semanticpre_run4_bold.json
│           └── sub-01_ses-pre_task-semanticpre_run4_bold.nii.gz
│           ├── sub-01_ses-pre_task-semanticpre_run5_bold.json
│           └── sub-01_ses-pre_task-semanticpre_run5_bold.nii.gz
│           ├── sub-01_ses-pre_task-restpre_run1_bold.json
│           └── sub-01_ses-pre_task-restpre_run1_bold.nii.gz
│           ├── sub-01_ses-pre_task-restpre_run2_bold.json
│           └── sub-01_ses-pre_task-restpre_run2_bold.nii.gz
│
└── task-episodicpre_bold.json

Thank you!

What command did you use?

RUNNING: docker run --rm -e DOCKER_VERSION_8395080871=26.1.3 -it -u 1003 \
    -v /media/data_1t/keepinmind/derivatives/license.txt:/opt/freesurfer/license.txt:ro \
    -v /media/data_1t/keepinmind:/data:ro \
    -v /media/data_1t/keepinmind/derivatives:/out \
    -v /media/data_1t/keepinmind/code/plugin.yml:/tmp/plugin.yml:ro \
    nipreps/fmriprep:23.2.1 \
    /data /out participant \
    --skip_bids_validation \
    --participant-label 04 \
    --stop-on-first-crash \
    --use-plugin /tmp/plugin.yml \
    --output-spaces MNI152NLin6Asym:res-2 MNI152NLin2009cAsym

What version of fMRIPrep are you running?

fMRIPrep-23.2.1

How are you running fMRIPrep?

Docker

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

No

Please copy and paste any relevant log output.

240618-14:28:42,669 nipype.workflow INFO:
	 [Node] Finished "n4_correct", elapsed time 6.519346s.
Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/run.py", line 155, in main
    fmriprep_wf.run(**config.nipype.get_plugin())
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/workflows.py", line 638, in run
    runner.run(execgraph, updatehash=updatehash, config=self.config)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/plugins/base.py", line 178, in run
    self._clean_queue(jobid, graph, result=result)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/plugins/base.py", line 256, in _clean_queue
    raise RuntimeError("".join(result["traceback"]))
RuntimeError: Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/plugins/legacymultiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node n4_correct.

Cmdline:
	N4BiasFieldCorrection --bspline-fitting [ 200 ] -d 3 --input-image /tmp/work/fmriprep_23_2_wf/sub_04_wf/bold_ses_post_task_semanticpost_run4_wf/bold_fit_wf/hmc_boldref_wf/gen_avg/sub-04_ses-post_task-semanticpost_run4_bold_average.nii.gz --output sub-04_ses-post_task-semanticpost_run4_bold_average_corrected.nii.gz -r --weight-image /tmp/tpl-MNI152NLin2009cAsym_res-01_label-brain_probseg_trans_fixhdr.nii.gz
Stdout:

Stderr:

Traceback:
	Traceback (most recent call last):
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 453, in aggregate_outputs
	    setattr(outputs, key, val)
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/traits_extension.py", line 330, in validate
	    value = super(File, self).validate(objekt, name, value, return_pathlike=True)
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/traits_extension.py", line 135, in validate
	    self.error(objekt, name, str(value))
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/traits/base_trait_handler.py", line 74, in error
	    raise TraitError(
	traits.trait_errors.TraitError: The 'output_image' trait of a _FixN4BiasFieldCorrectionOutputSpec instance must be a pathlike object or string representing an existing file, but a value of '/tmp/work/fmriprep_23_2_wf/sub_04_wf/bold_ses_post_task_semanticpost_run4_wf/bold_fit_wf/enhance_and_skullstrip_bold_wf/n4_correct/sub-04_ses-post_task-semanticpost_run4_bold_average_corrected.nii.gz' <class 'str'> was specified.

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 398, in run
	    runtime = self._post_run_hook(runtime)
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/mixins/fixheader.py", line 127, in _post_run_hook
	    outputs = self.aggregate_outputs(runtime=runtime).get_traitsfree()
	  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 460, in aggregate_outputs
	    raise FileNotFoundError(msg)
	FileNotFoundError: No such file or directory '/tmp/work/fmriprep_23_2_wf/sub_04_wf/bold_ses_post_task_semanticpost_run4_wf/bold_fit_wf/enhance_and_skullstrip_bold_wf/n4_correct/sub-04_ses-post_task-semanticpost_run4_bold_average_corrected.nii.gz' for output 'output_image' of a FixN4BiasFieldCorrection interface



During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/fmriprep/bin/fmriprep", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/cli/run.py", line 217, in main
    failed_reports = generate_reports(
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/reports/core.py", line 96, in generate_reports
    report_errors = [
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/reports/core.py", line 97, in <listcomp>
    run_reports(
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/fmriprep/reports/core.py", line 86, in run_reports
    ).generate_report()
  File "/opt/conda/envs/fmriprep/lib/python3.10/site-packages/niworkflows/reports/core.py", line 435, in generate_report
    (self.out_dir / self.out_filename).write_text(report_render, encoding="UTF-8")
  File "/opt/conda/envs/fmriprep/lib/python3.10/pathlib.py", line 1154, in write_text
    with self.open(mode='w', encoding=encoding, errors=errors, newline=newline) as f:
  File "/opt/conda/envs/fmriprep/lib/python3.10/pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
PermissionError: [Errno 13] Permission denied: '/out/sub-04.html'
fMRIPrep: Please report errors to https://github.com/nipreps/fmriprep/issues

Additional information / screenshots

No response

@tsalo
Copy link
Collaborator

tsalo commented Jun 24, 2024

@mariagiuliat I noticed that your BOLD files do not follow BIDS format. You have run<number> in the filenames instead of run-<number>. Can you try fixing that?

As for the N4BiasFieldCorrection failure, I would recommend trying to follow the debugging steps taken in #3307- specifically @effigies' instructions in #3307 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants