PennLINC / qsiprep

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

AttributeError: '_Undefined' object has no attribute 'items' #661

Open granitz opened 1 year ago

granitz commented 1 year ago

Hi all,

I've run qsiprep (v 0.19.1) followed by the following command. The program gets stuck at calc_connectivity. qsiprep does not seem to read pipeline.json?

  qsiprep-docker /bids  \
      /bids/derivatives \
      participant \
      --recon-only --recon_spec /bids/files/pipeline.json \
      --recon_input /bids/derivatives/qsiprep \
      --fs-license-file /license.txt \
      --n_cpus 8 --skip_bids_validation -w /bids/derivatives/work

The crash report looks like this. I get the same error with --recon_spec dsi_studio_qgi

    Node: qsirecon_wf.sub-X_dsistudio_pipeline.sub_X_ses_1_space_T1w_desc_preproc_recon_wf.streamline_connectivity.calc_connectivity
    Working directory: /out/work/qsirecon_wf/sub-X_dsistudio_pipeline/sub_X_ses_1_space_T1w_desc_preproc_recon_wf/streamline_connectivity/calc_connectivity

    Node inputs:

    args = <undefined>
    atlas_config = <undefined>
    atlas_configs = <undefined>
    atlas_name = <undefined>
    connectivity = <undefined>
    connectivity_type = pass,end
    connectivity_value = ncount,gfa
    environ = {}
    fa_threshold = <undefined>
    fiber_count = <undefined>
    initial_dir = <undefined>
    input_fib = <undefined>
    interpo_angle = <undefined>
    interpolation = <undefined>
    max_length = <undefined>
    min_length = <undefined>
    num_threads = 3
    random_seed = <undefined>
    seed_count = <undefined>
    seed_file = <undefined>
    seed_plan = <undefined>
    smoothing = <undefined>
    step_size = <undefined>
    thread_count = 1
    to_export = <undefined>
    trk_file = <undefined>
    turning_angle = <undefined>

    Traceback (most recent call last):
      File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
        result["result"] = node.run(updatehash=updatehash)
      File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
        result = self._run_interface(execute=True)
      File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
        return self._run_command(execute)
      File "/usr/local/miniconda/lib/python3.8/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 calc_connectivity.

    Traceback:
    Traceback (most recent call last):
    File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 397, in run
    runtime = self._run_interface(runtime)
    File "/usr/local/miniconda/lib/python3.8/site-packages/qsiprep/interfaces/dsi_studio.py", line 459, in _run_interface
    for atlasnum, (atlas_name, atlas_config) in enumerate(atlas_configs.items(), start=1):
    AttributeError: '_Undefined' object has no attribute 'items'

Appreciate your help!

granitz commented 1 year ago

When I ran QSIprep on ABCD data it created a folder structure: /qsiprep/sub-/ /qsiprep/sub-/anat/ # contains all but one file ending in mode-image_xfm.txt /qsiprep/sub-/ses-/anat/ # contains only the file ending in mode-image_xfm.txt /qsiprep/sub-/ses-/dwi/ /qsiprep/sub-/ses-/figures/

Before running the reconstruction, I moved /qsiprep/sub-/anat/ to /qsiprep/sub-/ses-/anat/ Running qsiprep with --recon-only then resulted in the error above. Restoring the folder structure resolved the issue.

mattcieslak commented 11 months ago

could you post the content of pipeline.json?

keithgjones commented 11 months ago

Hi all,

I'm getting the same error trying to run --recon_spec dsi_studio_gqi. I have no "anat" folder in my qsiprep output, as I'm analyzing phantom data and used --dwi-only for the preprocessing.

Here is the command I'm using (from inside a bash script):

singularity run --cleanenv \ 
--bind ${BIDSINDATA}:/recon_in \ 
--bind ${BIDSOUTDATA}:/recon_out \ 
--bind /home/Software/FreeSurfer/freesurfer-7.3.2/freesurfer:/fs_license \ 
/home/Software/qsiPrepS-0.19.1 \ 
/recon_in \ 
/recon_out \ 
participant \ 
--participant_label ${SUBJECT} \ 
-w /recon_out/work_${SUBJECT} \ 
--fs-license-file /fs_license/license.txt \ 
--recon-only \ 
--recon-spec dsi_studio_gqi \ 
--recon-input /recon_in

And here is the error message:

Node: qsirecon_wf.sub-02_dsistudio_pipeline.sub_02_ses_01_space_T1w_desc_preproc_recon_wf.streamline_connectivity.calc_connectivity
Working directory: /recon_out/work_02/qsirecon_wf/sub-02_dsistudio_pipeline/sub_02_ses_01_space_T1w_desc_preproc_recon_wf/streamline_connectivity/calc_connectivity

Node inputs:

args = <undefined>
atlas_config = <undefined>
atlas_configs = <undefined>
atlas_name = <undefined>
connectivity = <undefined>
connectivity_type = pass,end
connectivity_value = count,ncount,mean_length,gfa
environ = {}
fa_threshold = <undefined>
fiber_count = <undefined>
initial_dir = <undefined>
input_fib = <undefined>
interpo_angle = <undefined>
interpolation = <undefined>
max_length = <undefined>
min_length = <undefined>
num_threads = 8
random_seed = <undefined>
seed_count = <undefined>
seed_file = <undefined>
seed_plan = <undefined>
smoothing = <undefined>
step_size = <undefined>
thread_count = 1
to_export = <undefined>
trk_file = <undefined>
turning_angle = <undefined>

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/usr/local/miniconda/lib/python3.8/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 calc_connectivity.

Traceback:
    Traceback (most recent call last):
      File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 397, in run
        runtime = self._run_interface(runtime)
      File "/usr/local/miniconda/lib/python3.8/site-packages/qsiprep/interfaces/dsi_studio.py", line 459, in _run_interface
        for atlasnum, (atlas_name, atlas_config) in enumerate(atlas_configs.items(), start=1):
    AttributeError: '_Undefined' object has no attribute 'items'

Thanks for the help!

mattcieslak commented 11 months ago

Hi @keithgjones, you won't be able to run that pipeline as-is without anatomical data. The transform from the anatomical data to template space is used to get atlases aligned to the dwis so you can calculate connectivity. You can edit the json file here to exclude the connectivity estimation (you'll also have to change line 4 to "atlases": [],)

granitz commented 11 months ago

Here's the content of pipeline.json:

  {
      "name": "dsistudio_pipeline",
      "space": "T1w",
      "atlases": ["schaefer400", "gordon333"],
      "nodes": [
        {
          "name": "dsistudio_gqi",
          "software": "DSI Studio",
          "action": "reconstruction",
          "input": "qsiprep",
          "output_suffix": "gqi",
          "parameters": {"method": "gqi"}
        },
        {
          "name": "scalar_export",
          "software": "DSI Studio",
          "action": "export",
          "input": "dsistudio_gqi",
          "output_suffix": "gqiscalar"
        },
        {
          "name": "tractography",
          "software": "DSI Studio",
          "action": "tractography",
          "input": "dsistudio_gqi",
          "parameters": {
            "turning_angle": 35,
            "smoothing": 0.0,
            "step_size": 1.0,
            "min_length": 30,
            "max_length": 250,
            "seed_plan": 0,
            "interpolation": 0,
            "initial_dir": 2,
            "fiber_count": 5000000
          }
        },
        {
          "name": "streamline_connectivity",
          "software": "DSI Studio",
          "action": "connectivity",
          "input": "tractography",
          "output_suffix": "gqinetwork",
          "parameters": {
            "connectivity_value": "ncount,gfa",
            "connectivity_type": "pass,end"
          }
        }
      ]
    }