Skip to content

Commit

Permalink
Minor: default dimension_order for render
Browse files Browse the repository at this point in the history
  • Loading branch information
folterj committed Mar 4, 2024
1 parent 8259aeb commit a971034
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 3 additions & 1 deletion OmeSliCC/OmeSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ def get_channel_window(self, channeli):
min, max = start, end
return {'start': start, 'end': end, 'min': min, 'max': max}

def render(self, image: np.ndarray, source_dimension_order: str, t: int = 0, z: int = 0, channels: list = []) -> np.ndarray:
def render(self, image: np.ndarray, source_dimension_order: str = None, t: int = 0, z: int = 0, channels: list = []) -> np.ndarray:
if source_dimension_order is None:
source_dimension_order = self.get_dimension_order()
image = redimension_data(image, source_dimension_order, 'yxc', t=t, z=z)
new_image = np.zeros(list(image.shape[:2]) + [3], dtype=np.float32)
tot_alpha = 0
Expand Down
16 changes: 7 additions & 9 deletions tests/conversion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def load_as_zarr_um(path, x0_um, x1_um, y0_um, y1_um):
source = TiffSource(path)
data = source.asarray_um(x0=x0_um, x1=x1_um, y0=y0_um, y1=y1_um)
image = np.asarray(data)
image = source.render(image, source.get_dimension_order())
image = source.render(image)
show_image(image)


Expand Down Expand Up @@ -58,43 +58,41 @@ def generated_conversion_test():

def check_large_tiff_arrays(input):
source = TiffSource(input, target_pixel_size=[(10, 'um')])
dimension_order = source.get_dimension_order()
image = source.render(source.asarray(), dimension_order)
image = source.render(source.asarray())
x, y = source.get_size()
show_image(image)
tile = source.render(source.asarray(x0=x//2, x1=x//2+1000, y0=y//2, y1=y//2+1000), dimension_order)
tile = source.render(source.asarray(x0=x//2, x1=x//2+1000, y0=y//2, y1=y//2+1000))
show_image(tile)
tile = source.render(source.asarray(x0=x//2, x1=x//2+1000, y0=y//2, y1=y//2+1000, pixel_size=[10]), dimension_order)
tile = source.render(source.asarray(x0=x//2, x1=x//2+1000, y0=y//2, y1=y//2+1000, pixel_size=[10]))
show_image(tile)


def check_cached_loading(path):
source = TiffSource(path)
dimension_order = source.get_dimension_order()
pixel_size = [1]
x, y = np.array(source.get_size()) * source.get_pixel_size_micrometer() / pixel_size / 2

print('Read as dask')
start = time.process_time()
source._load_as_dask()
print(f'Load process time:', time.process_time() - start)
data = source.render(source.asarray(x0=x, x1=x+100, y0=y, y1=y+100, pixel_size=pixel_size), dimension_order)
data = source.render(source.asarray(x0=x, x1=x+100, y0=y, y1=y+100, pixel_size=pixel_size))
show_image(data)
random_access_test(source, n=100)

print('Read compressed')
start = time.process_time()
source.load()
print(f'Load process time:', time.process_time() - start)
data = source.render(source.asarray(x0=x, x1=x+100, y0=y, y1=y+100, pixel_size=pixel_size), dimension_order)
data = source.render(source.asarray(x0=x, x1=x+100, y0=y, y1=y+100, pixel_size=pixel_size))
show_image(data)
random_access_test(source, n=100)

print('Read decompressed')
start = time.process_time()
source.load(decompress=True)
print(f'Load process time:', time.process_time() - start)
data = source.render(source.asarray(x0=x, x1=x+100, y0=y, y1=y+100, pixel_size=pixel_size), dimension_order)
data = source.render(source.asarray(x0=x, x1=x+100, y0=y, y1=y+100, pixel_size=pixel_size))
show_image(data)
random_access_test(source, n=100)

Expand Down

0 comments on commit a971034

Please sign in to comment.