Run this notebook
Purpose¶
Susceptibility-weighted imaging (SWI) is an MRI technique that exploits differences in magnetic susceptibility between tissues to generate contrast. It is particularly useful for visualising venous vasculature, microbleeds, calcifications, and iron deposits in the brain.
This tutorial demonstrates how to:
Download a demo MRI dataset containing magnitude and phase images
Use the CLEAR-SWI Julia package within Neurodesk to compute SWI maps
Generate a minimum intensity projection (mIP) for enhanced vein visualisation
Inspect the results in an image viewer
Citation and Resources¶
Tools used in this workflow¶
- CLEAR-SWI
- Eckstein, K., et al. (2021). Improved susceptibility weighted imaging at ultra-high field using bipolar multi-echo acquisition and optimized image processing: CLEAR-SWI. NeuroImage, 237, 118175. Eckstein et al. (2021)
Educational resources¶
Prerequisites¶
A running Neurodesk environment
Familiarity with basic terminal commands
No additional software installation required — CLEAR-SWI is pre-installed in Neurodesk
Load software tools and download demo data¶
First, we install osfclient to download the demo dataset from the Open Science Framework, then fetch and unzip the BIDS-formatted data. We use the same demo dataset as the Unwrapping tutorial.
To do so, open a Neurodesktop session, launch a terminal and run the following commands.
The terminal in Neurodesktop.
pip install osfclient
cd ~/neurodesktop-storage/
osf -p ru43c fetch -f 01_bids.zip ~/neurodesktop-storage/swi-demo/01_bids.zip
unzip -o ~/neurodesktop-storage/swi-demo/01_bids.zip -d ~/neurodesktop-storage/swi-demo/
The Neurodesktop terminal outputs after running the command.
You may wish to confirm the download was successful. You can locate the files in your neurodesktop-storage folder using the file manager. You will see the swi-demo folder containing a zipped and unzipped 01_bids folder.
The Neurodesktop file manager showing the downloaded data.
Run CLEAR-SWI¶
Write a Julia script that will perform three steps:
Read the magnitude and phase NIfTI files
Compute the SWI volume using
calculateSWIGenerate a minimum intensity projection (mIP) using
createMIP
Using the command
nano ~/neurodesktop-storage/clearswi.jlcreate a file called clearswi.jl with the following contents :
using CLEARSWI
TEs = [20]
nifti_folder = joinpath(homedir(), "neurodesktop-storage/swi-demo/01_bids/sub-170705134431std1312211075243167001/ses-1/anat")
magfile = joinpath(nifti_folder, "sub-170705134431std1312211075243167001_ses-1_run-1_part-mag_T2starw.nii")
phasefile = joinpath(nifti_folder, "sub-170705134431std1312211075243167001_ses-1_run-1_part-phase_T2starw.nii")
println("Loading magnitude and phase data...")
mag = readmag(magfile);
phase = readphase(phasefile);
data = Data(mag, phase, mag.header, TEs);
println("Computing SWI...")
swi = calculateSWI(data);
println("Creating minimum intensity projection...")
mip = createMIP(swi);
outdir = joinpath(homedir(), "neurodesktop-storage/swi-demo")
println("Saving outputs...")
savenii(swi, joinpath(outdir, "swi.nii"); header=mag.header)
savenii(mip, joinpath(outdir, "mip.nii"); header=mag.header)
println("Done! Output saved to ~/neurodesktop-storage/swi-demo/")Save the file using Ctrl+X (confirm by hitting Y followed by Enter).
The Neurodesktop terminal with the Julia script.
Open the CLEAR-SWI tool from the Neurodesk application menu.
Opening CLEAR-SWI in Neurodesktop.
Then run your newly written file from the CLEAR-SWI container terminal:
cd ~/neurodesktop-storage/
julia clearswi.jl
The CLEAR-SWI container terminal after running the script.
Inspect the results¶
Open ITK-SNAP from the Neurodesk Visualisation menu and load the output files:
~/neurodesktop-storage/swi-demo/swi.nii— the susceptibility-weighted image~/neurodesktop-storage/swi-demo/mip.nii— the minimum intensity projection

Summary¶
In this tutorial you:
Downloaded a demo magnitude/phase MRI dataset from the Open Science Framework
Used the CLEAR-SWI Julia package to compute susceptibility-weighted images
Generated a minimum intensity projection for enhanced venous visualisation
Inspected the outputs using ITK-SNAP
- Eckstein, K., Bachrata, B., Hangel, G., Widhalm, G., Enzinger, C., Barth, M., Trattnig, S., & Robinson, S. D. (2021). Improved susceptibility weighted imaging at ultra-high field using bipolar multi-echo acquisition and optimized image processing: CLEAR-SWI. NeuroImage, 237, 118175. 10.1016/j.neuroimage.2021.118175
