Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ def test_analysis_recompute_after_roi_change():
with datalab_test_app_context(console=False) as win:
panel = win.imagepanel

# Create a 2D Gaussian image in a 200x200 image
# Create a 2D Gaussian image in a 200x200 image (pixel coordinates, as
# the ROIs and expected centroids below)
size = 200
param = Gauss2DParam.create(height=size, width=size, sigma=20)
param = Gauss2DParam.create(
height=size, width=size, sigma=20, physical_coords=False
)
img = create_image_from_param(param)
panel.add_object(img)

Expand Down Expand Up @@ -202,10 +205,12 @@ def test_analysis_recompute_after_recompute_1_to_1():
size = 200
# In Gauss2DParam, x0 and y0 are the center coordinates with Xmin=-10.0,
# Ymin=-10.0, Xmax=10.0, Ymax=10.0 by default.
# The centroid position should be at (49.75, 99.5).
# The centroid position should be at (49.75, 99.5) in pixel coordinates.
# After a 45° rotation, it should move closer to (64.32, 134.68).
# Or after a 90° rotation, it should move to (99.5, 149.2).
param = Gauss2DParam.create(height=size, width=size, x0=-5.0)
param = Gauss2DParam.create(
height=size, width=size, x0=-5.0, physical_coords=False
)
img = create_image_from_param(param)
panel.add_object(img)

Expand Down
43 changes: 43 additions & 0 deletions datalab/tests/features/common/creation_metadata_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
PEAK_PARAMETERIZATION,
GaussParam,
SineParam,
SinusoidalGrating2DParam,
create_image,
create_signal,
)
from sigima.tools.signal.pulse import GaussianModel, LegacyPeakParameterizationError

from datalab.gui.creation import create_image_from_param
from datalab.gui.newobject import (
CREATION_PARAMETERS_FORMAT_VERSION,
CREATION_PARAMETERS_OPTION,
Expand All @@ -26,6 +29,7 @@
extract_creation_parameters,
insert_creation_parameters,
)
from datalab.history.core import decode_kwargs


def _legacy_gaussian_json(
Expand Down Expand Up @@ -117,3 +121,42 @@ def test_creation_parameter_formats_never_fall_back_implicitly() -> None:
obj.set_metadata_option(LEGACY_CREATION_PARAMETERS_OPTION, _legacy_gaussian_json())
with pytest.raises(ValueError, match="Conflicting creation parameter formats"):
extract_creation_parameters(obj)


def test_domain_image_creation_parameters_keep_their_coordinates() -> None:
"""Images created before the "Physical coordinates" option stay in pixels.

Recreating an image from creation parameters stored by DataLab 1.3 (without
the option) must give back the original pixel coordinates, while parameters
stored by this version are restored as they were.
"""
param = SinusoidalGrating2DParam.create(height=16, width=32)
image = create_image_from_param(param)
assert (image.x0, image.dx) == (param.xmin, (param.xmax - param.xmin) / 31)
restored = extract_creation_parameters(image)
assert isinstance(restored, SinusoidalGrating2DParam)
assert restored.physical_coords is True

payload = json.loads(dataset_to_json(param))
del payload["physical_coords"]
legacy = create_image("Legacy grating", np.zeros((16, 32)))
legacy.set_metadata_option(
CREATION_PARAMETERS_OPTION,
{
"format_version": CREATION_PARAMETERS_FORMAT_VERSION,
"dataset_json": json.dumps(payload),
},
)
legacy_param = extract_creation_parameters(legacy)
assert isinstance(legacy_param, SinusoidalGrating2DParam)
assert legacy_param.physical_coords is False
recreated = create_image_from_param(legacy_param)
assert (recreated.x0, recreated.y0, recreated.dx, recreated.dy) == (
0.0,
0.0,
1.0,
1.0,
)

history_kwargs = decode_kwargs({"param": {"__dataset_json__": json.dumps(payload)}})
assert history_kwargs["param"].physical_coords is False
2 changes: 2 additions & 0 deletions datalab/tests/features/image/geometry_transform_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

def __create_test_image() -> sio.ImageObj:
"""Create a test image with geometry results for testing."""
# Geometry results and ROI below are defined in pixel coordinates
param = sio.Gauss2DParam.create(
height=600,
width=600,
x0=2.5,
y0=7.5,
title="Test image (with geometry results)",
dtype=sio.ImageDatatypes.UINT16,
physical_coords=False,
)
obj = sio.create_image_from_param(param)
for geometry in test_data.generate_geometry_results():
Expand Down
12 changes: 12 additions & 0 deletions doc/locale/fr/LC_MESSAGES/release_notes/release_1.03.po
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ msgstr ""
msgid "Version 1.3"
msgstr "Version 1.3"

msgid "DataLab Version 1.3.1"
msgstr "DataLab Version 1.3.1"

msgid "🔧 Improvements since version 1.3.0"
msgstr "🔧 Améliorations depuis la version 1.3.0"

msgid "**Compatibility:**"
msgstr "**Compatibilité :**"

msgid "Updated minimum Sigima requirement from 1.2.0 to 1.3.0: Gaussian, 2D ramp, sinusoidal grating, ring pattern, Siemens star and 2D sinc images are now created in physical coordinates (over their [x<sub>min</sub>, x<sub>max</sub>] × [y<sub>min</sub>, y<sub>max</sub>] domain) instead of pixel coordinates, unless the new \"Physical coordinates\" option is disabled. Images created with earlier versions keep their pixel coordinates when they are recreated"
msgstr "Mise à jour de la version minimale requise de Sigima de 1.2.0 à 1.3.0 : les images gaussienne, rampe 2D, réseau sinusoïdal, anneaux, étoile de Siemens et sinus cardinal 2D sont désormais créées en coordonnées physiques (sur leur domaine [x<sub>min</sub>, x<sub>max</sub>] × [y<sub>min</sub>, y<sub>max</sub>]) au lieu de coordonnées en pixels, sauf si la nouvelle option « Coordonnées physiques » est désactivée. Les images créées avec des versions antérieures conservent leurs coordonnées en pixels lorsqu'elles sont recréées"

msgid "DataLab Version 1.3.0"
msgstr "DataLab Version 1.3.0"

Expand Down
8 changes: 8 additions & 0 deletions doc/release_notes/release_1.03.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Version 1.3 #

## DataLab Version 1.3.1 ##

### 🔧 Improvements since version 1.3.0 ###

**Compatibility:**

* Updated minimum Sigima requirement from 1.2.0 to 1.3.0: Gaussian, 2D ramp, sinusoidal grating, ring pattern, Siemens star and 2D sinc images are now created in physical coordinates (over their [x<sub>min</sub>, x<sub>max</sub>] × [y<sub>min</sub>, y<sub>max</sub>] domain) instead of pixel coordinates, unless the new "Physical coordinates" option is disabled. Images created with earlier versions keep their pixel coordinates when they are recreated

## DataLab Version 1.3.0 ##

### ✨ New Features ###
Expand Down
2 changes: 1 addition & 1 deletion doc/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The `datalab-platform` package requires the following Python modules:
- >= 2.11.0
- Curve and image plotting tools for Python/Qt applications
* - Sigima
- >= 1.2.0
- >= 1.3.0
- Scientific computing engine for 1D signals and 2D images, part of the DataLab open-source platform.
* - SigimaX
- >= 1.0.2
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ requires-python = ">=3.9, <4"
dependencies = [
"guidata >= 3.15.1",
"PlotPy >= 2.11.0",
"Sigima >= 1.2.0",
"Sigima >= 1.3.0",
"SigimaX >= 1.0.2",
"NumPy >= 1.22, < 2.5",
"SciPy >= 1.10.1, < 1.17",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PlotPy >= 2.11.0
PyQt5 >= 5.15.6
PyWavelets >= 1.2, < 2.0
SciPy >= 1.10.1, < 1.17
Sigima >= 1.2.0
Sigima >= 1.3.0
SigimaX >= 1.0.2
babel
build
Expand Down
Loading