diff --git a/aicsimageio/readers/lif_reader.py b/aicsimageio/readers/lif_reader.py index b52ed6c74..189a739f0 100644 --- a/aicsimageio/readers/lif_reader.py +++ b/aicsimageio/readers/lif_reader.py @@ -380,6 +380,12 @@ def _get_coords_and_physical_px_sizes( # Unpack short info scales scale_x, scale_y, scale_z, scale_t = image_short_info["scale"] + # Scales from readlif are returned as px/µm + # We want to return as µm/px + scale_x = 1 / scale_x if scale_x is not None else None + scale_y = 1 / scale_y if scale_y is not None else None + scale_z = 1 / scale_z if scale_z is not None else None + # Handle Spatial Dimensions if scale_z is not None: coords[DimensionNames.SpatialZ] = Reader._generate_coord_array( @@ -596,6 +602,9 @@ def _construct_mosaic_xarray(self, data: types.ArrayLike) -> xr.DataArray: # Add expanded Y and X coords scale_x, scale_y, _, _ = selected_scene.info["scale"] + scale_x = 1 / scale_x if scale_x is not None else None + scale_y = 1 / scale_y if scale_y is not None else None + if scale_y is not None: coords[DimensionNames.SpatialY] = Reader._generate_coord_array( 0, stitched.shape[-2], scale_y diff --git a/aicsimageio/tests/readers/test_lif_reader.py b/aicsimageio/tests/readers/test_lif_reader.py index 055de76b8..6ee51740e 100644 --- a/aicsimageio/tests/readers/test_lif_reader.py +++ b/aicsimageio/tests/readers/test_lif_reader.py @@ -37,7 +37,7 @@ np.uint16, dimensions.DEFAULT_DIMENSION_ORDER, ["Gray--TL-BF--EMP_BF", "Green--FLUO--GFP"], - (None, 3.076923076923077, 3.076923076923077), + (None, 0.32499999999999996, 0.32499999999999996), ), ( "s_1_t_4_c_2_z_1.lif", @@ -47,7 +47,7 @@ np.uint16, dimensions.DEFAULT_DIMENSION_ORDER, ["Gray--TL-PH--EMP_BF", "Green--FLUO--GFP"], - (None, 2.9485556406398508, 2.9485556406398508), + (None, 0.33914910277324634, 0.33914910277324634), ), ( "tiled.lif", @@ -57,7 +57,7 @@ np.uint8, dimensions.DEFAULT_DIMENSION_ORDER_WITH_MOSAIC_TILES, ["Gray", "Red", "Green", "Cyan"], - (None, 4.984719055966396, 4.984719055966396), + (None, 0.20061311154598827, 0.20061311154598827), ), pytest.param( "example.txt", @@ -306,10 +306,10 @@ def test_lif_reader_mosaic_tile_inspection( [ ( "tiled.lif", - np.arange(0, 2552.176156654795, 4.984719055966396), - np.arange(0, 2552.176156654795, 4.984719055966396), - np.arange(0, 28024.09053264308, 4.984719055966396), - np.arange(0, 38212.85628303839, 4.984719055966396), + np.arange(0, 102.71391311154599, 0.20061311154598827), + np.arange(0, 102.71391311154599, 0.20061311154598827), + np.arange(0, 1127.846913111546, 0.20061311154598827), + np.arange(0, 1537.900113111546, 0.20061311154598827), ), ], ) diff --git a/aicsimageio/tests/test_aics_image.py b/aicsimageio/tests/test_aics_image.py index 510769413..9601eac18 100644 --- a/aicsimageio/tests/test_aics_image.py +++ b/aicsimageio/tests/test_aics_image.py @@ -168,7 +168,7 @@ np.uint16, dimensions.DEFAULT_DIMENSION_ORDER, ["Gray--TL-PH--EMP_BF", "Green--FLUO--GFP"], - (None, 2.9485556406398508, 2.9485556406398508), + (None, 0.33914910277324634, 0.33914910277324634), ET.Element, ), ( @@ -179,7 +179,7 @@ np.uint8, dimensions.DEFAULT_DIMENSION_ORDER, ["Gray", "Red", "Green", "Cyan"], - (None, 4.984719055966396, 4.984719055966396), + (None, 0.20061311154598827, 0.20061311154598827), ET.Element, ), #######################################################################