"""
Import modules
"""
import os # system functions
import nipype.interfaces.freesurfer as fs # freesurfer
import nipype.interfaces.dcm2nii as d2n # dicom2nii
import nipype.interfaces.utility as util # utility
import nipype.pipeline.engine as pe # pypeline engine
"""
Define experiment specific parameters
"""
#Specification of the folder where the dicom-files are located at
tmp_dir = '/data/scanautomator/tmp/'
#Output base dir
outputBase_dir = '/data/scanautomator/tmp/'
#Subject Name for output directory
subject_name = 'recon'
#Folder name for input directory
folder_name = '576a5eb9-a0aa-4716-ae32-db6ebf86dcbe___20140117_131433/20140117_131433'
#Specification of a list containing each scan
folder_list = ['3__3D_T2_SPACE_Sag']
#Specification of the name of the dicom and output folder
dicom_dir_name = 'dicom' #if the path to the dicoms is: '~SOMEPATH/experiment/dicom'
data_dir_name = 'data' #if the path to the data should be: '~SOMEPATH/experiment/data'
"""
Define nodes to use
"""
#Node: Infosource - we use IdentityInterface to create our own node, to specify
# the list of subjects the pipeline should be executed on
infosource = pe.Node(interface=util.IdentityInterface(fields=['folder_id']),
name="infosource")
infosource.iterables = ('folder_id', folder_list)
#Node: DICOMConvert - converts the .dcm files into .nii and moves them into
# the folder "data" with a subject specific subfolder
dicom2nifti = pe.Node(interface=d2n.Dcm2nii(), name="dicom2nifti")
dicom2nifti.terminal_output = 'file'
# dicom2nifti.inputs.base_output_dir = outputBase_dir + '/' + subject_name
# #This will store the output to '~SOMEPATH/experiment/data'
# dicom2nifti.inputs.file_mapping = [('nifti','*.nii'),('info','dicom.txt'),('dti','*dti.bv*')]
# dicom2nifti.inputs.out_type = 'nii'
# dicom2nifti.inputs.subject_dir_template = '%s'
#Node ParseDICOMDIR - for creating a nicer nifti overview textfile
dcminfo = pe.Node(interface=fs.ParseDICOMDir(), name="dcminfo")
dcminfo.inputs.sortbyrun = True
dcminfo.inputs.summarize = True
dcminfo.inputs.dicom_info_file = 'nifti_overview.txt'
"""
Define pipeline
"""
#Initiation of the preparation pipeline
prepareflow = pe.Workflow(name="prepareflow")
#Define where the workingdir of the all_consuming_workflow should be stored at
prepareflow.base_dir = tmp_dir + '/workingdir_prepareflow'
"""
Specify node connections
"""
#Define pathfinder function
def pathfinder(scan, subject):
import os
tmp_dir = '/data/scanautomator/tmp/'
print os.path.join(tmp_dir, subject, scan)
return os.path.join(tmp_dir, subject, scan)
#Connect all components
prepareflow.connect([(infosource, dicom2nifti,[(('folder_id', pathfinder, folder_name),
'source_names')]),
(infosource, dcminfo,[(('folder_id', pathfinder, folder_name),
'dicom_dir')]),
])
"""
Run pipeline and create graph
"""
prepareflow.run(plugin='MultiProc', plugin_args={'n_procs' : 2})
prepareflow.write_graph(graph2use='flat')
traits.trait_errors.TraitError: Each element of the 'source_names' trait of a Dcm2niiInputSpec instance must be an existing file name, but a value of '/data/scanautomator/tmp/576a5eb9-a0aa-4716-ae32-db6ebf86dcbe___20140117_131433/20140117_131433/3__3D_T2_SPACE_Sag' <type 'str'> was specified.
--
---
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.
1a. Yeah, I just checked with cd /data/scanautomator/tmp/576a5eb9-a0aa-4716-ae32-db6ebf86dcbe___20140117_131433/20140117_131433/3__3D_T2_SPACE_Sag and it goes to the right directory.
Ah okay. Thanks for the help.
What features does your script have?
What features does your script have?
What script exactly are you referring to here? Is this one of the nipype example
scripts?On Fri, Jan 31, 2014 at 12:45 PM, Satrajit Ghosh <sa...@mit.edu> wrote:
What features does your script have?
- it allows customizable directory layouts and naming schemes through heuristic file- it only converts the necessary dicoms, not everything in a directory- you can keep links to dicom files in the participant layout- it's faster than parsesdicomdir or mri_convert if you use dcm2nii option- it embeds all the dicom metadata inside the nifti header using dcmstack- it tracks the provenance of the conversion from dicom to nifti in w3c prov format- the example shows a conversion to openfmri layout structure- soon you'll be able to add more tags to the metadata representation of the files- and push the metadata to a provenance store