Skip to content

Commit

Permalink
add tests for image size
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Meech committed Mar 12, 2024
1 parent 61c7caa commit 799f52e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion brainglobe_utils/image_io/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ def get_size_image_from_file_paths(file_path, file_extension="tif"):
Parameters
----------
file_path : str
File containing file_paths in a text file, or as a list.
Filepath of text file containing paths of all 2D files, or
filepath of a directory containing all 2D files.
file_extension : str, optional
Optional file extension (if a directory is passed).
Expand Down
19 changes: 19 additions & 0 deletions tests/tests/test_image_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,22 @@ def test_scale_z(array_3d):
"""
assert utils.scale_z(array_3d, 0.5).shape[0] == array_3d.shape[0] / 2
assert utils.scale_z(array_3d, 2).shape[0] == array_3d.shape[0] * 2


def test_image_size_dir(tmp_path, array_3d):
save.to_tiffs(array_3d, str(tmp_path / "image_array"))

image_shape = load.get_size_image_from_file_paths(str(tmp_path))
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(tmp_path, array_3d):
txt_filepath = tmp_path / "image.txt"
write_tiff_sequence_with_txt_file(txt_filepath, array_3d)

image_shape = load.get_size_image_from_file_paths(str(txt_filepath))
assert image_shape["x"] == array_3d.shape[2]
assert image_shape["y"] == array_3d.shape[1]
assert image_shape["z"] == array_3d.shape[0]

0 comments on commit 799f52e

Please sign in to comment.