-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added source dimension order, split functionality between Zarr and Om…
…eZarr as write-only classes, fixed ome zarr channel metadata
- Loading branch information
Showing
8 changed files
with
150 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
def create_axes_metadata(dimension_order): | ||
axes = [] | ||
for dimension in dimension_order: | ||
unit1 = None | ||
if dimension == 't': | ||
type1 = 'time' | ||
unit1 = 'millisecond' | ||
elif dimension == 'c': | ||
type1 = 'channel' | ||
else: | ||
type1 = 'space' | ||
unit1 = 'micrometer' | ||
axis = {'name': dimension, 'type': type1} | ||
if unit1 is not None and unit1 != '': | ||
axis['unit'] = unit1 | ||
axes.append(axis) | ||
return axes | ||
|
||
|
||
def create_transformation_metadata(dimension_order, pixel_size_um, scale): | ||
pixel_size_scale = [] | ||
for dimension in dimension_order: | ||
if dimension == 'z': | ||
pixel_size_scale1 = pixel_size_um[2] | ||
elif dimension == 'y': | ||
pixel_size_scale1 = pixel_size_um[1] / scale | ||
elif dimension == 'x': | ||
pixel_size_scale1 = pixel_size_um[0] / scale | ||
else: | ||
pixel_size_scale1 = 1 | ||
if pixel_size_scale1 == 0: | ||
pixel_size_scale1 = 1 | ||
pixel_size_scale.append(pixel_size_scale1) | ||
return [{'scale': pixel_size_scale, 'type': 'scale'}] | ||
|
||
|
||
def create_channel_metadata(source): | ||
channels = [] | ||
for channeli, channel0 in enumerate(source.get_channels()): | ||
channel = {'label': channel0.get('Name', '')} | ||
color = channel0.get('Color') | ||
if color is None: | ||
color = 'FFFFFF' | ||
elif isinstance(color, str): | ||
# int value as string; convert | ||
color = int(color) | ||
if not isinstance(color, str): | ||
color = hex(color & 0xFFFFFF)[2:].upper().zfill(6) | ||
channel['color'] = color | ||
if not 'window' in channel: | ||
start, end, min, max = source.get_min_max(channeli) | ||
channel['window'] = {'start': start, 'end': end, 'min': min, 'max': max} | ||
channels.append(channel) | ||
|
||
metadata = { | ||
'version': '0.4', | ||
'channels': channels, | ||
} | ||
return metadata | ||
|
||
|
||
def calc_shape_scale(shape0, dimension_order, scale): | ||
shape = [] | ||
if scale == 1: | ||
return shape0 | ||
for shape1, dimension in zip(shape0, dimension_order): | ||
if dimension in ['x', 'y']: | ||
shape1 = int(round(shape1 / scale)) | ||
shape.append(shape1) | ||
return shape |
Oops, something went wrong.