Skip to content

Commit

Permalink
allow no axis metadata for 3D tiff files
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrofelder committed May 3, 2024
1 parent befb748 commit ed40e38
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions brainglobe_utils/image_io/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,15 +698,28 @@ def get_size_image_from_file_paths(file_path, file_extension="tif"):

shape = tiff.series[0].shape
axes = tiff.series[0].axes.lower()
# axes is e.g. "zxy"
if set(axes) != {"x", "y", "z"}:

if len(shape) != 3:
raise ValueError(
f"Attempted to load {file_path} but didn't find a "
f"xyz-stack. Found {axes} axes with shape {shape}"
f"3-dimensional stack. Found {axes} axes "
f"with shape {shape}"
)

image_shape = {ax: n for ax, n in zip(axes, shape)}
return image_shape
# axes is e.g. "zxy"
if set(axes) == {"x", "y", "z"}:
image_shape = {ax: n for ax, n in zip(axes, shape)}
return image_shape
else: # metadata does not specify axes as expected,
logging.debug(
f"Axis metadata is {axes}, "
"which is not the expected set of x,y,z in any order. "
"Assume z,y,x"
)
image_shape = {
ax: n
for ax, n in zip(["z", "y", "x"], tiff.series[0].shape)
}
return image_shape

img_paths = get_sorted_file_paths(file_path, file_extension=file_extension)
z_shape = len(img_paths)
Expand Down

0 comments on commit ed40e38

Please sign in to comment.