[Neuroimaging] [nipype] DataGrabber Question to get Directory

David Gutman dagutman at gmail.com
Wed Nov 30 16:57:55 EST 2016


I think I'm probably using the wrong module to do this... but I am trying
to write a simple script to iterate through my raw DICOM data and convert
it into NIFTI.   I had modified some of the old code I had written before,
but in this case I want to match a directory name, not return a file.

Basically I have a list of directories


BaseSubjPath = '/some/where/data/lives'
DirsWithSubjectData  = [Subject1, Subject2, Subject3, Subject4]

For now I am only going to convert the T1 Image,

DCM2NII_wf = pe.Workflow('stoutDCM2NII_wf') ## Initialize the workflow
DCM2NII_wf.base_dir = NiPypeOutputDir  ## Target  to dump the results of
the workflow

SessionId_InfoSrc  =
pe.Node(util.IdentityInterface(fields=['imageSessionName']),name='imageSession_Id_InfoSrc')
SessionId_InfoSrc.iterables = ('imageSessionName', DirsWithSubjectData)

# ## Create a datasource.. this basically helps me find the individual
image files and data sets for an image session
# ## a single image directory likely consists of DTI data, T2 images, T1
images, etc, etc
datasource =
pe.Node(interface=nio.DataGrabber(infields=['imageSessionName'],
outfields=['t1Mprage_dir']), name='datasource')
datasource.inputs.base_directory = StoutRawData
datasource.inputs.template = '%s/t1_mprage_sag_*'
datasource.inputs.sort_filelist = True
datasource.inputs.template_args = dict( t1Mprage_dir=[['imageSessionName']])

### eventually I'll add in templates for the DTI data, Functional data,
etc...



## Now create a node for the dicom converter!
dcmConvert = pe.Node(interface=Dcm2nii(),name='dcmConvert')
dcmConvert.inputs.gzip_output = False
dcmConvert.inputs.reorient = False
dcmConvert.inputs.reorient_and_crop = False


DCM2NII_wf.connect(imageSession_Id_InfoSrc, 'imageSessionName', datasource,
'imageSessionName')
DCM2NII_wf.connect(datasource,'t1Mprage_dir', dcmConvert, 'source_dir' )

DCM2NII_wf.run()

So the work flow as written failed because the datagrabber was/is trying to
return files and not a directory..

As a hack, I just created a list of all the t1 directories and bypassed the
datagrabber node, and connected it directly to the DCM Converter.  However
this isn't particularly elegant, and I'd like to know the Nipyponic method
to achieve this so I can make this clean.


T1ImageInputDirectories =  glob( oj(RawData,'*/t1_mp*'))


With the death of neurostars, I wasn't able to search in the archives in
case this has already been addressed.






-- 
David A Gutman MD PhD
Assistant Professor of Neurology, Psychiatry & Biomedical Informatics
Emory University School of Medicine
Staff Physician, Mental Health Service Line
Atlanta VA Medical Center
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20161130/60913c80/attachment.html>


More information about the Neuroimaging mailing list