|
| 1 | +from nipype.interfaces.base import CommandLineInputSpec, File, traits, TraitedSpec |
| 2 | +from nipype.interfaces.workbench.base import WBCommand |
| 3 | + |
| 4 | + |
| 5 | +class CiftiDilateInputSpec(CommandLineInputSpec): |
| 6 | + in_file = File( |
| 7 | + exists=True, |
| 8 | + mandatory=True, |
| 9 | + argstr="%s", |
| 10 | + position=0, |
| 11 | + desc="The input CIFTI file", |
| 12 | + ) |
| 13 | + direction = traits.Enum( |
| 14 | + "ROW", |
| 15 | + "COLUMN", |
| 16 | + mandatory=True, |
| 17 | + argstr="%s", |
| 18 | + position=1, |
| 19 | + desc="Which dimension to dilate along, ROW or COLUMN", |
| 20 | + ) |
| 21 | + surface_distance = traits.Int( |
| 22 | + mandatory=True, |
| 23 | + argstr="%d", |
| 24 | + position=2, |
| 25 | + desc="The distance to dilate on surfaces, in mm", |
| 26 | + ) |
| 27 | + volume_distance = traits.Int( |
| 28 | + mandatory=True, |
| 29 | + argstr="%d", |
| 30 | + position=3, |
| 31 | + desc="The distance to dilate in the volume, in mm", |
| 32 | + ) |
| 33 | + out_file = File( |
| 34 | + name_source=["in_file"], |
| 35 | + name_template="dilated_%s.nii", |
| 36 | + keep_extension=True, |
| 37 | + argstr="%s", |
| 38 | + position=4, |
| 39 | + desc="The dilated CIFTI file", |
| 40 | + ) |
| 41 | + left_surface = File( |
| 42 | + exists=True, |
| 43 | + position=5, |
| 44 | + argstr="-left-surface %s", |
| 45 | + desc="Specify the left surface to use", |
| 46 | + ) |
| 47 | + left_corrected_areas = File( |
| 48 | + exists=True, |
| 49 | + position=6, |
| 50 | + requires=["left_surface"], |
| 51 | + argstr="-left-corrected-areas %s", |
| 52 | + desc="vertex areas (as a metric) to use instead of computing them from the left surface.", |
| 53 | + ) |
| 54 | + right_surface = File( |
| 55 | + exists=True, |
| 56 | + position=7, |
| 57 | + argstr="-right-surface %s", |
| 58 | + desc="Specify the right surface to use", |
| 59 | + ) |
| 60 | + right_corrected_areas = File( |
| 61 | + exists=True, |
| 62 | + position=8, |
| 63 | + requires=["right_surface"], |
| 64 | + argstr="-right-corrected-areas %s", |
| 65 | + desc="vertex areas (as a metric) to use instead of computing them from the right surface", |
| 66 | + ) |
| 67 | + cerebellum_surface = File( |
| 68 | + exists=True, |
| 69 | + position=9, |
| 70 | + argstr="-cerebellum-surface %s", |
| 71 | + desc="specify the cerebellum surface to use", |
| 72 | + ) |
| 73 | + cerebellum_corrected_areas = File( |
| 74 | + exists=True, |
| 75 | + position=10, |
| 76 | + requires=["cerebellum_surface"], |
| 77 | + argstr="-cerebellum-corrected-areas %s", |
| 78 | + desc="vertex areas (as a metric) to use instead of computing them from the cerebellum " |
| 79 | + "surface", |
| 80 | + ) |
| 81 | + bad_brainordinate_roi = File( |
| 82 | + exists=True, |
| 83 | + position=11, |
| 84 | + argstr="-bad-brainordinate-roi %s", |
| 85 | + desc="CIFTI dscalar or dtseries file, positive values denote brainordinates to have their " |
| 86 | + "values replaced", |
| 87 | + ) |
| 88 | + nearest = traits.Bool( |
| 89 | + position=12, |
| 90 | + argstr="-nearest", |
| 91 | + desc="Use nearest good value instead of a weighted average", |
| 92 | + ) |
| 93 | + merged_volume = traits.Bool( |
| 94 | + position=13, |
| 95 | + argstr="-merged-volume", |
| 96 | + desc="treat volume components as if they were a single component", |
| 97 | + ) |
| 98 | + legacy_mode = traits.Bool( |
| 99 | + position=14, |
| 100 | + argstr="-legacy-mode", |
| 101 | + desc="Use the math from v1.3.2 and earlier for weighted dilation", |
| 102 | + ) |
| 103 | + |
| 104 | + |
| 105 | +class CiftiDilateOutputSpec(TraitedSpec): |
| 106 | + out_file = File(exists=True, desc="Dilated CIFTI file") |
| 107 | + |
| 108 | + |
| 109 | +class CiftiDilate(WBCommand): |
| 110 | + """ |
| 111 | + Dilate a CIFTI file. |
| 112 | +
|
| 113 | + For all data values designated as bad, if they neighbor a good value or |
| 114 | + are within the specified distance of a good value in the same kind of |
| 115 | + model, replace the value with a distance weighted average of nearby good |
| 116 | + values, otherwise set the value to zero. If -nearest is specified, it |
| 117 | + will use the value from the closest good value within range instead of a |
| 118 | + weighted average. When the input file contains label data, nearest |
| 119 | + dilation is used on the surface, and weighted popularity is used in the |
| 120 | + volume. |
| 121 | +
|
| 122 | + The -*-corrected-areas options are intended for dilating on group average |
| 123 | + surfaces, but it is only an approximate correction for the reduction of |
| 124 | + structure in a group average surface. |
| 125 | +
|
| 126 | + If -bad-brainordinate-roi is specified, all values, including those with |
| 127 | + value zero, are good, except for locations with a positive value in the |
| 128 | + ROI. If it is not specified, only values equal to zero are bad. |
| 129 | +
|
| 130 | + """ |
| 131 | + |
| 132 | + input_spec = CiftiDilateInputSpec |
| 133 | + output_spec = CiftiDilateOutputSpec |
| 134 | + _cmd = "wb_command -cifti-dilate" |
0 commit comments