Skip to content

Commit 6941f0b

Browse files
committed
Read/write with imageio
1 parent 8681745 commit 6941f0b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

scripts/augmentation/affine_transform.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from scipy.spatial.transform import Rotation as R
1313
from scipy.spatial import ConvexHull
1414

15-
from tifffile import tifffile
15+
import imageio.v3 as imageio
1616

1717
# https://github.com/mrirecon/dl-segmentation-realtime-cmr/blob/main/scripts/assess_dl_seg_utils.py
1818
def mask_from_polygon_mplt(coordinates:list, img_shape:list):
@@ -132,7 +132,7 @@ def read_tif_stack(file):
132132
"""
133133
Read stack of TIF files.
134134
"""
135-
images = tifffile.imread(file)
135+
images = imageio.imread(file)
136136
images = np.transpose(images, (1,2,0))
137137
return images
138138

@@ -266,7 +266,7 @@ def main(input_file, dir_out, scale, ex, ey, ez, make_convex):
266266
save_images = os.path.join(dir_out, basename + "_affExyz" + str(int(ex)).zfill(2) + str(int(ey)).zfill(2) + str(int(ez)).zfill(2) + ".tif")
267267

268268
array_out = np.transpose(images_aff, (2,0,1))
269-
tifffile.imwrite(save_images, array_out)
269+
imageio.imwrite(save_images, array_out, compression="zlib")
270270

271271
#---Labels---
272272
if label_path != "":
@@ -286,7 +286,7 @@ def main(input_file, dir_out, scale, ex, ey, ez, make_convex):
286286
save_labels = os.path.join(dir_out, basename + "_affExyz" + str(int(ex)).zfill(2) + str(int(ey)).zfill(2) + str(int(ez)).zfill(2) + "_annotations.tif")
287287

288288
array_out = np.transpose(labels_aff, (2,0,1))
289-
tifffile.imwrite(save_labels, array_out)
289+
imageio.imwrite(save_labels, array_out, compression="zlib")
290290

291291
if __name__ == "__main__":
292292

0 commit comments

Comments
 (0)