dcm2nii recursively

220 views
Skip to first unread message

Michaël Bernier

unread,
Sep 20, 2013, 8:31:59 PM9/20/13
to nipy...@googlegroups.com
Hello folks,

I'm new to nipype, so my question might be basic..

I want to use the dcm2nii interface from nipype, but it only takes a single file in parameter. I tried to feed it a path to a folder and specify the "-r y" tag in the "arg" parameter, but it doesn't work.

So is it possible to use dcm2nii recursively, as I used to do it outside nipype, or it is not supported?

Thank you in advance for the help!

Satrajit Ghosh

unread,
Sep 20, 2013, 8:47:08 PM9/20/13
to nipy-user
hi michael,

you'll need to give it all the files that you would like to convert.

try the following:

from glob import glob

filenames = glob('/path/to/dcmdir/*.dcm') # assuming your file end with dcm

dcm.inputs.source_names = filenames

cheers,

satra


--

---
You received this message because you are subscribed to the Google Groups "NiPy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nipy-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Michaël Bernier

unread,
Sep 20, 2013, 9:49:06 PM9/20/13
to nipy...@googlegroups.com
Thanks for the reply. However, all my files are in different subfolders and have no extension (old Siemens dicom). I will try tomorrow to get all the files recursively using grop or whatever, but I hoped for a simpler solution :P

Ben

unread,
Sep 22, 2013, 9:57:43 PM9/22/13
to nipy...@googlegroups.com
Hey there - I solved this by writing an interface that consolidates all of my dicoms into one folder using hard links. Then I can just hand dcm2nii one of those files, and it takes care of everything in that directory.


You're free to use that code all you like.

Fred Loney

unread,
Sep 24, 2013, 8:24:08 PM9/24/13
to nipy...@googlegroups.com
I find the Siemens DICOM file structure bothersome enough that I wrote the lndicom.py script to create links to the DICOM files in a single directory. The link file names are cleaned up to remove spaces and add a .dcm extension.

Alternatively, you can wrap the script's dicom_files method in a Nipype Function node.

This script requires that you install the pydicom Python package, which you need anyway to do anything with DICOM.

Fred
Reply all
Reply to author
Forward
0 new messages