Skip to content

Commit a67de7e

Browse files
committed
added example files
1 parent f4e7124 commit a67de7e

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

nipype/interfaces/ants/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .segmentation import Atropos, LaplacianThickness, N4BiasFieldCorrection
1515

1616
# Visualization Programs
17-
from .visualization import ConvertScalarImageToRGB
17+
from .visualization import ConvertScalarImageToRGB, CreateTiledMosaic
1818

1919
# Utility Programs
2020
from .utils import AverageAffineTransform, AverageImages, MultiplyImages, JacobianDeterminant

nipype/interfaces/ants/visualization.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
from ..base import (TraitedSpec, File, traits)
1010
from .base import ANTSCommand, ANTSCommandInputSpec
11-
import os
11+
from nipype.utils.filemanip import split_filename
1212
from nipype.interfaces.base import InputMultiPath
1313
from nipype.interfaces.traits_extension import isdefined
1414
import numpy as np
15+
import os
1516

1617
class ConvertScalarImageToRGBInputSpec(ANTSCommandInputSpec):
1718
dimension=traits.Enum(3, 2, argstr= '%d', usedefault=True,
@@ -82,19 +83,18 @@ class CreateTiledMosaicInputSpec(ANTSCommandInputSpec):
8283
mandatory = True)
8384
mask_image = File(argstr = '-x %s', exists = True,
8485
desc = 'Specifies the ROI of the RGB voxels used.')
85-
alpha_value = traits.Float(argstr = '-a %f',
86+
alpha_value = traits.Float(argstr = '-a %.2f',
8687
desc = ('If an Rgb image is provided, render the overlay '
8788
'using the specified alpha parameter.'))
8889
output_image = traits.Str(argstr = '-o %s',
8990
desc = 'The output consists of the tiled mosaic image.')
90-
tile_geometry = traits.Str(argstr = '%s',
91-
desc = (
91+
tile_geometry = traits.Str(argstr = '-t %s',desc = (
9292
'The tile geometry specifies the number of rows and columns'
93-
'in the output image. For example, if the user specifies ''5x10'', '
93+
'in the output image. For example, if the user specifies "5x10", '
9494
'then 5 rows by 10 columns of slices are rendered. If R < 0 and C > '
9595
'0 (or vice versa), the negative value is selected'
9696
'based on direction.'))
97-
direction = traits.Int(argstr = '%d', desc = ('Specifies the direction of '
97+
direction = traits.Int(argstr = '-d %d', desc = ('Specifies the direction of '
9898
'the slices. If no direction is specified, the '
9999
'direction with the coarsest spacing is chosen.'))
100100
pad_or_crop = traits.Str(argstr='-p %s',
@@ -133,18 +133,30 @@ class CreateTiledMosaic(ANTSCommand):
133133
134134
>>> from nipype.interfaces.ants.visualization import CreateTiledMosaic
135135
>>> mosaic_slicer = CreateTiledMosaic()
136-
>>> mosaic_slicer.inputs.dimension = 3
137136
>>> mosaic_slicer.inputs.input_image = 'T1.nii.gz'
138-
>>> mosaic_slicer.inputs.colormap = 'jet'
139-
>>>
140-
137+
>>> mosaic_slicer.inputs.rgb_image = 'rgb.nii.gz'
138+
>>> mosaic_slicer.inputs.mask_image = 'mask.nii.gz'
139+
>>> mosaic_slicer.inputs.output_image = 'output.png'
140+
>>> mosaic_slicer.inputs.alpha_value = 0.5
141+
>>> mosaic_slicer.inputs.direction = 2
142+
>>> mosaic_slicer.inputs.pad_or_crop = '[ -15x -50 , -15x -30 ,0]'
143+
>>> mosaic_slicer.inputs.slices = '[2 ,100 ,160]'
144+
>>> mosaic_slicer.cmdline
145+
'CreateTiledMosaic -a 0.50 -d 2 -i T1.nii.gz -x mask.nii.gz -o output.png -p [ -15x -50 , -15x -30 ,0] -r rgb.nii.gz -s [2 ,100 ,160]'
141146
"""
142147

143148
_cmd = 'CreateTiledMosaic'
144149
input_spec = CreateTiledMosaicInputSpec
145150
output_spec = CreateTiledMosaicOutputSpec
146151

152+
def _gen_outfilename(self):
153+
output_image = self.inputs.output_image
154+
if not isdefined(output_image) and isdefined(self.inputs.input_image):
155+
path, _, _ = split_filename(self.inputs.input_image)
156+
output_image = os.path.join(path, 'out.png')
157+
return output_image
158+
147159
def _list_outputs(self):
148160
outputs = self._outputs().get()
149-
outputs['output_image'] = os.path.join(os.getcwd(),
150-
self.inputs.output_image)
161+
output_image = self._gen_outfilename()
162+
outputs['output_image'] = output_image

nipype/testing/data/mask.nii.gz

Whitespace-only changes.

nipype/testing/data/rgb.nii.gz

Whitespace-only changes.

0 commit comments

Comments
 (0)