niwrap.ants.smooth_image
1# This file was auto generated by Styx. 2# Do not edit this file directly. 3 4import typing 5import pathlib 6from styxdefs import * 7 8SMOOTH_IMAGE_METADATA = Metadata( 9 id="c743ecca2407454064c39d3994944e2822b5560a.boutiques", 10 name="SmoothImage", 11 package="ants", 12 container_image_tag="antsx/ants:v2.5.3", 13) 14 15 16SmoothImageParameters = typing.TypedDict('SmoothImageParameters', { 17 "__STYX_TYPE__": typing.Literal["SmoothImage"], 18 "image_dimension": int, 19 "image_ext": InputPathType, 20 "smoothing_sigma": str, 21 "out_image_ext": str, 22 "sigma_units": typing.NotRequired[typing.Literal[0, 1] | None], 23 "median_filter": typing.NotRequired[typing.Literal[0, 1] | None], 24}) 25 26 27def dyn_cargs( 28 t: str, 29) -> typing.Any: 30 """ 31 Get build cargs function by command type. 32 33 Args: 34 t: Command type. 35 Returns: 36 Build cargs function. 37 """ 38 return { 39 "SmoothImage": smooth_image_cargs, 40 }.get(t) 41 42 43def dyn_outputs( 44 t: str, 45) -> typing.Any: 46 """ 47 Get build outputs function by command type. 48 49 Args: 50 t: Command type. 51 Returns: 52 Build outputs function. 53 """ 54 return { 55 "SmoothImage": smooth_image_outputs, 56 }.get(t) 57 58 59class SmoothImageOutputs(typing.NamedTuple): 60 """ 61 Output object returned when calling `smooth_image(...)`. 62 """ 63 root: OutputPathType 64 """Output root folder. This is the root folder for all outputs.""" 65 smoothed_image: OutputPathType 66 """The output smoothed image file.""" 67 68 69def smooth_image_params( 70 image_dimension: int, 71 image_ext: InputPathType, 72 smoothing_sigma: str, 73 out_image_ext: str, 74 sigma_units: typing.Literal[0, 1] | None = None, 75 median_filter: typing.Literal[0, 1] | None = None, 76) -> SmoothImageParameters: 77 """ 78 Build parameters. 79 80 Args: 81 image_dimension: Specifies the dimensionality of the image. 82 image_ext: The input image file to be smoothed. 83 smoothing_sigma: The sigma value for smoothing. A separate sigma may be\ 84 specified for each dimension, e.g., '1.5x1x2'. 85 out_image_ext: The output smoothed image file. 86 sigma_units: Determines if sigma is in spacing units (1) or not (0).\ 87 Default is 0. 88 median_filter: Whether to use median filter. Default is 0. If using\ 89 median filter, sigma represents the radius in voxels. 90 Returns: 91 Parameter dictionary 92 """ 93 params = { 94 "__STYXTYPE__": "SmoothImage", 95 "image_dimension": image_dimension, 96 "image_ext": image_ext, 97 "smoothing_sigma": smoothing_sigma, 98 "out_image_ext": out_image_ext, 99 } 100 if sigma_units is not None: 101 params["sigma_units"] = sigma_units 102 if median_filter is not None: 103 params["median_filter"] = median_filter 104 return params 105 106 107def smooth_image_cargs( 108 params: SmoothImageParameters, 109 execution: Execution, 110) -> list[str]: 111 """ 112 Build command-line arguments from parameters. 113 114 Args: 115 params: The parameters. 116 execution: The execution object for resolving input paths. 117 Returns: 118 Command-line arguments. 119 """ 120 cargs = [] 121 cargs.append("SmoothImage") 122 cargs.append(str(params.get("image_dimension"))) 123 cargs.append(execution.input_file(params.get("image_ext"))) 124 cargs.append(params.get("smoothing_sigma")) 125 cargs.append(params.get("out_image_ext")) 126 if params.get("sigma_units") is not None: 127 cargs.append(str(params.get("sigma_units"))) 128 if params.get("median_filter") is not None: 129 cargs.append(str(params.get("median_filter"))) 130 return cargs 131 132 133def smooth_image_outputs( 134 params: SmoothImageParameters, 135 execution: Execution, 136) -> SmoothImageOutputs: 137 """ 138 Build outputs object containing output file paths and possibly stdout/stderr. 139 140 Args: 141 params: The parameters. 142 execution: The execution object for resolving input paths. 143 Returns: 144 Outputs object. 145 """ 146 ret = SmoothImageOutputs( 147 root=execution.output_file("."), 148 smoothed_image=execution.output_file(params.get("out_image_ext")), 149 ) 150 return ret 151 152 153def smooth_image_execute( 154 params: SmoothImageParameters, 155 execution: Execution, 156) -> SmoothImageOutputs: 157 """ 158 SmoothImage allows smoothing of images with adjustable sigma values, offering 159 optional median filtering functionality. 160 161 Author: ANTs Developers 162 163 URL: https://github.com/ANTsX/ANTs 164 165 Args: 166 params: The parameters. 167 execution: The execution object. 168 Returns: 169 NamedTuple of outputs (described in `SmoothImageOutputs`). 170 """ 171 params = execution.params(params) 172 cargs = smooth_image_cargs(params, execution) 173 ret = smooth_image_outputs(params, execution) 174 execution.run(cargs) 175 return ret 176 177 178def smooth_image( 179 image_dimension: int, 180 image_ext: InputPathType, 181 smoothing_sigma: str, 182 out_image_ext: str, 183 sigma_units: typing.Literal[0, 1] | None = None, 184 median_filter: typing.Literal[0, 1] | None = None, 185 runner: Runner | None = None, 186) -> SmoothImageOutputs: 187 """ 188 SmoothImage allows smoothing of images with adjustable sigma values, offering 189 optional median filtering functionality. 190 191 Author: ANTs Developers 192 193 URL: https://github.com/ANTsX/ANTs 194 195 Args: 196 image_dimension: Specifies the dimensionality of the image. 197 image_ext: The input image file to be smoothed. 198 smoothing_sigma: The sigma value for smoothing. A separate sigma may be\ 199 specified for each dimension, e.g., '1.5x1x2'. 200 out_image_ext: The output smoothed image file. 201 sigma_units: Determines if sigma is in spacing units (1) or not (0).\ 202 Default is 0. 203 median_filter: Whether to use median filter. Default is 0. If using\ 204 median filter, sigma represents the radius in voxels. 205 runner: Command runner. 206 Returns: 207 NamedTuple of outputs (described in `SmoothImageOutputs`). 208 """ 209 runner = runner or get_global_runner() 210 execution = runner.start_execution(SMOOTH_IMAGE_METADATA) 211 params = smooth_image_params( 212 image_dimension=image_dimension, 213 image_ext=image_ext, 214 smoothing_sigma=smoothing_sigma, 215 out_image_ext=out_image_ext, 216 sigma_units=sigma_units, 217 median_filter=median_filter, 218 ) 219 return smooth_image_execute(params, execution) 220 221 222__all__ = [ 223 "SMOOTH_IMAGE_METADATA", 224 "SmoothImageOutputs", 225 "SmoothImageParameters", 226 "smooth_image", 227 "smooth_image_params", 228]
SMOOTH_IMAGE_METADATA =
Metadata(id='c743ecca2407454064c39d3994944e2822b5560a.boutiques', name='SmoothImage', package='ants', citations=None, container_image_tag='antsx/ants:v2.5.3')
class
SmoothImageOutputs(typing.NamedTuple):
60class SmoothImageOutputs(typing.NamedTuple): 61 """ 62 Output object returned when calling `smooth_image(...)`. 63 """ 64 root: OutputPathType 65 """Output root folder. This is the root folder for all outputs.""" 66 smoothed_image: OutputPathType 67 """The output smoothed image file."""
Output object returned when calling smooth_image(...)
.
class
SmoothImageParameters(typing.TypedDict):
def
smooth_image( image_dimension: int, image_ext: pathlib._local.Path | str, smoothing_sigma: str, out_image_ext: str, sigma_units: Optional[Literal[0, 1]] = None, median_filter: Optional[Literal[0, 1]] = None, runner: styxdefs.types.Runner | None = None) -> SmoothImageOutputs:
179def smooth_image( 180 image_dimension: int, 181 image_ext: InputPathType, 182 smoothing_sigma: str, 183 out_image_ext: str, 184 sigma_units: typing.Literal[0, 1] | None = None, 185 median_filter: typing.Literal[0, 1] | None = None, 186 runner: Runner | None = None, 187) -> SmoothImageOutputs: 188 """ 189 SmoothImage allows smoothing of images with adjustable sigma values, offering 190 optional median filtering functionality. 191 192 Author: ANTs Developers 193 194 URL: https://github.com/ANTsX/ANTs 195 196 Args: 197 image_dimension: Specifies the dimensionality of the image. 198 image_ext: The input image file to be smoothed. 199 smoothing_sigma: The sigma value for smoothing. A separate sigma may be\ 200 specified for each dimension, e.g., '1.5x1x2'. 201 out_image_ext: The output smoothed image file. 202 sigma_units: Determines if sigma is in spacing units (1) or not (0).\ 203 Default is 0. 204 median_filter: Whether to use median filter. Default is 0. If using\ 205 median filter, sigma represents the radius in voxels. 206 runner: Command runner. 207 Returns: 208 NamedTuple of outputs (described in `SmoothImageOutputs`). 209 """ 210 runner = runner or get_global_runner() 211 execution = runner.start_execution(SMOOTH_IMAGE_METADATA) 212 params = smooth_image_params( 213 image_dimension=image_dimension, 214 image_ext=image_ext, 215 smoothing_sigma=smoothing_sigma, 216 out_image_ext=out_image_ext, 217 sigma_units=sigma_units, 218 median_filter=median_filter, 219 ) 220 return smooth_image_execute(params, execution)
SmoothImage allows smoothing of images with adjustable sigma values, offering optional median filtering functionality.
Author: ANTs Developers
URL: https://github.com/ANTsX/ANTs
Arguments:
- image_dimension: Specifies the dimensionality of the image.
- image_ext: The input image file to be smoothed.
- smoothing_sigma: The sigma value for smoothing. A separate sigma may be specified for each dimension, e.g., '1.5x1x2'.
- out_image_ext: The output smoothed image file.
- sigma_units: Determines if sigma is in spacing units (1) or not (0). Default is 0.
- median_filter: Whether to use median filter. Default is 0. If using median filter, sigma represents the radius in voxels.
- runner: Command runner.
Returns:
NamedTuple of outputs (described in
SmoothImageOutputs
).
def
smooth_image_params( image_dimension: int, image_ext: pathlib._local.Path | str, smoothing_sigma: str, out_image_ext: str, sigma_units: Optional[Literal[0, 1]] = None, median_filter: Optional[Literal[0, 1]] = None) -> SmoothImageParameters:
70def smooth_image_params( 71 image_dimension: int, 72 image_ext: InputPathType, 73 smoothing_sigma: str, 74 out_image_ext: str, 75 sigma_units: typing.Literal[0, 1] | None = None, 76 median_filter: typing.Literal[0, 1] | None = None, 77) -> SmoothImageParameters: 78 """ 79 Build parameters. 80 81 Args: 82 image_dimension: Specifies the dimensionality of the image. 83 image_ext: The input image file to be smoothed. 84 smoothing_sigma: The sigma value for smoothing. A separate sigma may be\ 85 specified for each dimension, e.g., '1.5x1x2'. 86 out_image_ext: The output smoothed image file. 87 sigma_units: Determines if sigma is in spacing units (1) or not (0).\ 88 Default is 0. 89 median_filter: Whether to use median filter. Default is 0. If using\ 90 median filter, sigma represents the radius in voxels. 91 Returns: 92 Parameter dictionary 93 """ 94 params = { 95 "__STYXTYPE__": "SmoothImage", 96 "image_dimension": image_dimension, 97 "image_ext": image_ext, 98 "smoothing_sigma": smoothing_sigma, 99 "out_image_ext": out_image_ext, 100 } 101 if sigma_units is not None: 102 params["sigma_units"] = sigma_units 103 if median_filter is not None: 104 params["median_filter"] = median_filter 105 return params
Build parameters.
Arguments:
- image_dimension: Specifies the dimensionality of the image.
- image_ext: The input image file to be smoothed.
- smoothing_sigma: The sigma value for smoothing. A separate sigma may be specified for each dimension, e.g., '1.5x1x2'.
- out_image_ext: The output smoothed image file.
- sigma_units: Determines if sigma is in spacing units (1) or not (0). Default is 0.
- median_filter: Whether to use median filter. Default is 0. If using median filter, sigma represents the radius in voxels.
Returns:
Parameter dictionary