Skip to content

Commit dbf6d75

Browse files
authored
Merge pull request #799 from fractal-analytics-platform/797-improve-type-hints-and-docstring-for-calculate_registration_image_based
Minor fixes for `calculate_registration_image_based`
2 parents cd45cd3 + e756599 commit dbf6d75

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
* Tasks:
66
* Fix issue with masked ROI & relabeling in Cellpose task (\#785).
7-
* Fix issue with masking ROI label types in masked_loading_wrapper for Cellpose task (\#785).
7+
* Fix issue with masking ROI label types in `masked_loading_wrapper` for Cellpose task (\#785).
88
* Enable workaround to support yx images in Cellpose task (\#789).
9+
* Fix error handling in `calculate_registration_image_based` (\#799).
10+
* Fix minor issues with call-signature and type hints in `calculate_registration_image_based` (\#799).
911

1012
# 1.1.0
1113

@@ -21,7 +23,7 @@
2123
* Rename `task.cellpose_transforms` into `tasks.cellpose_utils` (\#738).
2224
* Fix wrong repeated overlap checks for bounding-boxes in Cellpose task (\#778).
2325
* Fix minor MIP issues related to plate metadata and expecting acquisition metadata in all NGFF plates(\#781).
24-
* Add chi2_shift option to Calculate Registration (image-based) task(\#741).
26+
* Add `chi2_shift` option to Calculate Registration (image-based) task(\#741).
2527
* Development:
2628
* Switch to transitional pydantic.v1 imports, changes pydantic requirement to `==1.10.16` or `>=2.6.3` (\#760).
2729
* Support JSON-Schema generation for `Enum` task arguments (\#749).

fractal_tasks_core/__FRACTAL_MANIFEST__.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@
10761076
},
10771077
"RegistrationMethod": {
10781078
"title": "RegistrationMethod",
1079-
"description": "An enumeration.",
1079+
"description": "RegistrationMethod Enum class",
10801080
"enum": [
10811081
"phase_cross_correlation",
10821082
"chi2_shift"

fractal_tasks_core/tasks/calculate_registration_image_based.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@
4848

4949

5050
class RegistrationMethod(Enum):
51+
"""
52+
RegistrationMethod Enum class
53+
54+
Attributes:
55+
PHASE_CROSS_CORRELATION: phase cross correlation based on scikit-image
56+
(works with 2D & 3D images).
57+
CHI2_SHIFT: chi2 shift based on image-registration library
58+
(only works with 2D images).
59+
"""
60+
5161
PHASE_CROSS_CORRELATION = "phase_cross_correlation"
5262
CHI2_SHIFT = "chi2_shift"
5363

@@ -66,7 +76,7 @@ def calculate_registration_image_based(
6676
init_args: InitArgsRegistration,
6777
# Core parameters
6878
wavelength_id: str,
69-
method: RegistrationMethod = "phase_cross_correlation",
79+
method: RegistrationMethod = RegistrationMethod.PHASE_CROSS_CORRELATION,
7080
roi_table: str = "FOV_ROI_table",
7181
level: int = 2,
7282
) -> None:
@@ -137,11 +147,11 @@ def calculate_registration_image_based(
137147
# Check if data is 3D (as not all registration methods work in 3D)
138148
# TODO: Abstract this check into a higher-level Zarr loading class
139149
if is_3D(data_reference_zyx):
140-
if method == "chi2_shift":
150+
if method == RegistrationMethod(RegistrationMethod.CHI2_SHIFT):
141151
raise ValueError(
142-
"The `chi2_shift` registration method has not been "
143-
"implemented for 3D images and the input image had a shape of "
144-
f"{data_reference_zyx.shape}."
152+
f"The `{RegistrationMethod.CHI2_SHIFT}` registration method "
153+
"has not been implemented for 3D images and the input image "
154+
f"had a shape of {data_reference_zyx.shape}."
145155
)
146156

147157
# Read ROIs

0 commit comments

Comments
 (0)