diff --git a/brainglobe_utils/image_io/save.py b/brainglobe_utils/image_io/save.py index 613b805..2115f07 100644 --- a/brainglobe_utils/image_io/save.py +++ b/brainglobe_utils/image_io/save.py @@ -58,7 +58,12 @@ def to_tiff(img_volume, dest_path, photometric="minisblack"): Use 'minisblack' (default) for grayscale and 'rgb' for rgb """ dest_path = Path(dest_path) - tifffile.imwrite(dest_path, img_volume, photometric=photometric) + tifffile.imwrite( + dest_path, + img_volume, + photometric=photometric, + metadata={"axes": "ZYX"}, + ) def to_tiffs(img_volume, path_prefix, path_suffix="", extension=".tif"): diff --git a/tests/tests/test_image_io.py b/tests/tests/test_image_io.py index e720cd5..0f38c39 100644 --- a/tests/tests/test_image_io.py +++ b/tests/tests/test_image_io.py @@ -350,6 +350,19 @@ def test_image_size_dir(tmp_path, array_3d): assert image_shape["z"] == array_3d.shape[0] +def test_image_size_tiff_stack(tmp_path, array_3d): + """ + Test that image size can be detected from a directory of 2D tiffs + """ + filename = tmp_path.joinpath("image_size_tiff_stack.tif") + save.save_any(array_3d, filename) + + image_shape = load.get_size_image_from_file_paths(filename) + assert image_shape["x"] == array_3d.shape[2] + assert image_shape["y"] == array_3d.shape[1] + assert image_shape["z"] == array_3d.shape[0] + + def test_image_size_txt(txt_path, array_3d): """ Test that image size can be detected from a text file containing the paths