@@ -38,10 +38,15 @@ class NiftiGeneratorBaseInputSpec(TraitedSpec):
38
38
desc = "Determines output file type" )
39
39
40
40
class NiftiGeneratorBase (BaseInterface ):
41
+ '''Base class for interfaces that produce Nifti files, potentially with
42
+ embeded meta data.'''
41
43
def _get_out_path (self , meta ):
44
+ '''Return the output path for the gernerated Nifti.'''
42
45
if self .inputs .out_format :
43
46
out_fmt = self .inputs .out_format
44
47
else :
48
+ #If no out_format is specified, use a sane default that will work
49
+ #with the provided meta data.
45
50
out_fmt = []
46
51
if 'SeriesNumber' in meta :
47
52
out_fmt .append ('%(SeriesNumber)03d' )
@@ -71,7 +76,19 @@ class DcmStackOutputSpec(TraitedSpec):
71
76
out_file = traits .File (exists = True )
72
77
73
78
class DcmStack (NiftiGeneratorBase ):
74
- '''Create one Nifti file from a set of DICOM files'''
79
+ '''Create one Nifti file from a set of DICOM files. Can optionally embed
80
+ meta data.
81
+
82
+ Example
83
+ -------
84
+
85
+ >>> from nipype.interfaces.dcmstack import DcmStack
86
+ >>> stacker = DcmStack()
87
+ >>> stacker.inputs.dicom_files = 'path/to/series/'
88
+ >>> stacker.run()
89
+ >>> result.outputs.out_file
90
+ 'sequence.nii.gz'
91
+ '''
75
92
input_spec = DcmStackInputSpec
76
93
output_spec = DcmStackOutputSpec
77
94
@@ -116,8 +133,7 @@ class GroupAndStackOutputSpec(TraitedSpec):
116
133
out_list = traits .List (desc = "List of output nifti files" )
117
134
118
135
class GroupAndStack (NiftiGeneratorBase ):
119
- '''Create (potentially) multiple Nifti files for a set of DICOM
120
- files.'''
136
+ '''Create (potentially) multiple Nifti files for a set of DICOM files.'''
121
137
input_spec = DcmStackInputSpec
122
138
output_spec = GroupAndStackOutputSpec
123
139
@@ -162,12 +178,16 @@ class LookupMeta(BaseInterface):
162
178
-------
163
179
164
180
>>> from nipype.interfaces import dcmstack
165
- >>> lm = dcmstack.LookupMeta()
166
- >>> lm.inputs.in_file = 'input.nii.gz'
167
- >>> lm.inputs.meta_keys = {'RepetitionTime' : 'TR'}
168
- >>> result = lm.run()
181
+ >>> lookup = dcmstack.LookupMeta()
182
+ >>> lookup.inputs.in_file = 'input.nii.gz'
183
+ >>> lookup.inputs.meta_keys = {'RepetitionTime' : 'TR',
184
+ 'EchoTime' : 'TE'
185
+ }
186
+ >>> result = lookup.run()
169
187
>>> result.outputs.TR
170
188
9500.0
189
+ >>> result.outputs.TE
190
+ 95.0
171
191
'''
172
192
input_spec = LookupMetaInputSpec
173
193
output_spec = DynamicTraitedSpec
@@ -224,10 +244,11 @@ class CopyMetaOutputSpec(TraitedSpec):
224
244
dest_file = traits .File (exists = True )
225
245
226
246
class CopyMeta (BaseInterface ):
247
+ '''Copy meta data from one Nifti file to another. Useful for preserving
248
+ meta data after some processing steps.'''
227
249
input_spec = CopyMetaInputSpec
228
250
output_spec = CopyMetaOutputSpec
229
251
230
- '''Copy meta data from one Nifti file to another.'''
231
252
def _run_interface (self , runtime ):
232
253
src = NiftiWrapper .from_filename (self .inputs .src_file )
233
254
dest_nii = nb .load (self .inputs .dest_file )
@@ -327,8 +348,8 @@ class SplitNiftiOutputSpec(TraitedSpec):
327
348
desc = "Split Nifti files" )
328
349
329
350
class SplitNifti (NiftiGeneratorBase ):
330
- '''Merge multiple Nifti files into one. Merges together meta data
331
- extensions as well.'''
351
+ '''Split one Nifti file into many along the specified dimension. Each
352
+ result has an updated meta data extension as well.'''
332
353
input_spec = SplitNiftiInputSpec
333
354
output_spec = SplitNiftiOutputSpec
334
355
0 commit comments