Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set-scale utility #228

Merged
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9e0bc16
add update_scale_metadata.py
aaronalvarezcz Jul 2, 2024
59ab2ac
add update-scale-metadata command to cli
aaronalvarezcz Jul 2, 2024
6217bad
add zyx flags for update-scale-metadata utility
aaronalvarezcz Jul 2, 2024
7bda4b3
add handling of missing zyx cli flags for update-scale-metadata
aaronalvarezcz Jul 2, 2024
953b4b9
update order of params in update_scale_metadata to be passed as z, y, x
aaronalvarezcz Jul 2, 2024
4e158d6
Merge branch 'main' into update-scale-metadata-util
talonchandler Jul 9, 2024
ea4dd73
black
talonchandler Jul 9, 2024
fdfca08
isort
talonchandler Jul 9, 2024
a5ec62f
flake8
talonchandler Jul 9, 2024
826b250
Merge branch 'main' into update-scale-metadata-util
talonchandler Sep 17, 2024
e660042
update to `iohub.ngff.models`
talonchandler Sep 17, 2024
fcc408d
move parsing utilities to iohub
talonchandler Sep 17, 2024
c8816e5
move update_scale_metadata inside cli folder
talonchandler Sep 17, 2024
2642a51
typo
talonchandler Sep 17, 2024
e0ff8e2
update import for refactor
talonchandler Sep 17, 2024
7fac9f8
require -z, -y, -x flags
talonchandler Sep 17, 2024
de5c883
simplify interface and print statements
talonchandler Sep 17, 2024
9d6492e
clean up print statement
talonchandler Sep 17, 2024
387ac59
update the last three dimensions for OME compatibility
talonchandler Sep 17, 2024
461dc65
fix tests
talonchandler Sep 17, 2024
dcb00a1
fix test
talonchandler Sep 17, 2024
37add16
helper functions for axis names
talonchandler Sep 18, 2024
6b4461d
set_scale API
talonchandler Sep 18, 2024
353ab65
consolidate and clean CLI
talonchandler Sep 18, 2024
a900763
test get_axis_index
talonchandler Sep 18, 2024
b98381f
test_set_scale
talonchandler Sep 18, 2024
74bdb7b
case insensitive axis name
talonchandler Sep 18, 2024
6b857a9
tests don't overwrite data
talonchandler Sep 18, 2024
9e6d676
save old metadata in a namespace
talonchandler Sep 19, 2024
9df8007
test multiple inputs to cli
talonchandler Sep 19, 2024
e858dc6
handle empty current_transforms
talonchandler Sep 19, 2024
75d2525
improved empty handling
talonchandler Sep 19, 2024
b46c5f3
unit test CLI plate expansion into positions
talonchandler Sep 25, 2024
d657c88
cleanup test
talonchandler Sep 25, 2024
0e3ac36
test OptionEatAll
talonchandler Sep 25, 2024
e1a04cc
stronger plate-expansion test
talonchandler Sep 25, 2024
f678f44
fix bug when scale transform does not exist
ieivanov Sep 26, 2024
a551257
create "iohub" dict if it doesn't exist, and update it
talonchandler Sep 26, 2024
b49980e
test old_* metadata
talonchandler Sep 26, 2024
bb419b2
rename old_x to prior_x_scale
ieivanov Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion iohub/ngff/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,14 @@ def set_scale(
raise ValueError("New scale must be positive.")

axis_index = self.get_axis_index(axis_name)
self.zattrs["iohub"] = {f"old_{axis_name}": self.scale[axis_index]}

# Append old scale to metadata
if "iohub" not in self.zattrs:
iohub_dict = {}
else:
iohub_dict = self.zattrs["iohub"]
iohub_dict.update({f"old_{axis_name}": self.scale[axis_index]})
self.zattrs["iohub"] = iohub_dict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ziw-liu our original line didn't update the metadata in the way we intended. My fault for not testing this.

@ziw-liu this is the simplest solution I could get to work, but it's a bit ugly. Should .zattrs["iohub"] be part of the pydantic models so that we can use dump_meta?


# Update scale while preserving existing transforms
transforms = (
Expand Down