|
8 | 8 |
|
9 | 9 | from ..base import (TraitedSpec, File, traits)
|
10 | 10 | from .base import ANTSCommand, ANTSCommandInputSpec
|
11 |
| -import os |
| 11 | +from nipype.utils.filemanip import split_filename |
12 | 12 | from nipype.interfaces.base import InputMultiPath
|
13 | 13 | from nipype.interfaces.traits_extension import isdefined
|
14 | 14 | import numpy as np
|
| 15 | +import os |
15 | 16 |
|
16 | 17 | class ConvertScalarImageToRGBInputSpec(ANTSCommandInputSpec):
|
17 | 18 | dimension=traits.Enum(3, 2, argstr= '%d', usedefault=True,
|
@@ -82,19 +83,18 @@ class CreateTiledMosaicInputSpec(ANTSCommandInputSpec):
|
82 | 83 | mandatory = True)
|
83 | 84 | mask_image = File(argstr = '-x %s', exists = True,
|
84 | 85 | 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', |
86 | 87 | desc = ('If an Rgb image is provided, render the overlay '
|
87 | 88 | 'using the specified alpha parameter.'))
|
88 | 89 | output_image = traits.Str(argstr = '-o %s',
|
89 | 90 | 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 = ( |
92 | 92 | '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", ' |
94 | 94 | 'then 5 rows by 10 columns of slices are rendered. If R < 0 and C > '
|
95 | 95 | '0 (or vice versa), the negative value is selected'
|
96 | 96 | '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 ' |
98 | 98 | 'the slices. If no direction is specified, the '
|
99 | 99 | 'direction with the coarsest spacing is chosen.'))
|
100 | 100 | pad_or_crop = traits.Str(argstr='-p %s',
|
@@ -133,18 +133,30 @@ class CreateTiledMosaic(ANTSCommand):
|
133 | 133 |
|
134 | 134 | >>> from nipype.interfaces.ants.visualization import CreateTiledMosaic
|
135 | 135 | >>> mosaic_slicer = CreateTiledMosaic()
|
136 |
| - >>> mosaic_slicer.inputs.dimension = 3 |
137 | 136 | >>> 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]' |
141 | 146 | """
|
142 | 147 |
|
143 | 148 | _cmd = 'CreateTiledMosaic'
|
144 | 149 | input_spec = CreateTiledMosaicInputSpec
|
145 | 150 | output_spec = CreateTiledMosaicOutputSpec
|
146 | 151 |
|
| 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 | + |
147 | 159 | def _list_outputs(self):
|
148 | 160 | 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 |
0 commit comments