Skip to content

Commit

Permalink
Merge branch '797-improve-type-hints-and-docstring-for-calculate_regi…
Browse files Browse the repository at this point in the history
…stration_image_based' into tmp-remove-anyof-from-pydantic-v2-schema
  • Loading branch information
tcompa committed Jul 16, 2024
2 parents 1525513 + e756599 commit 197ff1b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
* Tasks:
* Fix issue with masked ROI & relabeling in Cellpose task (\#785).
* Fix issue with masking ROI label types in masked_loading_wrapper for Cellpose task (\#785).
* Fix issue with masking ROI label types in `masked_loading_wrapper` for Cellpose task (\#785).
* Enable workaround to support yx images in Cellpose task (\#789).
* Fix error handling in `calculate_registration_image_based` (\#799).
* Fix minor issues with call-signature and type hints in `calculate_registration_image_based` (\#799).

* Development:
* Switch all core models to pydantic v2 (\#790).
* Enable workaround to support yx images in Cellpose task (\#789).

# 1.1.0

Expand All @@ -23,7 +27,7 @@
* Rename `task.cellpose_transforms` into `tasks.cellpose_utils` (\#738).
* Fix wrong repeated overlap checks for bounding-boxes in Cellpose task (\#778).
* Fix minor MIP issues related to plate metadata and expecting acquisition metadata in all NGFF plates(\#781).
* Add chi2_shift option to Calculate Registration (image-based) task(\#741).
* Add `chi2_shift` option to Calculate Registration (image-based) task(\#741).
* Development:
* Switch to transitional pydantic.v1 imports, changes pydantic requirement to `==1.10.16` or `>=2.6.3` (\#760).
* Support JSON-Schema generation for `Enum` task arguments (\#749).
Expand Down
2 changes: 1 addition & 1 deletion fractal_tasks_core/__FRACTAL_MANIFEST__.json
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@
},
"RegistrationMethod": {
"title": "RegistrationMethod",
"description": "An enumeration.",
"description": "RegistrationMethod Enum class",
"enum": [
"phase_cross_correlation",
"chi2_shift"
Expand Down
20 changes: 15 additions & 5 deletions fractal_tasks_core/tasks/calculate_registration_image_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@


class RegistrationMethod(Enum):
"""
RegistrationMethod Enum class
Attributes:
PHASE_CROSS_CORRELATION: phase cross correlation based on scikit-image
(works with 2D & 3D images).
CHI2_SHIFT: chi2 shift based on image-registration library
(only works with 2D images).
"""

PHASE_CROSS_CORRELATION = "phase_cross_correlation"
CHI2_SHIFT = "chi2_shift"

Expand All @@ -66,7 +76,7 @@ def calculate_registration_image_based(
init_args: InitArgsRegistration,
# Core parameters
wavelength_id: str,
method: RegistrationMethod = "phase_cross_correlation",
method: RegistrationMethod = RegistrationMethod.PHASE_CROSS_CORRELATION,
roi_table: str = "FOV_ROI_table",
level: int = 2,
) -> None:
Expand Down Expand Up @@ -137,11 +147,11 @@ def calculate_registration_image_based(
# Check if data is 3D (as not all registration methods work in 3D)
# TODO: Abstract this check into a higher-level Zarr loading class
if is_3D(data_reference_zyx):
if method == "chi2_shift":
if method == RegistrationMethod(RegistrationMethod.CHI2_SHIFT):
raise ValueError(
"The `chi2_shift` registration method has not been "
"implemented for 3D images and the input image had a shape of "
f"{data_reference_zyx.shape}."
f"The `{RegistrationMethod.CHI2_SHIFT}` registration method "
"has not been implemented for 3D images and the input image "
f"had a shape of {data_reference_zyx.shape}."
)

# Read ROIs
Expand Down

0 comments on commit 197ff1b

Please sign in to comment.