HeuDiConv with heuristic.py: Files not recognized

Hi friends,

following issue: I’m following this tutorial to convert .dcm to BIDS: BIDS Tutorial Series: HeuDiConv Walkthrough | Stanford Center for Reproducible Neuroscience. I’m stuck on step 4, where I run HeuDiConv with heuristic.py:

docker run --rm -it -v C:/Users/pazlab/Documents/Max/MRIData/Pilot:/base nipy/heudiconv:latest -d /base/{subject}/*/*/*/*.dcm -o /base/Nifti/ -f /base/Nifti/code/heuristic.py -s "BE796" -c dcm2niix -b --overwrite

Running this, I get the following output:

C:\Users\pazlab>docker run --rm -it -v C:/Users/pazlab/Documents/Max/MRIData/Pilot:/base nipy/heudiconv:latest -d /base/{subject}////.dcm -o /base/Nifti/ -f /base/Nifti/code/heuristic.py -s “BE796” -c dcm2niix -b --overwrite
INFO: Running heudiconv version 0.9.0 latest 0.10.0
INFO: Need to process 1 study sessions
INFO: PROCESSING STARTS: {‘subject’: ‘BE796’, ‘outdir’: ‘/base/Nifti/’, ‘session’: None}
INFO: Processing 2104 dicoms
INFO: Analyzing 2104 dicoms
INFO: Generated sequence info for 14 studies with 2104 entries total
INFO: Doing conversion using dcm2niix
INFO: Lock 140494038703856 acquired on /base/Nifti/heudiconv.lock
INFO: Populating template files under /base/Nifti/
INFO: Lock 140494038703856 released on /base/Nifti/heudiconv.lock
INFO: PROCESSING DONE: {‘subject’: ‘BE796’, ‘outdir’: ‘/base/Nifti/’, ‘session’: None}

And in my Nifti folder, I get no .json outputs except my participants .json.

It looks like it’s not recognizing the identifiers I give in my dicominfo.tsv file but I’m not sure why, or at least for some other reason it seems like it doesn"t manage to read the files.

Here’s my code:

I’ve tried lots of different things, among them:

  1. Changed the file identifier (as you can see in the bracketed out part)
  2. Playing around with syntax (i.e. different backslashes etc., as you can see on top of the picture)

Not sure exactly what the issue is. Any leads welcome!



You can run with env var setting HEUDICONV_LOG_LEVEL=DEBUG to get more logging info – may be something would be useful. But I also noticed that you use windows paths (\) separator within your heuristic while running via docker so it would be “Linux” (/) inside. Try changing those and see if helps

Hi :slight_smile: Thanks for your reply! Tried playing around with the paths separators but it doesn’t seem to be the issue. I’ve been searching the heudiconv documentation on how to use the HEUDICONV_LOG_LEVEL=DEBUG setting, but don’t exactly understand how to use it - could you provide an example?


try to add -e HEUDICONV_LOG_LEVEL=DEBUG after docker run – it would pass it into the session

note also that you better first remove .heudiconv\THATSUBJ directory before rerunning heudiconv, since it would reuse previously discovered/created mapping on rerun.


finally solved the issues following a few steps:

  1. The “seqinfo” loop didn’t properly go through the different identifiers; I know use for idx, s in enumerate(seqinfo):
    → This basically solved the issue of the files not being recognized.
    This is the script for the T1 file (as you can see I also used different identifiers in my if-statements, but that wasn’t the deciding factor):

  1. After that, there was the issue that only one of the specified keys was being processed (i.e. only scan1, or only t1w, etc.).
    To solve this, I had to change my docker command such that docker run --rm -it -v C:/Users/pazlab/Documents/Max/MRIData/Pilot:/base nipy/heudiconv:latest -d /base/{subject}/*/*/*/*.dcm -o /base/Nifti/ -f /base/Nifti/code/heuristic.py -s BE796 -c dcm2niix -b --overwrite --minmeta, i.e. adding -minmeta do my command.
    This solved the issue.

Big thank you to Peer Herholz for debugging the script with me!