PennLINC / aslprep

Preprocessing of arterial spin labeling (ASL) data
https://aslprep.readthedocs.io
Other
39 stars 15 forks source link

CBF CIFTI generation failing #459

Closed tsalo closed 1 week ago

tsalo commented 1 week ago

Summary

I am trying to process new ASL data through ASLPrep with CIFTI outputs enabled, but it looks like there's a bug in init_asl_wf where the native-anatomical-resolution T1w is being passed into init_ds_ciftis_wf to be used as the reference for warping CBF images to anatomical space. The resulting T1w-space CBFs have the same resolution as the anatomical image (e.g., 1x1x1), but the goodvoxels mask used for projection is in native ASL resolution (e.g., 3x3x3). This leads to an error when projecting from the volume to the surface.

The solution is to pass the reference image (i.e., an empty 3D image in T1w space and native ASL resolution) from asl_anat_wf to ds_ciftis_wf instead of the high-resolution T1w.

Additional details

What were you trying to do?

apptainer run --cleanenv \
      /cbica/home/salot/apptainer/aslprep_0.7.4.sif \
      /data \
      /deriv/aslprep \
      participant \
      --participant-label 01 \
      -w /work/ \
      -d fmriprep=/deriv/fmriprep \
      --fs-subjects-dir /deriv/fmriprep/sourcedata/freesurfer \
      --output-spaces func T1w MNI152NLin6Asym:res-2 \
      --project-goodvoxels \
      --cifti-output 91k \
      --fs-license-file /license.txt \
      --skip_bids_validation \
      --m0_scale 10 \
      --basil \
      --level full

What did you expect to happen?

CIFTI CBF outputs should be created.

What actually happened?

Node: aslprep_0_7_wf.sub_PF_wf.asl_preproc_ses_techdev_run_01_wf.ds_asl_cifti_wf.cbf_ts_fsLR_resampling_wf.volume_to_surface
Working directory: /work/aslprep_0_7_wf/sub_PF_wf/asl_preproc_ses_techdev_run_01_wf/ds_asl_cifti_wf/cbf_ts_fsLR_resampling_wf/_hemi_R/volume_to_surface

Node inputs:

args = <undefined>
bad_vertices_out = <undefined>
environ = {'OMP_NUM_THREADS': '20'}
gaussian = <undefined>
inner_surface = <undefined>
interpolate = <undefined>
legacy_bug = <undefined>
method = ribbon-constrained
num_threads = 20
out_file = <undefined>
outer_surface = <undefined>
output_weights = <undefined>
output_weights_text = <undefined>
ribbon_roi = <undefined>
sigma = <undefined>
subvol_select = <undefined>
surface_file = <undefined>
thickness = <undefined>
thin_columns = <undefined>
volume_file = <undefined>
volume_roi = <undefined>
voxel_subdiv = <undefined>
weighted = <undefined>

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 volume_to_surface.

Cmdline:
    wb_command -volume-to-surface-mapping /work/aslprep_0_7_wf/sub_PF_wf/asl_preproc_ses_techdev_run_01_wf/ds_asl_cifti_wf/warp_cbf_ts_to_anat/sub-PF_ses-techdev_run-01_asl_DeltaMOrCBF_cbf_trans.nii.gz /deriv/fmriprep/sub-PF/ses-techdev/anat/sub-PF_ses-techdev_hemi-R_midthickness.surf.gii sub-PF_ses-techdev_hemi-R_midthickness.surf_mapped.func.gii -ribbon-constrained /deriv/fmriprep/sub-PF/ses-techdev/anat/sub-PF_ses-techdev_hemi-R_white.surf.gii /deriv/fmriprep/sub-PF/ses-techdev/anat/sub-PF_ses-techdev_hemi-R_pial.surf.gii -volume-roi /work/aslprep_0_7_wf/sub_PF_wf/asl_preproc_ses_techdev_run_01_wf/asl_cifti_resample_wf/goodvoxels_bold_mask_wf/goodvoxels_mask/sub-PF_ses-techdev_run-01_asl_reducedresampled_std_maths_maths_maths_thresh_maths.nii.gz
Stdout:

Stderr:

    While running:
    /opt/workbench/bin_linux64/../exe_linux64/wb_command -volume-to-surface-mapping /work/aslprep_0_7_wf/sub_PF_wf/asl_preproc_ses_techdev_run_01_wf/ds_asl_cifti_wf/warp_cbf_ts_to_anat/sub-PF_ses-techdev_run-01_asl_DeltaMOrCBF_cbf_trans.nii.gz /deriv/fmriprep/sub-PF/ses-techdev/anat/sub-PF_ses-techdev_hemi-R_midthickness.surf.gii sub-PF_ses-techdev_hemi-R_midthickness.surf_mapped.func.gii -ribbon-constrained /deriv/fmriprep/sub-PF/ses-techdev/anat/sub-PF_ses-techdev_hemi-R_white.surf.gii /deriv/fmriprep/sub-PF/ses-techdev/anat/sub-PF_ses-techdev_hemi-R_pial.surf.gii -volume-roi /work/aslprep_0_7_wf/sub_PF_wf/asl_preproc_ses_techdev_run_01_wf/asl_cifti_resample_wf/goodvoxels_bold_mask_wf/goodvoxels_mask/sub-PF_ses-techdev_run-01_asl_reducedresampled_std_maths_maths_maths_thresh_maths.nii.gz

    ERROR: roi volume is not in the same volume space as input volume

Traceback:
    RuntimeError: subprocess exited with code 255.

Reproducing the bug

I think the bug should occur if you have ASL data with a resolution that isn't the same as the anatomical image and you specify --cifti-output and --project-goodvoxels. I think test_003_full is only passing because we don't use --project-goodvoxels.

tsalo commented 1 week ago

This is somewhat similar to #360, but the source of the problem was different.