Skip to content

Commit fdb6a74

Browse files
committed
Refactoring
1 parent 1f3edda commit fdb6a74

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

‎src/IOFunctions.py‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,13 @@ def read_tiff_tophotons(
351351
Returns:
352352
image (numpy.ndarray): The image data from the TIFF file.
353353
"""
354-
# Use skimage's imread function to read the TIFF file
355-
# specifying the 'tifffile' plugin explicitly
356-
data = np.asarray(self.read_tiff(file_path, frame=frame), dtype=np.float32)
357-
if len(data.shape) > 2:
358-
image_dims = data.shape[1:]
354+
if frame is None:
355+
raw = tifffile.imread(file_path, is_ome=False, is_mmstack=False, is_imagej=False)
359356
else:
360-
image_dims = data.shape
357+
raw = tifffile.imread(file_path, key=frame, is_ome=False, is_mmstack=False, is_imagej=False)
358+
359+
data = raw.astype(np.float32)
360+
image_dims = data.shape[1:] if len(data.shape) > 2 else data.shape
361361

362362
if type(gain_map) is not float:
363363
if image_dims != gain_map.shape:
@@ -369,17 +369,14 @@ def read_tiff_tophotons(
369369

370370
if type(gain_map) is not float:
371371
if len(data.shape) > 2:
372-
data = np.divide(
373-
np.divide(
374-
np.subtract(data, offset_map[np.newaxis, :, :]),
375-
gain_map[np.newaxis, :, :],
376-
),
377-
QE,
378-
)
372+
data -= offset_map[np.newaxis, :, :]
373+
data /= (gain_map[np.newaxis, :, :] * QE)
379374
else:
380-
data = np.divide(np.divide(np.subtract(data, offset_map), gain_map), QE)
375+
data -= offset_map
376+
data /= (gain_map * QE)
381377
else:
382-
data = np.divide(np.divide(np.subtract(data, offset_map), gain_map), QE)
378+
data -= offset_map
379+
data /= (gain_map * QE)
383380
return data
384381

385382
def write_tiff(self, volume, file_path, bit=np.uint16, pixel_size=0.11):
-216 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)