ASLprep --basil doesnt work

Dear all,
I have a little problem using aslprep.

Summary of what happened:

In fact, when I did not perform partial volume correction by --basil, all the aslprep ran smoothly. But after I add --basil, the following error will be reported, causing the program to be unable to continue running. I’m wondering if this is because I don’t have a separate M0 image?

Command used (and if a helper script was used, a link to the helper script or the command generated):


aslprep script, without --basil work well, with 	--basil break

#set env
export SINGULARITYENV_TEMPLATEFLOW_HOME=/ibmgpfs/****_lab/****/package/templateflow
export SINGULARITYENV_WORK_HOME=/ibmgpfs/****_lab/****/.singularity/work
unset PYTHONPATH;
singularity run --cleanenv \
	-B $aslprep_wd:/wd \
	-B $BidsDir:/BIDS \
	-B $aslprep_output:/output \
	-B $templateflow:$templateflow \
	-B $fs_license:/fs_license \
	/ibmgpfs/****_lab/****/.singularity/aslprep-0.5.0.simg \
	/BIDS /output participant \
	--participant_label ${subj} \
	-w /wd \
        --fs-license-file /fs_license/license.txt \
	--output-spaces T1w  MNI152NLin6Asym \
	--notrack --verbose \
	--skip-bids-validation \
	--stop-on-first-crash  \
	--basil



Here is my asl json file:

	"TaskName":"DE",
	"ArterialSpinLabelingType":"PCASL",
	"PostLabelingDelay":1.5,
	"BackgroundSuppression":"false",
	"M0Type":"Absent",
	"TotalAcquiredPairs":135,
	"LabelingDuration":1.5,
	"RepetitionTimePreparation":4.4

Version:

aslprep-0.5.0.simg

Environment (Docker, Singularity / Apptainer, custom installation):

Singularity

Data formatted according to a validatable standard? Please provide the output of the validator:

PASTE VALIDATOR OUTPUT HERE

Relevant log outputs (up to 20 lines):

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py", line 344, in _send_procs_to_workers
    self.procs[jobid].run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 497, in run
    self._get_hashval()
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 548, in _get_hashval
    self._get_inputs()
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 619, in _get_inputs
    self.set_input(key, deepcopy(output_value))
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 312, in set_input
    setattr(self.inputs, parameter, deepcopy(val))
  File "/usr/local/miniconda/lib/python3.8/site-packages/traits/base_trait_handler.py", line 74, in error
    raise TraitError(
traits.trait_errors.TraitError: The 'm0tr' trait of a _BASILCBFInputSpec instance must be a float, but a value of None <class 'NoneType'> was specified.

Error setting node input:
Node: basilcbf
input: m0tr
results_file: /wd/aslprep_wf/single_subject_53_wf/asl_preproc_acq_DE1_wf/compute_cbf_wf/extract_deltam/result_extract_deltam.pklz
value: None


When creating this crashfile, the results file corresponding
to the node could not be found.
240314-21:56:24,694 nipype.workflow CRITICAL:
	 ASLPrep failed: Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py", line 344, in _send_procs_to_workers
    self.procs[jobid].run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 497, in run
    self._get_hashval()
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 548, in _get_hashval
    self._get_inputs()
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 619, in _get_inputs
    self.set_input(key, deepcopy(output_value))
  File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 312, in set_input
    setattr(self.inputs, parameter, deepcopy(val))
  File "/usr/local/miniconda/lib/python3.8/site-packages/traits/base_trait_handler.py", line 74, in error
    raise TraitError(
traits.trait_errors.TraitError: The 'm0tr' trait of a _BASILCBFInputSpec instance must be a float, but a value of None <class 'NoneType'> was specified.

Error setting node input:
Node: basilcbf
input: m0tr
results_file: /wd/aslprep_wf/single_subject_53_wf/asl_preproc_acq_DE1_wf/compute_cbf_wf/extract_deltam/result_extract_deltam.pklz
value: None

Screenshots / relevant information:


Thanks to all

Hi @Zhilin,

I believe I fixed that bug in 0.5.1. Would you mind updating your ASLPrep version (or even better, go up to 0.6.0) and rerunning?

1 Like

Thank you so much @tsalo . Now I’m trying 0.5.1. In fact, I have already tried 0.6.0, but the problems I encountered seemed to be bigger(Because I’ve never seen it before)? So I thought about solving the problems encountered in 0.5.0 first. Since you mentioned 0.6.0, I will list the problems I encountered here.

I can confirm that my working path is clean, and similar scripts work without any problems in 0.5.0.

singularity run --cleanenv \
	-B $aslprep_wd:/wd \
	-B $BidsDir:/BIDS \
	-B $aslprep_output:/output \
	-B $templateflow:$templateflow \
	-B $fs_license:/fs_license \
	-B $fs_dir:/fs_dir \
	/ibmgpfs/******/.singularity/aslprep-0.6.0.simg \
	/BIDS /output participant \
	--participant_label ${subj} \
	--fs-subjects-dir /fs_dir \
	-w /wd \
    --fs-license-file /fs_license/license.txt \
	--output-spaces T1w  MNI152NLin6Asym \
	--notrack --verbose \
	--skip-bids-validation \
	--stop-on-first-crash  


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

Traceback:
	Traceback (most recent call last):
	  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	  File "/usr/local/miniconda/lib/python3.10/site-packages/aslprep/interfaces/cbf.py", line 198, in _run_interface
	    raise ValueError(
	ValueError: Background-suppressed control volumes cannot be used for calibration.


240314-22:13:19,209 nipype.workflow CRITICAL:
	 ASLPrep failed: Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/pipeline/plugins/multiproc.py", line 344, in _send_procs_to_workers
    self.procs[jobid].run(updatehash=updatehash)
  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run
    result = self._run_interface(execute=True)
  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface
    return self._run_command(execute)
  File "/usr/local/miniconda/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 extract_deltam.

Traceback:
	Traceback (most recent call last):
	  File "/usr/local/miniconda/lib/python3.10/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	  File "/usr/local/miniconda/lib/python3.10/site-packages/aslprep/interfaces/cbf.py", line 198, in _run_interface
	    raise ValueError(
	ValueError: Background-suppressed control volumes cannot be used for calibration.


240314-22:13:20,212 cli ERROR:
	 Preprocessing did not finish successfully. Errors occurred while processing data from participants: 53 (1). Check the HTML reports for details.
240314-22:13:45,785 nipype.workflow INFO:
	 [Node] Finished "fast", elapsed time 120.595775s.
240314-22:44:51,336 nipype.workflow INFO:
	 [Node] Finished "registration", elapsed time 1987.662136s.
240314-22:48:53,534 nipype.workflow INFO:
	 [Node] Finished "registration", elapsed time 2229.859325s.
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.10/multiprocessing/util.py", line 300, in _run_finalizers
    finalizer()
  File "/usr/local/miniconda/lib/python3.10/multiprocessing/util.py", line 224, in __call__
    res = self._callback(*self._args, **self._kwargs)
  File "/usr/local/miniconda/lib/python3.10/multiprocessing/util.py", line 133, in _remove_temp_dir
    rmtree(tempdir)
  File "/usr/local/miniconda/lib/python3.10/shutil.py", line 731, in rmtree
    onerror(os.rmdir, path, sys.exc_info())
  File "/usr/local/miniconda/lib/python3.10/shutil.py", line 729, in rmtree
    os.rmdir(path)
OSError: [Errno 39] Directory not empty: '/tmp/pymp-7bon5u2s'

Thanks again! @tsalo

Sorry to bother you again @tsalo , I encountered some problems while using 0.5.1. The first is that I used --basil in 0.5.1, and this parameter worked normally. Thank you very much.
The --basil output does not have a CBF time series, but --scorescrub can generate a denoised CBF time series, so I started trying this option and then reported the following error. (Since the signal-to-noise ratio of my ASL data this time may not be very good, I want to try these denoise algorithms.

This is my script:

(Again, I can be sure that my data is in the correct format and that the working path is clean

singularity run --cleanenv \
	-B $aslprep_wd:/wd \
	-B $BidsDir:/BIDS \
	-B $aslprep_output:/output \
	-B $templateflow:$templateflow \
	-B $fs_license:/fs_license \
	/ibmgpfs/****/.singularity/aslprep-0.5.1.simg \
	/BIDS /output participant \
	--participant_label ${subj} \
	-w /wd \
        --fs-license-file /fs_license/license.txt \
	--output-spaces T1w  MNI152NLin6Asym \
	--notrack --verbose \
	--skip-bids-validation \
	--stop-on-first-crash  \
	--scorescrub

This is the crash file:

Node: aslprep_wf.single_subject_53_wf.asl_preproc_acq_DE1_wf.compute_cbf_wf.score_and_scrub_cbf
Working directory: /wd/aslprep_wf/single_subject_53_wf/asl_preproc_acq_DE1_wf/compute_cbf_wf/score_and_scrub_cbf

Node inputs:

cbf_ts = /wd/aslprep_wf/single_subject_53_wf/asl_preproc_acq_DE1_wf/compute_cbf_wf/compute_cbf/sub-53_acq-DE1_asl_DeltaMOrCBF_cbf.nii
csf_tpm = /wd/aslprep_wf/single_subject_53_wf/asl_preproc_acq_DE1_wf/compute_cbf_wf/csf_tfm/sub-53_T1w_corrected_xform_masked_pve_0_trans.nii.gz
gm_tpm = /wd/aslprep_wf/single_subject_53_wf/asl_preproc_acq_DE1_wf/compute_cbf_wf/gm_tfm/sub-53_T1w_corrected_xform_masked_pve_1_trans.nii.gz
mask = /wd/aslprep_wf/single_subject_53_wf/asl_preproc_acq_DE1_wf/compute_cbf_wf/refine_mask/ref_bold_corrected_brain_mask_maths_refinemask.nii.gz
tpm_threshold = 0.7
wavelet_function = huber
wm_tpm = /wd/aslprep_wf/single_subject_53_wf/asl_preproc_acq_DE1_wf/compute_cbf_wf/wm_tfm/sub-53_T1w_corrected_xform_masked_pve_2_trans.nii.gz

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

Traceback:
	Traceback (most recent call last):
	  File "/usr/local/miniconda/lib/python3.9/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	  File "/usr/local/miniconda/lib/python3.9/site-packages/aslprep/interfaces/cbf.py", line 745, in _run_interface
	    cbfscrub = _scrubcbf(
	  File "/usr/local/miniconda/lib/python3.9/site-packages/aslprep/utils/cbf.py", line 439, in _scrubcbf
	    thresh1, thresh3 = _getchisquare(y.shape[0])
	  File "/usr/local/miniconda/lib/python3.9/site-packages/aslprep/utils/cbf.py", line 273, in _getchisquare
	    return a[n - 1], b[n - 1]
	IndexError: list index out of range


ASLPrep 0.6.0 is probably interpreting the "false" string as True. Can you change "false" to false?

I don’t know what the SCRUB error in 0.5.1 is, but I’d like to hold off on digging into it unless we can reproduce it in 0.6.0.

1 Like

Wow, it works after changing “false” to false. Thanks so much!

1 Like

I tried it in version 0.6.0 and still got this error~
Do I need to set some additional parameters in json or script to run SCRUB?

Thanks for your patience @tsalo

I think I understand the problem.

The SCRUB code has hardcoded chi-square values that only go up to df=100, which limits it to ASL acquisitions with <= 100 control-label pairs. I should be able to swap out the hardcoded values to calls to scipy.stats.chi2, but I need to talk to SCRUB’s original developer to figure out what the specific values are.

Basically, your acquisition is too long for the current SCRUB code.

1 Like