Skip to content

Commit

Permalink
moved aramis versions into pydra/* directory
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Mar 25, 2024
1 parent 78655c3 commit 0e423bd
Show file tree
Hide file tree
Showing 6 changed files with 362 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def _format_output(
)


def _format_interpolation(interpolator: str, sigma: float, alpha: float, order: int) -> str:
def _format_interpolation(
interpolator: str, sigma: float, alpha: float, order: int
) -> str:
return "-n {}{}".format(
interpolator,
f"[{order}]"
Expand Down Expand Up @@ -70,7 +72,11 @@ class ApplyTransforms(ShellCommandTask):
@define(kw_only=True)
class InputSpec(ShellSpec):
dimensionality: int = field(
metadata={"help_string": "image dimensionality", "argstr": "-d", "allowed_values": {2, 3, 4}}
metadata={
"help_string": "image dimensionality",
"argstr": "-d",
"allowed_values": {2, 3, 4},
}
)

image_type: str = field(
Expand All @@ -85,19 +91,32 @@ class InputSpec(ShellSpec):
},
)

moving_image: PathLike = field(metadata={"help_string": "moving image", "mandatory": True, "argstr": "-i"})
moving_image: PathLike = field(
metadata={"help_string": "moving image", "mandatory": True, "argstr": "-i"}
)

fixed_image: PathLike = field(metadata={"help_string": "fixed image", "mandatory": True, "argstr": "-r"})
fixed_image: PathLike = field(
metadata={"help_string": "fixed image", "mandatory": True, "argstr": "-r"}
)

output_: str = field(
metadata={"help_string": "output parameter", "readonly": True, "formatter": _format_output}
metadata={
"help_string": "output parameter",
"readonly": True,
"formatter": _format_output,
}
)

output_image: str = field(
metadata={"help_string": "output image", "output_file_template": "{moving_image}_warped"}
metadata={
"help_string": "output image",
"output_file_template": "{moving_image}_warped",
}
)

save_warp_field: bool = field(metadata={"help_string": "save composite warp field"})
save_warp_field: bool = field(
metadata={"help_string": "save composite warp field"}
)

output_warp_field: str = field(
metadata={
Expand All @@ -107,7 +126,9 @@ class InputSpec(ShellSpec):
}
)

save_transform: bool = field(metadata={"help_string": "save composite transform"})
save_transform: bool = field(
metadata={"help_string": "save composite transform"}
)

output_transform: str = field(
metadata={
Expand All @@ -118,10 +139,16 @@ class InputSpec(ShellSpec):
}
)

invert_transform: bool = field(default=False, metadata={"help_string": "invert composite transform"})
invert_transform: bool = field(
default=False, metadata={"help_string": "invert composite transform"}
)

interpolation_: str = field(
metadata={"help_string": "interpolation parameter", "readonly": True, "formatter": _format_interpolation}
metadata={
"help_string": "interpolation parameter",
"readonly": True,
"formatter": _format_interpolation,
}
)

interpolator: str = field(
Expand All @@ -141,17 +168,31 @@ class InputSpec(ShellSpec):
},
)

sigma: float = field(default=1.0, metadata={"help_string": "sigma parameter interpolation"})
sigma: float = field(
default=1.0, metadata={"help_string": "sigma parameter interpolation"}
)

alpha: float = field(default=1.0, metadata={"help_string": "alpha parameter for interpolation"})
alpha: float = field(
default=1.0, metadata={"help_string": "alpha parameter for interpolation"}
)

order: int = field(default=3, metadata={"help_string": "order parameter for interpolation"})
order: int = field(
default=3, metadata={"help_string": "order parameter for interpolation"}
)

output_datatype: str = field(
metadata={
"help_string": "force output image datatype",
"argstr": "-u",
"allowed_values": {"char", "uchar", "short", "int", "float", "double", "default"},
"allowed_values": {
"char",
"uchar",
"short",
"int",
"float",
"double",
"default",
},
}
)

Expand All @@ -163,16 +204,24 @@ class InputSpec(ShellSpec):
if not input_transforms
else " ".join(f"-t {f}" for f in input_transforms)
if not invert_transforms
else " ".join(f"-t [{f},{int(i)}]" for f, i in zip(input_transforms, invert_transforms))
else " ".join(
f"-t [{f},{int(i)}]"
for f, i in zip(input_transforms, invert_transforms)
)
),
}
)

invert_transforms: Sequence[bool] = field(
metadata={"help_string": "which transforms to invert", "requires": {"input_transforms"}}
metadata={
"help_string": "which transforms to invert",
"requires": {"input_transforms"},
}
)

default_value: float = field(metadata={"help_string": "default voxel value", "argstr": "-f"})
default_value: float = field(
metadata={"help_string": "default voxel value", "argstr": "-f"}
)

use_float_precision: bool = field(
default=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ class N4BiasFieldCorrection(ShellCommandTask):
@define(kw_only=True)
class InputSpec(ShellSpec):
dimensionality: int = field(
metadata={"help_string": "image dimensionality", "argstr": "-d", "allowed_values": {2, 3, 4}}
metadata={
"help_string": "image dimensionality",
"argstr": "-d",
"allowed_values": {2, 3, 4},
}
)

input_image: PathLike = field(metadata={"help_string": "input image", "mandatory": True, "argstr": "-i"})
input_image: PathLike = field(
metadata={"help_string": "input image", "mandatory": True, "argstr": "-i"}
)

mask_image: PathLike = field(metadata={"help_string": "mask image", "argstr": "-x"})
mask_image: PathLike = field(
metadata={"help_string": "mask image", "argstr": "-x"}
)

rescale_intensities: bool = field(
default=True,
Expand All @@ -37,9 +45,13 @@ class InputSpec(ShellSpec):
},
)

weight_image: PathLike = field(metadata={"help_string": "weight image", "argstr": "-w"})
weight_image: PathLike = field(
metadata={"help_string": "weight image", "argstr": "-w"}
)

shrink_factor: int = field(default=4, metadata={"help_string": "shrink factor", "argstr": "-s"})
shrink_factor: int = field(
default=4, metadata={"help_string": "shrink factor", "argstr": "-s"}
)

bspline_fitting_: str = field(
metadata={
Expand All @@ -49,7 +61,9 @@ class InputSpec(ShellSpec):
}
)

spline_distance: float = field(default=200, metadata={"help_string": "spline distance"})
spline_distance: float = field(
default=200, metadata={"help_string": "spline distance"}
)

spline_order: int = field(default=3, metadata={"help_string": "spline order"})

Expand All @@ -58,7 +72,9 @@ class InputSpec(ShellSpec):
"help_string": "convergence parameters",
"readonly": True,
"formatter": lambda num_iterations, threshold: (
"-c [{},{}]".format("x".join(str(i) for i in num_iterations), threshold)
"-c [{},{}]".format(
"x".join(str(i) for i in num_iterations), threshold
)
),
}
)
Expand All @@ -67,7 +83,9 @@ class InputSpec(ShellSpec):
default=(50, 50, 50, 50), metadata={"help_string": "number of iterations"}
)

threshold: float = field(default=0.0, metadata={"help_string": "convergence threshold"})
threshold: float = field(
default=0.0, metadata={"help_string": "convergence threshold"}
)

histogram_sharpening_: str = field(
metadata={
Expand All @@ -77,30 +95,46 @@ class InputSpec(ShellSpec):
}
)

bias_field_fwhm: float = field(default=0.15, metadata={"help_string": "Bias field FWHM"})
bias_field_fwhm: float = field(
default=0.15, metadata={"help_string": "Bias field FWHM"}
)

wiener_filter_noise: float = field(default=0.01, metadata={"help_string": "Wiener filter noise"})
wiener_filter_noise: float = field(
default=0.01, metadata={"help_string": "Wiener filter noise"}
)

num_histogram_bins: int = field(default=200, metadata={"help_string": "number of histogram bins"})
num_histogram_bins: int = field(
default=200, metadata={"help_string": "number of histogram bins"}
)

output_ = field(
metadata={
"help_string": "output parameters",
"readonly": True,
"formatter": lambda output_image, save_bias_field, output_bias_field: (
f"-o [{output_image},{output_bias_field}]" if save_bias_field else f"-o {output_image}"
f"-o [{output_image},{output_bias_field}]"
if save_bias_field
else f"-o {output_image}"
),
}
)

output_image: str = field(
metadata={"help_string": "output image", "output_file_template": "{input_image}_corrected"}
metadata={
"help_string": "output image",
"output_file_template": "{input_image}_corrected",
}
)

save_bias_field: bool = field(default=False, metadata={"help_string": "save bias field"})
save_bias_field: bool = field(
default=False, metadata={"help_string": "save bias field"}
)

output_bias_field: str = field(
metadata={"help_string": "output bias field", "output_file_template": "{input_image}_biasfield"}
metadata={
"help_string": "output bias field",
"output_file_template": "{input_image}_biasfield",
}
)

input_spec = SpecInfo(name="Input", bases=(InputSpec,))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,28 @@ class CreateJacobianDeterminantImage(ShellCommandTask):
@define(kw_only=True)
class InputSpec(ShellSpec):
dimensionality: int = field(
metadata={"help_string": "image dimensionality", "mandatory": True, "argstr": "", "allowed_values": {2, 3}}
metadata={
"help_string": "image dimensionality",
"mandatory": True,
"argstr": "",
"allowed_values": {2, 3},
}
)

warp_field: PathLike = field(metadata={"help_string": "displacement field", "mandatory": True, "argstr": ""})
warp_field: PathLike = field(
metadata={
"help_string": "displacement field",
"mandatory": True,
"argstr": "",
}
)

output_image: str = field(
metadata={"help_string": "output image", "argstr": "", "output_file_template": "{warp_field}_jac"}
metadata={
"help_string": "output image",
"argstr": "",
"output_file_template": "{warp_field}_jac",
}
)

calculate_log_jacobian: bool = field(
Expand Down
Loading

0 comments on commit 0e423bd

Please sign in to comment.