Neuroimaging Software

Fix Neuroimaging Errors Fast with SpinLab’s Error Doctor

Neuroimaging software fails with messages that make sense only once you already know the answer. The SpinLab Error Doctor recognises around 50 common problems from tools such as HeuDiConv, dcm2niix, FSL and FreeSurfer. Paste the error, and it explains the cause and gives the corrected command.

Error Doctor diagnosing a HeuDiConv IsADirectoryError
The pasted error, the cause, the corrected command and a command to confirm the fix. From spinlab.mrispin.com.

Step by step

  1. Open spinlab.mrispin.com and choose Error Doctor.
  2. Paste the full error message, including the last lines of the traceback.
  3. Read the diagnosis: what went wrong and why.
  4. Copy the corrected command, and run the check command it suggests before running the fix on all your data.

Worked example: IsADirectoryError in HeuDiConv

A frequent first error with HeuDiConv is IsADirectoryError. It happens when the -d template points at a folder of folders, so HeuDiConv tries to open a directory as if it were a DICOM file.

# Fails: matches the subject folder itself
heudiconv -d '/data/dicom/{subject}' -s 01 -f heuristic.py -c dcm2niix -b -o /data/bids

# Works: match the files inside each series folder
heudiconv -d '/data/dicom/{subject}/*' -s 01 -f heuristic.py -c dcm2niix -b -o /data/bids

Before running the fix, check what the pattern really matches:

ls -d /data/dicom/01/* | head

If the output lists series folders rather than files, add another /* to the template so it reaches the DICOM files.

Other common errors and their usual causes

Message (shortened)Usual cause
FSLDIR not set / command not foundFSL’s setup script was not sourced in this shell
FreeSurfer license file not foundFS_LICENSE does not point at license.txt
No DICOMs found / empty outputThe path or wildcard does not match the files
Permission deniedOutput folder owned by another user, or a mounted drive is read-only
# FSL environment (adjust the path to your installation)
export FSLDIR=/usr/local/fsl
source $FSLDIR/etc/fslconf/fsl.sh

# FreeSurfer license
export FS_LICENSE=$HOME/license.txt

Good habits

  • Copy the whole error, not just the last line. The first lines often name the file that caused it.
  • Test a fix on one subject before looping over all of them.
  • Keep the command that worked in a script so the problem doesn’t come back.

Related: DICOM to BIDS with Autopilot and the HeuDiConv heuristic explained.

Last reviewed: 7 November 2026. SpinLab and SpinCalc are free tools developed by MRISpin. Screenshots show the tools as they were on this date and may change as the tools are updated. Generated scripts should be checked before use on real data.

MRISpin Team

MRISpin team combines decades of experience in MRI research, clinical practice, and science communication. Meet the people driving MRISpin’s mission.

Related Articles

Back to top button