From 8c098ba6d481259e7dfd897e0a1cdbf196aa1fe3 Mon Sep 17 00:00:00 2001 From: Tommaso Comparin <3862206+tcompa@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:59:03 +0200 Subject: [PATCH 1/7] Add docstring for `RegistrationMethod` --- .../tasks/calculate_registration_image_based.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fractal_tasks_core/tasks/calculate_registration_image_based.py b/fractal_tasks_core/tasks/calculate_registration_image_based.py index 6ef209208..0737acb74 100755 --- a/fractal_tasks_core/tasks/calculate_registration_image_based.py +++ b/fractal_tasks_core/tasks/calculate_registration_image_based.py @@ -48,6 +48,14 @@ class RegistrationMethod(Enum): + """ + RegistrationMethod Enum class + + Attributes: + PHASE_CROSS_CORRELATION: `phase_cross_correlation` + CHI2_SHIFT: `chi2_shift` + """ + PHASE_CROSS_CORRELATION = "phase_cross_correlation" CHI2_SHIFT = "chi2_shift" From 41bab92529b1b1598e556d7fc7c4b8bc74306afd Mon Sep 17 00:00:00 2001 From: Tommaso Comparin <3862206+tcompa@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:08:05 +0200 Subject: [PATCH 2/7] Improve docstring and default value for `calculate_registration_image_based` --- .../tasks/calculate_registration_image_based.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fractal_tasks_core/tasks/calculate_registration_image_based.py b/fractal_tasks_core/tasks/calculate_registration_image_based.py index 0737acb74..f0c0c8098 100755 --- a/fractal_tasks_core/tasks/calculate_registration_image_based.py +++ b/fractal_tasks_core/tasks/calculate_registration_image_based.py @@ -52,8 +52,8 @@ class RegistrationMethod(Enum): RegistrationMethod Enum class Attributes: - PHASE_CROSS_CORRELATION: `phase_cross_correlation` - CHI2_SHIFT: `chi2_shift` + PHASE_CROSS_CORRELATION: phase cross correlation based on scikit-image. + CHI2_SHIFT: chi2 shift based on image-registration library. """ PHASE_CROSS_CORRELATION = "phase_cross_correlation" @@ -74,7 +74,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: From 2d0d0246c2501ec0f7c317f6aa07f6452ae8b300 Mon Sep 17 00:00:00 2001 From: Tommaso Comparin <3862206+tcompa@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:15:09 +0200 Subject: [PATCH 3/7] Fix `Enum`-instance comparison (ref #798) --- .../tasks/calculate_registration_image_based.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fractal_tasks_core/tasks/calculate_registration_image_based.py b/fractal_tasks_core/tasks/calculate_registration_image_based.py index f0c0c8098..86cd3bdb2 100755 --- a/fractal_tasks_core/tasks/calculate_registration_image_based.py +++ b/fractal_tasks_core/tasks/calculate_registration_image_based.py @@ -145,11 +145,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 From 9ce3f11401ae3041682313e000aded097305255d Mon Sep 17 00:00:00 2001 From: Tommaso Comparin <3862206+tcompa@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:16:50 +0200 Subject: [PATCH 4/7] Update CHANGELOG [skip ci] --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 883895907..5b72a8649 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,10 @@ * 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). # 1.1.0 @@ -21,7 +23,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). From 87327722f21b0a1aa894b3db53692654f28eb6e6 Mon Sep 17 00:00:00 2001 From: Tommaso Comparin <3862206+tcompa@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:21:09 +0200 Subject: [PATCH 5/7] Improve `RegistrationMethod` docstring again --- .../tasks/calculate_registration_image_based.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fractal_tasks_core/tasks/calculate_registration_image_based.py b/fractal_tasks_core/tasks/calculate_registration_image_based.py index 86cd3bdb2..ce2650370 100755 --- a/fractal_tasks_core/tasks/calculate_registration_image_based.py +++ b/fractal_tasks_core/tasks/calculate_registration_image_based.py @@ -52,8 +52,10 @@ class RegistrationMethod(Enum): RegistrationMethod Enum class Attributes: - PHASE_CROSS_CORRELATION: phase cross correlation based on scikit-image. - CHI2_SHIFT: chi2 shift based on image-registration library. + 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" From f40116aedd211dac4a1b6d3eea3dbbb7734b1e86 Mon Sep 17 00:00:00 2001 From: Tommaso Comparin <3862206+tcompa@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:21:27 +0200 Subject: [PATCH 6/7] Update manifest --- fractal_tasks_core/__FRACTAL_MANIFEST__.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fractal_tasks_core/__FRACTAL_MANIFEST__.json b/fractal_tasks_core/__FRACTAL_MANIFEST__.json index 48c193b4d..824f18e3a 100644 --- a/fractal_tasks_core/__FRACTAL_MANIFEST__.json +++ b/fractal_tasks_core/__FRACTAL_MANIFEST__.json @@ -1076,7 +1076,7 @@ }, "RegistrationMethod": { "title": "RegistrationMethod", - "description": "An enumeration.", + "description": "RegistrationMethod Enum class", "enum": [ "phase_cross_correlation", "chi2_shift" From e75659973284e041d09706bac629f154959ca1c7 Mon Sep 17 00:00:00 2001 From: Tommaso Comparin <3862206+tcompa@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:23:23 +0200 Subject: [PATCH 7/7] Fix docstring indentation --- .../tasks/calculate_registration_image_based.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fractal_tasks_core/tasks/calculate_registration_image_based.py b/fractal_tasks_core/tasks/calculate_registration_image_based.py index ce2650370..d87c7d83e 100755 --- a/fractal_tasks_core/tasks/calculate_registration_image_based.py +++ b/fractal_tasks_core/tasks/calculate_registration_image_based.py @@ -53,9 +53,9 @@ class RegistrationMethod(Enum): Attributes: PHASE_CROSS_CORRELATION: phase cross correlation based on scikit-image - (works with 2D & 3D images). + (works with 2D & 3D images). CHI2_SHIFT: chi2 shift based on image-registration library - (only works with 2D images). + (only works with 2D images). """ PHASE_CROSS_CORRELATION = "phase_cross_correlation"