Skip to content

Commit

Permalink
added more defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthakpati committed Mar 31, 2024
1 parent ff0165b commit 65414d2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ereg/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ def register(
sitk.WriteTransform(self.transform, transform_file)

# apply composite transform if provided
self.parameters["composite_transform"] = self.parameters.get(
"composite_transform", None
)
if self.parameters["composite_transform"] is not None:
self.logger.info("Applying composite transform.")
transform_composite = sitk.ReadTransform(
Expand Down Expand Up @@ -256,7 +259,8 @@ def resample_image(
resampler = sitk.ResampleImageFilter()
resampler.SetReferenceImage(target_image)
interpolator_type = self.interpolator_type.get(
self.parameters["interpolator"]
self.parameters.get("interpolator", "linear").lower(),
sitk.sitkLinear,
)
resampler.SetInterpolator(interpolator_type)
resampler.SetDefaultPixelValue(0)
Expand Down Expand Up @@ -389,6 +393,7 @@ def _register_image_and_get_transform(

self.logger.info("Initializing registration.")
R = sitk.ImageRegistrationMethod()
self.parameters["metric_parameters"] = self.parameters.get("metric_parameters", {})
metric = (
self.parameters["metric_parameters"].get("type", "mean_squares").lower()
)
Expand Down Expand Up @@ -445,7 +450,7 @@ def _register_image_and_get_transform(
self.parameters.get("sampling_strategy", "random").lower()
]
)
R.SetMetricSamplingPercentagePerLevel(self.parameters["sampling_percentage"])
R.SetMetricSamplingPercentagePerLevel(self.parameters.get("sampling_percentage", 0.01)))

self.parameters["optimizer_parameters"] = self.parameters.get(
"optimizer_parameters", {}
Expand Down

0 comments on commit 65414d2

Please sign in to comment.