-- Load a preset or add steps to generate a script --
heuristic.py, the dcm2niix conversion script, and a BIDS folder structure preview — all in one place.Installing Neuroimaging Tools on Windows
Step-by-step terminal commands for setting up FSL, FreeSurfer, ANTs, AFNI, MRtrix3, dcm2niix and Python packages via WSL 2 (Windows Subsystem for Linux) — the recommended approach for Windows users.
wsl --install wsl --set-default-version 2 # Restart your PC when prompted, then open Ubuntu from Start Menu
After restart, Ubuntu launches automatically and asks you to create a username/password. Then open Ubuntu from the Start Menu for all subsequent steps.
sudo apt update && sudo apt upgrade -y
sudo apt install -y wget curl git unzip python3 python3-pip \
python3-venv build-essential libgl1 libglu1-mesa \
libgomp1 dc bc libxext6 libxt6 libxrender1 \
libquadmath0 tcsh libopenblas-dev
# Download FSL installer
wget https://fsl.fmrib.ox.ac.uk/fsldownloads/fslinstaller.py
# Run installer (will ask for install directory, default: /usr/local/fsl)
python3 fslinstaller.py
# Add to shell config
echo 'export FSLDIR=/usr/local/fsl' >> ~/.bashrc
echo 'source ${FSLDIR}/etc/fslconf/fsl.sh' >> ~/.bashrc
echo 'export PATH=${FSLDIR}/bin:${PATH}' >> ~/.bashrc
source ~/.bashrc
# Verify
bet --help | head -3
# Download FreeSurfer 7.4 (Ubuntu 22.04 build) wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer_ubuntu22-7.4.1_amd64.deb # Install sudo dpkg -i freesurfer_ubuntu22-7.4.1_amd64.deb # Add to shell config echo 'export FREESURFER_HOME=/usr/local/freesurfer/7.4.1' >> ~/.bashrc echo 'source $FREESURFER_HOME/SetUpFreeSurfer.sh' >> ~/.bashrc # Place your license file (download free from MGH website) # Copy license.txt to $FREESURFER_HOME/license.txt source ~/.bashrc recon-all --version
# Install pre-built binaries
wget https://github.com/ANTsX/ANTs/releases/download/v2.5.3/ants-2.5.3-ubuntu-22.04-X64-gcc.zip
unzip ants-2.5.3-ubuntu-22.04-X64-gcc.zip
sudo mv ants-2.5.3 /opt/ants
echo 'export ANTSPATH=/opt/ants/bin' >> ~/.bashrc
echo 'export PATH=${ANTSPATH}:${PATH}' >> ~/.bashrc
source ~/.bashrc
# Verify
antsRegistration --version
sudo apt install -y mrtrix3 # OR install latest from source: sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/MRtrix3/macos-installer/master/install)" mrconvert --version
sudo apt install -y dcm2niix # OR install latest binary: wget https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_lnx.zip unzip dcm2niix_lnx.zip sudo mv dcm2niix /usr/local/bin/ dcm2niix --version
# Create a virtual environment (recommended)
python3 -m venv ~/neuro-env
source ~/neuro-env/bin/activate
# Install core packages
pip install --upgrade pip
pip install nibabel nilearn nipype dipy \
pandas numpy scipy matplotlib \
scikit-learn jupyter
# Add activation to shell
echo 'source ~/neuro-env/bin/activate' >> ~/.bashrc
# Verify
python3 -c "import nibabel, nilearn, nipype, dipy; print('All packages OK')"
# Option A — pip install (lighter, no Docker needed) pip install fmriprep mriqc # Option B — Docker (most reliable, requires Docker Desktop for Windows) # Download Docker Desktop: https://www.docker.com/products/docker-desktop docker pull nipreps/fmriprep:latest docker pull nipreps/mriqc:latest # Verify pip install fmriprep --version mriqc --version
Installing Neuroimaging Tools on Linux
Native installation on Ubuntu 20.04 / 22.04 / 24.04 (recommended) or Debian-based HPC clusters. Commands also apply inside WSL 2 on Windows.
sudo apt update && sudo apt upgrade -y
sudo apt install -y \
wget curl git unzip vim htop \
python3 python3-pip python3-venv python3-dev \
build-essential gfortran liblapack-dev libopenblas-dev \
libgl1-mesa-glx libglu1-mesa libxt6 libxext6 \
libxrender1 libgomp1 dc bc tcsh \
libquadmath0 libgfortran5 \
gcc g++ cmake ninja-build
wget https://fsl.fmrib.ox.ac.uk/fsldownloads/fslinstaller.py
sudo python3 fslinstaller.py -d /usr/local/fsl
# Configure environment
echo 'export FSLDIR=/usr/local/fsl' >> ~/.bashrc
echo '. ${FSLDIR}/etc/fslconf/fsl.sh' >> ~/.bashrc
echo 'export PATH=${FSLDIR}/bin:${PATH}' >> ~/.bashrc
source ~/.bashrc
# Test
flirt -version
bet --help | head -2
# Ubuntu 22.04 wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer_ubuntu22-7.4.1_amd64.deb sudo dpkg -i freesurfer_ubuntu22-7.4.1_amd64.deb sudo apt install -f -y # fix any missing deps echo 'export FREESURFER_HOME=/usr/local/freesurfer/7.4.1' >> ~/.bashrc echo 'source $FREESURFER_HOME/SetUpFreeSurfer.sh' >> ~/.bashrc # Get free license: https://surfer.nmr.mgh.harvard.edu/registration.html # Copy license.txt to $FREESURFER_HOME/license.txt source ~/.bashrc freesurfer --version
# Pre-built binary (fastest)
wget https://github.com/ANTsX/ANTs/releases/download/v2.5.3/ants-2.5.3-ubuntu-22.04-X64-gcc.zip
unzip ants-2.5.3-ubuntu-22.04-X64-gcc.zip
sudo mv ants-2.5.3 /opt/ants
echo 'export ANTSPATH=/opt/ants/bin' >> ~/.bashrc
echo 'export PATH=${ANTSPATH}:${PATH}' >> ~/.bashrc
source ~/.bashrc
# Verify
antsRegistration --version
antsRegistrationSyN.sh --help | head -5
# Official installer curl -O https://afni.nimh.nih.gov/pub/dist/bin/misc/@update.afni.binaries tcsh @update.afni.binaries -package linux_ubuntu_16_64 -do_extras # Or via apt (older version) sudo add-apt-repository ppa:brains/afni sudo apt update && sudo apt install -y afni echo 'export PATH=$HOME/abin:$PATH' >> ~/.bashrc echo 'source /etc/afni/afni_login' >> ~/.bashrc 2>/dev/null || true source ~/.bashrc afni --version
# Option A — apt (Ubuntu 22.04+) sudo apt install -y mrtrix3 # Option B — pip pip install mrtrix3 # Option C — build from source (latest) sudo apt install -y libeigen3-dev zlib1g-dev libfftw3-dev libpng-dev git clone https://github.com/MRtrix3/mrtrix3.git cd mrtrix3 && ./configure && ./build echo 'export PATH=/path/to/mrtrix3/bin:$PATH' >> ~/.bashrc mrconvert --version
sudo apt install -y dcm2niix # HeuDiConv (BIDS converter) pip install heudiconv # BIDS validator (requires Node.js) sudo apt install -y nodejs npm npm install -g bids-validator dcm2niix --version heudiconv --version
python3 -m venv ~/neuro-env
source ~/neuro-env/bin/activate
pip install --upgrade pip setuptools wheel
pip install \
nibabel nilearn nipype dipy \
pandas numpy scipy matplotlib seaborn \
scikit-learn scikit-image \
jupyter jupyterlab ipywidgets \
fmriprep mriqc \
pydeface templateflow
echo 'source ~/neuro-env/bin/activate' >> ~/.bashrc
python3 -c "import nibabel; print('nibabel', nibabel.__version__)"
python3 -c "import nilearn; print('nilearn', nilearn.__version__)"
# GNU Parallel (parallelise subjects locally) sudo apt install -y parallel # Check SLURM is available on your HPC sinfo --version sbatch --version # Singularity (for containerised pipelines) sudo apt install -y singularity-container # Or Apptainer (newer name) sudo add-apt-repository -y ppa:apptainer/ppa sudo apt update && sudo apt install -y apptainer
MRISpin SpinLab is a browser-based scripting and pipeline tool for neuroimaging researchers. It generates real, complete, runnable bash and Python scripts — not templates with placeholders — for the full neuroimaging analysis workflow.
SpinLab is not a processing engine. It does not run MRI analysis itself. It generates the scripts that you run on your own computer, server, or HPC cluster. Think of it as a smart code generator and reference tool.
SUBJ, BIDS_DIR, OUT_DIR)bash spinlab_pipeline.shheuristic.py, dcm2niix.sh, and heudiconv.shheuristic.py in your BIDS code/ folder, run heudiconv.shThe Script Editor is a full-page code editor with syntax-appropriate highlighting, line numbers, and a permanent quick-action bar. It is the destination for snippets loaded from the sidebar, scripts sent from the Pipeline Builder, and your own written code.
The left sidebar contains 30+ snippets grouped by tool. Search works across snippet titles and keyword tags — typing "warp" finds FNIRT and ANTs. Filter pills (FSL, FS, ANTs…) restrict the list to one tool family. Clicking a snippet asks confirmation only if you have written something that differs from the default boilerplate.
for SUBJ in... loop that auto-discovers all sub-* folders. If nothing is selected, appends a loop template.#SBATCH header. Detects if one already exists and skips to avoid duplicating.set -euo pipefail and a trap that reports the exact line number on failure.tee.# for bash/python, // otherwise).Click the Find button or press Ctrl+H. Type your search term — the match count updates live. Use Replace Next to step through occurrences one at a time, or Replace All for a global substitution. Useful for changing paths like /data/bids → /scratch/project across 40 lines.
The Pipeline Builder generates complete, runnable neuroimaging pipeline scripts step by step. Every step produces real code — not placeholders. The generated script appears live on the right and updates instantly as you change parameters.
Steps can be added from the dropdown at the bottom, or loaded via a preset. Click any step card to expand it and edit its parameters. Each parameter has a sensible default but can be overridden — BET fractional threshold, registration DOF, tractogram size, etc. The generated script always reflects the current parameter values.
Steps pass outputs to subsequent inputs automatically via shell variables:
$T1_BRAIN and $T1_MASK$T1_BRAIN, sets $AFF_MAT and $T1_MNI_LIN$AFF_MAT, sets $WARPFIELD$DWI_EDDY$DWI_PREPROC and $DWI_MASK$FS_SUBJ_DIRbash pipeline.sh. Good for testing one subject.sub-* folders and loops. Run as bash pipeline.sh.#SBATCH directives. Submit with sbatch pipeline.sh.The Study Setup Wizard is the fastest way to get a complete, correctly-configured pipeline. Answer 4 questions and click Build — the Pipeline Builder opens pre-loaded with all the right steps and parameters for your specific study type, field strength, and analysis goals.
The wizard applies intelligent defaults based on your choices. Selecting 7T automatically lowers the BET threshold (7T images have different intensity profiles). Choosing "FLIRT only" removes the FNIRT step. Selecting "ANTs" adds the ANTs SyN step instead of FNIRT. All paths are substituted with your entered BIDS/derivatives directories.
The Heuristic Builder generates the three files needed for a complete DICOM-to-BIDS conversion workflow: a HeuDiConv heuristic.py, a dcm2niix.sh batch conversion script, and a heudiconv.sh run script. It also shows you a BIDS Tree preview of what your output structure will look like before you run anything.
{subject} as placeholder (e.g. /data/raw/{subject}/*/*/*.dcm)T1_MPRAGE_1mm). Assign it a BIDS datatype (anat/func/dwi/fmap), suffix (T1w/bold/dwi), and task/run if applicable.dcm2niix -h | head or check the DICOM tag (0008,103E).The Protocol Library contains 9 full, publication-ready neuroimaging protocols — complete scripts following established methods from the literature. Each protocol includes a full script, a Details tab with inputs/outputs/requirements and DOI references, a Pipeline Steps tab showing the data flow, and a Deploy to Pipeline Builder button.
The QC Tracker is a spreadsheet-style quality control table. Each row is a subject, each column is a QC metric. Enter the actual measured values and the cell colours green (pass), amber (warning), or red (fail) automatically based on published thresholds.
The Methods Text button generates a complete paragraph for your paper's Methods section describing your QC procedure, thresholds applied, and excluded subjects with reasons — ready to paste directly into your manuscript.
The Command Hub is a searchable interactive command reference for 37 neuroimaging commands across 9 tool families. It is not a manual — it is a practical quick reference with real working examples and flag explanations.
Type anything in the search box — command names, flag names, or descriptions. Searching "brain" finds BET. Searching "permutation" finds randomise. Use the filter pills to restrict to a single tool. Click any command card to expand it and see: a full description, a key flags table, a real working example with a Copy button, and a link to the official documentation.
FSL (10): bet, flirt, fnirt, feat, randomise, eddy_openmp, fslmaths, fslstats, applywarp, melodic · FreeSurfer (4): recon-all, asegstats2table, aparcstats2table, mri_convert · ANTs (3): antsRegistrationSyN, antsApplyTransforms, N4BiasFieldCorrection · AFNI (2): 3dDeconvolve, afni_proc.py · MRtrix3 (5): mrconvert, dwidenoise, tckgen, tcksift2, tck2connectome · Python (4): nibabel, nilearn maskers, ConnectivityMeasure, DIPY TensorModel · DICOM (3): dcm2niix, heudiconv, bids-validator · BIDS Apps (2): fmriprep, mriqc · HPC (3): sbatch, GNU parallel, Singularity
MNI152NLin2009cAsym:res-2.heuristic.py → place at /data/bids/code/heuristic.pydcm2niix.sh (optional — HeuDiConv calls dcm2niix internally)heudiconv.sh — converts for all subjects and runs bids-validator--dry-run mode first for one subject to check the heuristic is mapping correctly before processing all subjects.No. All SpinLab panels work without signing in. An account lets you save scripts to the database so they persist across browser sessions and devices.
Sign in → write or edit a script in the Script Editor → click Save → enter a name. Your saved scripts appear in the Account panel. Click Load to restore one to the editor at any time.
Registration may be enabled or disabled by the site administrator. If disabled, you will see a message on the Register tab. Contact your site admin to create an account.
No. SpinLab generates scripts. You download the script and run it on your own machine, server, or HPC cluster where FSL, FreeSurfer, etc. are installed.
Yes — all scripts use set -euo pipefail with error trapping by default. They do not delete data, only create new output directories. Always review the script before running on important data.
The tool requires an internet connection to load (fonts, icons from CDN), but once loaded, all panel generation and script building works offline. Saving scripts requires the database connection.
The database may not be configured. Check if a yellow banner appears at the top of the page saying "SpinLab needs to be installed." If so, run the installer at /spinlab/install/. If the tool is already installed, check that api/config.php exists on the server.
Edit the variables at the top of any generated script — SUBJ, BIDS_DIR, OUT_DIR, NTHREADS. In the Pipeline Builder, set these in the Global Config Bar before generating. In the Wizard, enter paths in Step 2.
SpinLab generates scripts tested against FSL 6.0.7, FreeSurfer 7.4.1, ANTs 2.5.3, MRtrix3 3.0.4. Earlier versions will generally work but specific flags may differ. The Install Guides specify exact recommended versions.
/data/bids → /scratch/project/bids across the whole script in one step.Sources & References
All commands, code snippets and documentation in MRISpin SpinLab are derived from the original open-source tools and publications listed below. We acknowledge all authors and respect their licensing terms.
Brain extraction (BET), linear/non-linear registration (FLIRT/FNIRT), GLM analysis (FEAT), ICA (MELODIC), DWI correction (eddy), tractography (FDT), permutation testing (randomise).
Cortical surface reconstruction (recon-all), subcortical segmentation, parcellation statistics (asegstats2table, aparcstats2table), mri_convert.
SyN non-linear registration, cortical thickness (antsCorticalThickness.sh), N4 bias field correction, antsApplyTransforms.
3dDeconvolve GLM, afni_proc.py preprocessing pipeline, align_epi_anat.py, 3dBlurToFWHM, motion censoring.
DWI preprocessing (dwidenoise, dwifslpreproc), CSD fibre orientation distribution, iFOD2 tractography, SIFT2 filtering, structural connectome (tck2connectome).
Reading, writing and manipulating neuroimaging file formats (NIfTI, MGZ, GIFTI, CIFTI). Used in all Python-based neuroimaging scripts.
Statistical learning and machine learning for neuroimaging. First-level GLM, functional connectivity, seed-based correlation, parcellation, plotting.
Workflow engine for building reproducible neuroimaging pipelines. Wraps FSL, FreeSurfer, SPM, ANTs, AFNI interfaces into portable Python workflows.
DTI tensor fitting, FA/MD/RD/AD maps, fibre tracking, noise estimation, gradient table handling.
Fast, reliable DICOM to NIfTI converter with automatic BIDS JSON sidecar generation. By Chris Rorden (University of South Carolina).
Robust, standardised fMRI preprocessing pipeline. Handles fieldmap correction, motion correction, confound extraction, ICA-AROMA, and multi-space outputs.
MRI quality control: computes image quality metrics (IQMs) for T1w and BOLD data, generates visual reports for participant and group levels.
Heuristic-driven DICOM to BIDS conversion tool. Automates session/run labelling via user-defined heuristic Python scripts.
Open-source cluster management and job scheduling. Used for submitting neuroimaging pipelines as job arrays across HPC systems.
Standard for organising neuroimaging datasets. All BIDS-related commands in MRISpin follow the official BIDS specification v1.8+.
MRISpin SpinLab (© 2026 MRISpin) is an independent tool that provides code templates, pipeline builders and reference documentation to assist neuroimaging researchers. It is not affiliated with, endorsed by, or a product of any of the tool developers listed above.
All code snippets are original compositions inspired by official documentation and best-practice examples from the neuroimaging community. They are provided as educational templates under fair-use principles. Users are responsible for citing the appropriate original tools and publications in their research outputs.
If you use any of the above tools in your research, please cite them according to their official citation guidelines.
Helpdesk & Support
Get help with SpinLab, report issues, or contact the MRISpin team. We are happy to assist with setup, scripting questions, and tool feedback.