ASLprep#

Author: Steffen Bollmann

Date: 17 Oct 2024

Citation and Resources#

Tools included in this workflow#

ASLPrep:

  • Adebimpe, A., Bertolero, M., Dolui, S. et al. ASLPrep: a platform for processing of arterial spin labeled MRI and quantification of regional brain perfusion. Nat Methods 19, 683–686 (2022). https://doi.org/10.1038/s41592-022-01458-7

FreeSurfer:

Dataset#

Opensource Data from OpenNeuro:

  • Alvaro Galiano and Reyes Garcia de Eulate and Marta Vidorreta and Miriam Recio and Mario Riverol and José L. Zubieta and Maria A. Fernandez-Seara PhD (2021). Resting State Perfusion in Healthy Aging. OpenNeuro Dataset ds000240.doi: 10.18112/openneuro.ds000240.v2.0.0

Run aslprep#

# load fmriprep
import module
import os
await module.load('aslprep/0.7.2')
await module.list()
Lmod Warning: MODULEPATH is undefined.



Lmod has detected the following error: The following module(s) are unknown:
"aslprep/0.7.2"

Please check the spelling or version number. Also try "module spider ..."
It is also possible your cache file is out-of-date; it may help to try:
  $ module --ignore_cache load "aslprep/0.7.2"

Also make sure that all modulefiles written in TCL start with the string
#%Module
[]
# Request a freesurfer license and store it in your homedirectory. This is just an example - please replace with your license id:
!echo "Steffen.Bollmann@cai.uq.edu.au" > ~/.license
!echo "21029" >> ~/.license
!echo "*Cqyn12sqTCxo" >> ~/.license
!echo "FSxgcvGkNR59Y" >> ~/.license
# download data using datalad
!datalad install https://github.com/OpenNeuroDatasets/ds000240.git
!cd ds000240 && datalad get sub-01
It is highly recommended to configure Git before using DataLad. Set both 'user.name' and 'user.email' configuration variables.
Cloning:   0%|                             | 0.00/2.00 [00:00<?, ? candidates/s]

Enumerating: 0.00 Objects [00:00, ? Objects/s]
                                              

Counting:   0%|                              | 0.00/1.20k [00:00<?, ? Objects/s]
                                                                                
Compressing:   0%|                             | 0.00/883 [00:00<?, ? Objects/s]
                                                                                
Receiving:   0%|                             | 0.00/2.39k [00:00<?, ? Objects/s]

                                                                                
Resolving:   0%|                                | 0.00/256 [00:00<?, ? Deltas/s]
                                                                                
[INFO   ] Remote origin not usable by git-annex; setting annex-ignore 
[INFO   ] https://github.com/OpenNeuroDatasets/ds000240.git/config download failed: Not Found
[INFO   ] Author identity unknown
| 
| *** Please tell me who you are.
| 
| Run
| 
|   git config --global user.email "you@example.com"
|   git config --global user.name "Your Name"
| 
| to set your account's default identity.
| Omit --global to set the identity only in this repository.
| 
| fatal: unable to auto-detect email address (got 'root@42bb7b306dba.(none)') 
[INFO   ] git-annex: user error (git ["--git-dir=.git","--work-tree=.","--literal-pathspecs","-c","annex.dotfiles=true","commit-tree","1521aaeeb82a009ff35a2f1316e9ba572124784e","--no-gpg-sign","-p","refs/heads/git-annex"] exited 128)
install(error): /tmp/tmp6lmsgulv/ds000240 (dataset) [CommandError: 'git -c diff.ignoreSubmodules=none -c core.quotepath=false annex init -c annex.dotfiles=true' failed with exitcode 1 under /tmp/tmp6lmsgulv/ds000240] [CommandError: 'git -c diff.ignoreSubmodules=none -c core.quotepath=false annex init -c annex.dotfiles=true' failed with exitcode 1 under /tmp/tmp6lmsgulv/ds000240]

/bin/bash: line 1: cd: ds000240: No such file or directory
%%bash
# aslprep data/bids_root/ out/ participant -w work/
aslprep ds000240 \
   aslprep-output \
   participant \
   --participant-label 01 \
   --fs-license-file ~/.license \
   -w aslprep-work
bash: line 2: aslprep: command not found
---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
Cell In[4], line 1
----> 1 get_ipython().run_cell_magic('bash', '', '# aslprep data/bids_root/ out/ participant -w work/\naslprep ds000240 \\\n   aslprep-output \\\n   participant \\\n   --participant-label 01 \\\n   --fs-license-file ~/.license \\\n   -w aslprep-work\n')

File /opt/conda/lib/python3.13/site-packages/IPython/core/interactiveshell.py:2565, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
   2563 with self.builtin_trap:
   2564     args = (magic_arg_s, cell)
-> 2565     result = fn(*args, **kwargs)
   2567 # The code below prevents the output from being displayed
   2568 # when using magics with decorator @output_can_be_silenced
   2569 # when the last Python token in the expression is a ';'.
   2570 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File /opt/conda/lib/python3.13/site-packages/IPython/core/magics/script.py:160, in ScriptMagics._make_script_magic.<locals>.named_script_magic(line, cell)
    158 else:
    159     line = script
--> 160 return self.shebang(line, cell)

File /opt/conda/lib/python3.13/site-packages/IPython/core/magics/script.py:348, in ScriptMagics.shebang(self, line, cell)
    343 if args.raise_error and p.returncode != 0:
    344     # If we get here and p.returncode is still None, we must have
    345     # killed it but not yet seen its return code. We don't wait for it,
    346     # in case it's stuck in uninterruptible sleep. -9 = SIGKILL
    347     rc = p.returncode or -9
--> 348     raise CalledProcessError(rc, cell)

CalledProcessError: Command 'b'# aslprep data/bids_root/ out/ participant -w work/\naslprep ds000240 \\\n   aslprep-output \\\n   participant \\\n   --participant-label 01 \\\n   --fs-license-file ~/.license \\\n   -w aslprep-work\n'' returned non-zero exit status 127.

aslprep Results#

The full result report is in aslprep-output/sub-01.html and you can open this webpage in Jupyterlab or in the browser. Here a few items from the report as an example and for a quick checking:

Brain mask and brain tissue segmentation of the T1w#

This panel shows the template T1-weighted image (if several T1w images were found), with contours delineating the detected brain mask and brain tissue segmentations.

from IPython.core.display import SVG
SVG(filename='aslprep-output/sub-01/figures/sub-01_dseg.svg')
_images/20c27e221843832793141f90d2fc4d0f1cf449e1763ec51ada4b0e464f943938.svg

Spatial normalization of the anatomical T1w reference#

Results of nonlinear alignment of the T1w reference one or more template space(s)

from IPython.core.display import SVG
SVG(filename='aslprep-output/sub-01/figures/sub-01_space-MNI152NLin2009cAsym_T1w.svg')
_images/cab387e03a51a9835bb77dabde4c54213bc15afcaf18bd79231a4c713ef2f90d.svg

Surface reconstruction#

Surfaces (white and pial) reconstructed with FreeSurfer (recon-all) overlaid on the participant’s T1w template.

from IPython.core.display import SVG
SVG(filename='aslprep-output/sub-01/figures/sub-01_desc-reconall_T1w.svg')
_images/3e4844499ac317fa1c9f3e9a35081ddb5b8fcf22b38f6bf4406c338387b41228.svg

Alignment of functional and anatomical MRI data (volume based)#

mri_coreg (FreeSurfer) was used to generate transformations from EPI space to T1 Space - bbregister refinement rejected. Note that Nearest Neighbor interpolation is used in the reportlets in order to highlight potential spin-history and other artifacts, whereas final images are resampled using Lanczos interpolation.

from IPython.core.display import SVG
SVG(filename='aslprep-output/sub-01/figures/sub-01_desc-coreg_asl.svg')
_images/c7a3ef531b55d63616ff5f8a4b125a2cd864e92ec1e7f66b6d63d32daa753e5d.svg

ASL Summary#

Summary statistics are plotted, which may reveal trends or artifacts in the ASL data. DVARS and FD show the standardized DVARS and framewise-displacement measures for each time point. A carpet plot shows the time series for all voxels within the brain mask. Voxels are grouped into cortical (blue), and subcortical (orange) gray matter, cerebellum (green) and white matter and CSF (red), indicated by the color map on the left-hand side.

from IPython.core.display import SVG
SVG(filename='aslprep-output/sub-01/figures/sub-01_desc-carpetplot_asl.svg')
_images/42b96d368a12fb8f4468a7789006cee75dbe519a18a31cd836ba4486298166cc.svg

CBF#

The maps plot cerebral blood flow (CBF) for basic CBF. The unit is mL/100 g/min.

from IPython.core.display import SVG
SVG(filename='aslprep-output/sub-01/figures/sub-01_desc-cbf_cbf.svg')
_images/38845cb058b591c72db9840722ea25ccce66b134718a315360e28da8fce04e9b.svg

Dependencies in Jupyter/Python#

  • Using the package watermark to document system environment and software versions used in this notebook

%load_ext watermark

%watermark
%watermark --iversions
Last updated: 2025-11-05T01:33:38.158844+00:00

Python implementation: CPython
Python version       : 3.11.6
IPython version      : 8.16.1

Compiler    : GCC 12.3.0
OS          : Linux
Release     : 5.4.0-204-generic
Machine     : x86_64
Processor   : x86_64
CPU cores   : 32
Architecture: 64bit

IPython: 8.16.1