Skip to content

Commit 07e146d

Browse files
authored
Merge pull request #33 from ChengLabResearch/main
Merge in tiff read fix
2 parents 3ad1b53 + abf89d1 commit 07e146d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

python/ouroboros/pipeline/backproject_pipeline.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,18 @@ def _process(self, input_data: any) -> tuple[any, None] | tuple[None, any]:
9696
is_compressed = bool(tif.pages[0].compression)
9797
FPShape = FrontProjStack(D=len(tif.pages), V=tif.pages[0].shape[0], U=tif.pages[0].shape[1])
9898

99-
if is_compressed:
99+
cannot_memmap = False
100+
try:
101+
if Path(straightened_volume_path).is_dir():
102+
_ = tifffile.memmap(next(Path(straightened_volume_path).iterdir()), mode="r")
103+
else:
104+
_ = tifffile.memmap(straightened_volume_path, mode="r")
105+
except: # noqa: E722
106+
# Check here is because memmap needs certain types of dataoffsets, which aren't always there
107+
# separate to compression.
108+
cannot_memmap = True
109+
110+
if is_compressed or cannot_memmap:
100111
print("Input data compressed; Rewriting.")
101112

102113
# Create a new path for the straightened volume

0 commit comments

Comments
 (0)