Aslprep key error

Summary

Hello, the issue I am having is the below pasted error I have encountered for a single subject. I have tried rerunning and adjusting permissions, but only this subject fails, the other 8 ran without errors. Has anyone encountered this keyerror and can provide any info on what’s going on?

Much appreciated,
Caleb

Version:

ASLPrep 0.7.2

Singularity container

Error

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

Traceback:
	Traceback (most recent call last):
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/aslprep/interfaces/plotting.py", line 164, in _run_interface
	    ).plot()
	      ^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/aslprep/utils/plotting.py", line 47, in plot
	    statfile = plot_stat_map(
	               ^^^^^^^^^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/aslprep/utils/plotting.py", line 99, in plot_stat_map
	    svg = extract_svg(display, compress=compress)
	          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/niworkflows/viz/utils.py", line 140, in extract_svg
	    image_svg = svg2str(display_object, dpi)
	                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/niworkflows/viz/utils.py", line 132, in svg2str
	    display_object.frame_axes.figure.savefig(
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/matplotlib/figure.py", line 3390, in savefig
	    self.canvas.print_figure(fname, **kwargs)
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/matplotlib/backend_bases.py", line 2193, in print_figure
	    result = print_method(
	             ^^^^^^^^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/matplotlib/backend_bases.py", line 2043, in 
	    print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
	                                                                 ^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/matplotlib/backends/backend_svg.py", line 1339, in print_svg
	    self.figure.draw(renderer)
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/matplotlib/artist.py", line 95, in draw_wrapper
	    result = draw(artist, renderer, *args, **kwargs)
	             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
	    return draw(artist, renderer)
	           ^^^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/matplotlib/figure.py", line 3143, in draw
	    artists = self._get_draw_artists(renderer)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/matplotlib/figure.py", line 231, in _get_draw_artists
	    ax.apply_aspect(locator(ax, renderer) if locator else None)
	                    ^^^^^^^^^^^^^^^^^^^^^
	  File "/opt/conda/envs/aslprep/lib/python3.11/site-packages/nilearn/plotting/displays/_slicers.py", line 1572, in _locator
	    [[left_dict[axes], y0], [left_dict[axes] + width_dict[axes], y1]]
	      ~~~~~~~~~^^^^^^
	KeyError:

Hi @CalH,

Please re-add in parts of the support post template you deleted (e.g., your command and BIDS validation report). Also, the tree structure of this subject’s data folder could help. Have you tried running the subject with a fresh working directory? It looks like the error message is cut off early, what is key that is incorrect?

Best,
Steven

Hi Steven,

Thanks for your quick reply.

Apologies, let me add what I left out.

BIDS Validator

3 warnings but seem consistent with subjects who successfully completed:

bids-validator@1.14.5
(node:9871) Warning: Closing directory handle on garbage collection
(Use `node --trace-warnings ...` to show where the warning was created)
	1: [WARN] It is recommended to define 'VascularCrushing' for this file. 'VascularCrushing' is a boolean value indicating if an ASL crusher method is used. (code: 137 - VASCULAR_CRUSHING_MUST_DEFINE)
		./sub-P00004874/ses-S0022/perf/sub-P00004874_ses-S0022_asl.nii.gz

	Please visit https://neurostars.org/search?q=VASCULAR_CRUSHING_MUST_DEFINE for existing conversations about this issue.

	2: [WARN] It is recommended to define 'AcquisitionVoxelSize' for this file. 'AcquisitionVoxelSize' is an array of numbers with a length of 3, in millimeters. This parameter denotes the original acquisition voxel size, excluding any inter-slice gaps and before any interpolation or resampling within reconstruction or image processing. Any point spread function effects (e.g. due to T2-blurring) that would decrease the effective resolution are not considered here. (code: 143 - ACQUISITION_VOXELSIZE_MISSING)
		./sub-P00004874/ses-S0022/perf/sub-P00004874_ses-S0022_asl.nii.gz

	Please visit https://neurostars.org/search?q=ACQUISITION_VOXELSIZE_MISSING for existing conversations about this issue.

	3: [WARN] The recommended file /README is very small. Please consider expanding it with additional information about the dataset. (code: 213 - README_FILE_SMALL)
		./README

	Please visit https://neurostars.org/search?q=README_FILE_SMALL for existing conversations about this issue.

Singularity command:


singularity run --cleanenv \
  -B /mnt/mfs/cndgrid/data2/studies/CR_RANN_bids/bids/:/bids, \
  -B "$aslprep_output":/output/aslprep, \
  -B "$freesurfer_output":/output/freesurfer, \
  -B /mnt/mfs/cluster/bin/FREESURFER/license.txt:/opt/freesurfer/license.txt \
  /mnt/mfs/cndgrid/data2/studies/CR_RANN_bids/code/aslprep-0.7.2.simg /bids /output/aslprep participant \
  --fs-subjects-dir /output/freesurfer \
  --participant-label "$participant_label" \
  --fs-no-reconall

Folder Structure:

sub-P00004874/
└── ses-S0022
    ├── anat
    │   ├── sub-P00004874_ses-S0022_T1w.json
    │   └── sub-P00004874_ses-S0022_T1w.nii.gz
    └── perf
        ├── sub-P00004874_ses-S0022_aslcontext.tsv
        ├── sub-P00004874_ses-S0022_asl.json
        └── sub-P00004874_ses-S0022_asl.nii.gz

Error

I copied the error exactly as it is in the html, I checked the log and looks like it just escaped the angled bracket:

	KeyError: <Axes: >

There’s a Nilearn bug that only occurs randomly that looks pretty similar (see plotting crash in single axis mode but not ortho · Issue #1070 · nilearn/nilearn · GitHub). Can you try rerunning that subject to see if the error goes away?

Thanks @tsalo, got it twice in a row before I posted and rerunning again now- maybe 3rd times the charm?

That’s unfortunate. I doubt running it again will fix the problem. I might need to make the code more flexible. Any chance you could dig through your working directory to find the cbf and ref_vol files that the interface is trying to use? If so, would you mind sending them to me? I wonder if there’s something in the data that plot_stat_map’s having trouble with.

Yes, happy to-- what’s the best way to send you? Also ran 2 more times just to make sure the error is reproducible.

ref

mean cbf

It looks like your email was quarantined on my end, unfortunately. Can you try uploading the files to Drive or Box and sending me the link?

I wasn’t able to reproduce the error locally, but I did notice that the distribution of CBF values is wild. All of the CBF values are negative and extreme.

Thanks for taking a look- I’ll have to verify my setup was correct because that is pretty troubling.