PennLINC / qsiprep

Preprocessing of diffusion MRI
http://qsiprep.readthedocs.io
BSD 3-Clause "New" or "Revised" License
139 stars 56 forks source link

Error with output-space template #97

Closed eds-slim closed 4 years ago

eds-slim commented 4 years ago

Running qsiprep v0.7.1 with --output-space template results in the error

QSIPrep failed: Does not support two inline functions in series ('def _get_first(lll):
    return lll[0]
'  and 'def _aslist(in_value):
    if isinstance(in_value, list):
        return in_value
    return [in_value]
'), found when connecting qsiprep_wf.single_subject_12528110012001019532537329278425520171212202032940_wf.dwi_preproc_acq_DFC_run_01_wf.b0_anat_coreg.b0_to_anat to qsiprep_wf.single_subject_12528110012001019532537329278425520171212202032940_wf.dwi_finalize_acq_DFC_run_01_wf.transform_dwis_mni.mask_merge_tfms. Please use a Function node.
Traceback (most recent call last):
  File "/usr/local/miniconda/bin/qsiprep", line 8, in <module>
    sys.exit(main())
  File "/usr/local/miniconda/lib/python3.7/site-packages/qsiprep/cli/run.py", line 566, in main
    qsiprep_wf.run(**plugin_settings)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/workflows.py", line 589, in run
    execgraph = generate_expanded_graph(deepcopy(flatgraph))
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/utils.py", line 1001, in generate_expanded_graph
    graph_in = _remove_nonjoin_identity_nodes(graph_in, keep_iterables=True)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/utils.py", line 879, in _remove_nonjoin_identity_nodes
    _remove_identity_node(graph, node)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/utils.py", line 905, in _remove_identity_node
    portinputs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/nipype/pipeline/engine/utils.py", line 963, in _propagate_internal_output
    destnode))
ValueError: Does not support two inline functions in series ('def _get_first(lll):
    return lll[0]
'  and 'def _aslist(in_value):
    if isinstance(in_value, list):
        return in_value
    return [in_value]
'), found when connecting qsiprep_wf.single_subject_12528110012001019532537329278425520171212202032940_wf.dwi_preproc_acq_DFC_run_01_wf.b0_anat_coreg.b0_to_anat to qsiprep_wf.single_subject_12528110012001019532537329278425520171212202032940_wf.dwi_finalize_acq_DFC_run_01_wf.transform_dwis_mni.mask_merge_tfms. Please use a Function node.

No further log or crash files are generated.

The problem does not occur with --output-space T1w.

I have identified the offending code in qsiprep/workflows/dwi/resampling.py, but don't see anything obviously wrong with it.

Thanks for pointers to what might cause this error.

mattcieslak commented 4 years ago

I was thinking about removing template from output-spaces for the preprocessing workflows. Since the registration is done using only the T1w images, the alignment in white matter is not great. I would recommend using reconstructed outputs (like FODs or QSDR) for normalizing to a template. That way the diffusion data is used in registration and you get much better registration in white matter. What do you think?

eds-slim commented 4 years ago

I think that's reasonable. I ran into the issue when trying to use the fieldmap-less susceptibility-distortion estimation (--use-syn-sdc), which requires, at last according to the docs, that template be passed to --output-space. I haven't really dived into the syn-sdc workflow in any depth, but it does seem to rely on an average fieldmap atlas in MNI space. So even if high-fidelity registration to standard space is better done at a later stage, using reconstructed outputs, crudely normalising to a template early on might be necessary for using fieldmapless SDC?

mattcieslak commented 4 years ago

Right, there is a displacements prior that is used to constrain the fieldmapless distortion correction. This is a problem in my documentation. You can get the to-mni normalization done via --force-spatial-normalization or --force-syn. The T1-based normalization can still be useful for things like mapping atlases from MNI space to T1w space for connectivity analysis, so I typically run everything with --force-spatial-normalization. Maybe it would be best to remove the --use-syn-sdc option because it's mostly just confusing.

eds-slim commented 4 years ago

Ok, cool!. Thanks!

ghost commented 2 years ago

Hi, I am having a similar problem.

The --force-spatial-normalization seems to be not available anymore (qsiprep version 0.16.1), and the only way to make the syn-sdc work seems to pass also the --force-syn option.

My objective would be to generate a qsiprep call that uses fieldmaps for distortion correction if present and attempts fieldmap-less distortion correction if not (for example, this is what happens in fmriprep with the --use-syn-sdc option).

Right now, by using the --force-syn option to get the syn-sdc to work, the fieldmap-less correction will be forced on the top of the fiedmal-based correction (which I don't want).

Thanks in advance for your help! Giuseppe