Skip to content

Commit c7e43ea

Browse files
committed
Editing docstring to follow nipype template and add some tests.
1 parent f431e0c commit c7e43ea

14 files changed

+245
-224
lines changed

nipype/interfaces/niftyseg/em.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
Examples
1111
--------
1212
See the docstrings of the individual classes for examples.
13+
14+
Change directory to provide relative paths for doctests
15+
>>> import os
16+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
17+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
18+
>>> os.chdir(datadir)
1319
"""
1420

1521
import os
@@ -116,9 +122,9 @@ class EM(NiftySegCommand):
116122
117123
Examples
118124
--------
119-
>>> from nipype.interfaces.niftyseg import EM
120-
>>> node = EM()
121-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
125+
>>> from nipype.interfaces import niftyseg
126+
>>> node = niftyseg.EM()
127+
>>> node.inputs.in_file = 'im1.nii'
122128
>>> node.inputs.no_prior = 4
123129
>>> node.cmdline # doctest: +SKIP
124130
'seg_EM -in im1.nii -nopriors 4 -bc_out im1_bc_em.nii -out im1_em.nii \

nipype/interfaces/niftyseg/label_fusion.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"""
55
The fusion module provides higher-level interfaces to some of the operations
66
that can be performed with the seg_LabFusion command-line program.
7+
8+
Change directory to provide relative paths for doctests
9+
>>> import os
10+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
11+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
12+
>>> os.chdir(datadir)
713
"""
814

915
from builtins import str
@@ -114,12 +120,12 @@ class LabelFusion(NiftySegCommand):
114120
115121
Examples
116122
--------
117-
>>> from nipype.interfaces.niftyseg import LabelFusion
118-
>>> node = LabelFusion()
119-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
123+
>>> from nipype.interfaces import niftyseg
124+
>>> node = niftyseg.LabelFusion()
125+
>>> node.inputs.in_file = 'im1.nii'
120126
>>> node.inputs.kernel_size = 2.0
121-
>>> node.inputs.file_to_seg = 'im2.nii' # doctest: +SKIP
122-
>>> node.inputs.template_file = 'im3.nii' # doctest: +SKIP
127+
>>> node.inputs.file_to_seg = 'im2.nii'
128+
>>> node.inputs.template_file = 'im3.nii'
123129
>>> node.inputs.template_num = 2
124130
>>> node.inputs.classifier_type = 'STEPS'
125131
>>> node.cmdline # doctest: +SKIP
@@ -277,11 +283,11 @@ class CalcTopNCC(NiftySegCommand):
277283
278284
Examples
279285
--------
280-
>>> from nipype.interfaces.niftyseg import CalcTopNCC
281-
>>> node = CalcTopNCC()
282-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
286+
>>> from nipype.interfaces import niftyseg
287+
>>> node = niftyseg.CalcTopNCC()
288+
>>> node.inputs.in_file = 'im1.nii'
283289
>>> node.inputs.num_templates = 2
284-
>>> node.inputs.in_templates = ['im2.nii', 'im3.nii'] # doctest: +SKIP
290+
>>> node.inputs.in_templates = ['im2.nii', 'im3.nii']
285291
>>> node.inputs.top_templates = 1
286292
>>> node.cmdline # doctest: +SKIP
287293
'seg_CalcTopNCC -target im1.nii -templates 2 im2.nii im3.nii -n 1'

nipype/interfaces/niftyseg/lesions.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
Examples
1111
--------
1212
See the docstrings of the individual classes for examples.
13+
14+
Change directory to provide relative paths for doctests
15+
>>> import os
16+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
17+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
18+
>>> os.chdir(datadir)
1319
"""
1420

1521
import os
@@ -98,10 +104,10 @@ class FillLesions(NiftySegCommand):
98104
99105
Examples
100106
--------
101-
>>> from nipype.interfaces.niftyseg import FillLesions
102-
>>> node = FillLesions()
103-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
104-
>>> node.inputs.lesion_mask = 'im2.nii' # doctest: +SKIP
107+
>>> from nipype.interfaces import niftyseg
108+
>>> node = niftyseg.FillLesions()
109+
>>> node.inputs.in_file = 'im1.nii'
110+
>>> node.inputs.lesion_mask = 'im2.nii'
105111
>>> node.cmdline # doctest: +SKIP
106112
'seg_FillLesions -i im1.nii -l im2.nii -o im1_lesions_filled.nii'
107113

nipype/interfaces/niftyseg/maths.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
Examples
1111
--------
1212
See the docstrings of the individual classes for examples.
13+
14+
Change directory to provide relative paths for doctests
15+
>>> import os
16+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
17+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
18+
>>> os.chdir(datadir)
1319
"""
1420
import os
1521

@@ -125,9 +131,9 @@ class UnaryMaths(MathsCommand):
125131
126132
Examples
127133
--------
128-
>>> from nipype.interfaces.niftyseg import UnaryMaths
129-
>>> node = UnaryMaths()
130-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
134+
>>> from nipype.interfaces import niftyseg
135+
>>> node = niftyseg.UnaryMaths()
136+
>>> node.inputs.in_file = 'im1.nii'
131137
>>> node.inputs.operation = 'sqrt'
132138
>>> node.inputs.output_datatype = 'float'
133139
>>> node.cmdline # doctest: +SKIP
@@ -212,11 +218,11 @@ class BinaryMaths(MathsCommand):
212218
213219
Examples
214220
--------
215-
>>> from nipype.interfaces.niftyseg import BinaryMaths
216-
>>> node = BinaryMaths()
217-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
221+
>>> from nipype.interfaces import niftyseg
222+
>>> node = niftyseg.BinaryMaths()
223+
>>> node.inputs.in_file = 'im1.nii'
218224
>>> node.inputs.operation = 'sub'
219-
>>> node.inputs.operand_file = 'im2.nii' # doctest: +SKIP
225+
>>> node.inputs.operand_file = 'im2.nii'
220226
>>> node.inputs.output_datatype = 'float'
221227
>>> node.cmdline # doctest: +SKIP
222228
'seg_maths im1.nii -odt float -sub im2.nii im1_sub.nii.gz'
@@ -289,7 +295,7 @@ class BinaryMathsInteger(MathsCommand):
289295
--------
290296
>>> from nipype.interfaces.niftyseg import BinaryMathsInteger
291297
>>> node = BinaryMathsInteger()
292-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
298+
>>> node.inputs.in_file = 'im1.nii'
293299
>>> node.inputs.operation = 'dil'
294300
>>> node.inputs.operand_value = 2
295301
>>> node.inputs.output_datatype = 'float'
@@ -357,11 +363,11 @@ class TupleMaths(MathsCommand):
357363
358364
Examples
359365
--------
360-
>>> from nipype.interfaces.niftyseg import TupleMaths
361-
>>> node = TupleMaths()
362-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
366+
>>> from nipype.interfaces import niftyseg
367+
>>> node = niftyseg.TupleMaths()
368+
>>> node.inputs.in_file = 'im1.nii'
363369
>>> node.inputs.operation = 'lncc'
364-
>>> node.inputs.operand_file1 = 'im2.nii' # doctest: +SKIP
370+
>>> node.inputs.operand_file1 = 'im2.nii'
365371
>>> node.inputs.operand_value2 = 2.0
366372
>>> node.inputs.output_datatype = 'float'
367373
>>> node.cmdline # doctest: +SKIP
@@ -398,11 +404,11 @@ class Merge(MathsCommand):
398404
399405
Examples
400406
--------
401-
>>> from nipype.interfaces.niftyseg import Merge
402-
>>> node = Merge()
403-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
407+
>>> from nipype.interfaces import niftyseg
408+
>>> node = niftyseg.Merge()
409+
>>> node.inputs.in_file = 'im1.nii'
404410
>>> files = ['im2.nii', 'im3.nii']
405-
>>> node.inputs.merge_files = files # doctest: +SKIP
411+
>>> node.inputs.merge_files = files
406412
>>> node.inputs.dimension = 2
407413
>>> node.inputs.output_datatype = 'float'
408414
>>> node.cmdline # doctest: +SKIP

nipype/interfaces/niftyseg/patchmatch.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
34
"""
45
The fusion module provides higher-level interfaces to some of the operations
56
that can be performed with the seg_DetectLesions command-line program.
7+
8+
Change directory to provide relative paths for doctests
9+
>>> import os
10+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
11+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
12+
>>> os.chdir(datadir)
613
"""
714
import os
815
import warnings
@@ -93,11 +100,11 @@ class PatchMatch(NiftySegCommand):
93100
94101
Examples
95102
--------
96-
>>> from nipype.interfaces.niftyseg import PatchMatch
97-
>>> node = PatchMatch()
98-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
99-
>>> node.inputs.mask_file = 'im2.nii' # doctest: +SKIP
100-
>>> node.inputs.database_file = 'db.xml' # doctest: +SKIP
103+
>>> from nipype.interfaces import niftyseg
104+
>>> node = niftyseg.PatchMatch()
105+
>>> node.inputs.in_file = 'im1.nii'
106+
>>> node.inputs.mask_file = 'im2.nii'
107+
>>> node.inputs.database_file = 'db.xml'
101108
>>> node.cmdline # doctest: +SKIP
102109
'seg_PatchMatch -i im1.nii -m im2.nii -db db.xml -o im1_pm.nii'
103110

nipype/interfaces/niftyseg/stats.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
34
"""
45
The stats module provides higher-level interfaces to some of the operations
5-
that can be performed with the niftysegstats (seg_stats) command-line program.
6+
that can be performed with the niftyseg stats (seg_stats) command-line program.
7+
8+
Change directory to provide relative paths for doctests
9+
>>> import os
10+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
11+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
12+
>>> os.chdir(datadir)
613
"""
714
from __future__ import print_function
815
import numpy as np
@@ -121,9 +128,9 @@ class UnaryStats(StatsCommand):
121128
122129
Examples
123130
--------
124-
>>> from nipype.interfaces.niftyseg import UnaryStats
125-
>>> node = UnaryStats()
126-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
131+
>>> from nipype.interfaces import niftyseg
132+
>>> node = niftyseg.UnaryStats()
133+
>>> node.inputs.in_file = 'im1.nii'
127134
>>> node.inputs.operation = 'v'
128135
>>> node.cmdline # doctest: +SKIP
129136
'seg_stats im1.nii -v'
@@ -184,9 +191,9 @@ class BinaryStats(StatsCommand):
184191
185192
Examples
186193
--------
187-
>>> from nipype.interfaces.niftyseg import BinaryStats
188-
>>> node = BinaryStats()
189-
>>> node.inputs.in_file = 'im1.nii' # doctest: +SKIP
194+
>>> from nipype.interfaces import niftyseg
195+
>>> node = niftyseg.BinaryStats()
196+
>>> node.inputs.in_file = 'im1.nii'
190197
>>> node.inputs.operation = 'sa'
191198
>>> node.inputs.operand_value = 2.0
192199
>>> node.cmdline # doctest: +SKIP

nipype/interfaces/niftyseg/tests/test_Seg_CalcTopNCC.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)