Skip to content

Commit 3abf060

Browse files
committed
DOC: Various clean up an improvements to docstrings.
1 parent 0972fa0 commit 3abf060

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

nipype/interfaces/dcmstack.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ class NiftiGeneratorBaseInputSpec(TraitedSpec):
3838
desc="Determines output file type")
3939

4040
class NiftiGeneratorBase(BaseInterface):
41+
'''Base class for interfaces that produce Nifti files, potentially with
42+
embeded meta data.'''
4143
def _get_out_path(self, meta):
44+
'''Return the output path for the gernerated Nifti.'''
4245
if self.inputs.out_format:
4346
out_fmt = self.inputs.out_format
4447
else:
48+
#If no out_format is specified, use a sane default that will work
49+
#with the provided meta data.
4550
out_fmt = []
4651
if 'SeriesNumber' in meta:
4752
out_fmt.append('%(SeriesNumber)03d')
@@ -71,7 +76,19 @@ class DcmStackOutputSpec(TraitedSpec):
7176
out_file = traits.File(exists=True)
7277

7378
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+
'''
7592
input_spec = DcmStackInputSpec
7693
output_spec = DcmStackOutputSpec
7794

@@ -116,8 +133,7 @@ class GroupAndStackOutputSpec(TraitedSpec):
116133
out_list = traits.List(desc="List of output nifti files")
117134

118135
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.'''
121137
input_spec = DcmStackInputSpec
122138
output_spec = GroupAndStackOutputSpec
123139

@@ -162,12 +178,16 @@ class LookupMeta(BaseInterface):
162178
-------
163179
164180
>>> 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()
169187
>>> result.outputs.TR
170188
9500.0
189+
>>> result.outputs.TE
190+
95.0
171191
'''
172192
input_spec = LookupMetaInputSpec
173193
output_spec = DynamicTraitedSpec
@@ -224,10 +244,11 @@ class CopyMetaOutputSpec(TraitedSpec):
224244
dest_file = traits.File(exists=True)
225245

226246
class CopyMeta(BaseInterface):
247+
'''Copy meta data from one Nifti file to another. Useful for preserving
248+
meta data after some processing steps.'''
227249
input_spec = CopyMetaInputSpec
228250
output_spec = CopyMetaOutputSpec
229251

230-
'''Copy meta data from one Nifti file to another.'''
231252
def _run_interface(self, runtime):
232253
src = NiftiWrapper.from_filename(self.inputs.src_file)
233254
dest_nii = nb.load(self.inputs.dest_file)
@@ -327,8 +348,8 @@ class SplitNiftiOutputSpec(TraitedSpec):
327348
desc="Split Nifti files")
328349

329350
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.'''
332353
input_spec = SplitNiftiInputSpec
333354
output_spec = SplitNiftiOutputSpec
334355

0 commit comments

Comments
 (0)