-
Notifications
You must be signed in to change notification settings - Fork 10
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
Name option #147
Open
will-moore
wants to merge
11
commits into
ome:master
Choose a base branch
from
will-moore:name_option
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+53
−20
Open
Name option #147
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e882a62
Add name_by option to allow name.ome.zarr
will-moore d80d276
Remove .pattern from image name
will-moore 1d72626
Handle first plate Wells having no fields
will-moore 6290b4b
Don't try to remove .pattern from image names
will-moore c73d400
Replace [] with () in zarr names
will-moore 57da8bb
Add get_zarr_name(). Always use .ome.zarr
will-moore 36e66c4
Update README with --name_by option
will-moore 3ca2c58
Update README and masks.py to use ID.ome.zarr
will-moore ecf5a3e
Merge remote-tracking branch 'origin/master' into name_option
will-moore 470ad2b
Use .ome.zarr in args help
will-moore a14f62a
Improve source-image example in README
will-moore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,12 +41,23 @@ | |
from .util import marshal_axes, marshal_transformations, open_store, print_status | ||
|
||
|
||
def sanitize_name(zarr_name: str) -> str: | ||
# Avoids re.compile errors when writing Zarr data with the named root | ||
# https://github.com/ome/omero-cli-zarr/pull/147#issuecomment-1669075660 | ||
return zarr_name.replace("[", "(").replace("]", ")") | ||
|
||
|
||
def image_to_zarr(image: omero.gateway.ImageWrapper, args: argparse.Namespace) -> None: | ||
target_dir = args.output | ||
tile_width = args.tile_width | ||
tile_height = args.tile_height | ||
name_by = args.name_by | ||
|
||
name = os.path.join(target_dir, "%s.zarr" % image.id) | ||
if name_by == "name": | ||
img_name = sanitize_name(image.name) | ||
name = os.path.join(target_dir, "%s.ome.zarr" % img_name) | ||
else: | ||
name = os.path.join(target_dir, "%s.zarr" % image.id) | ||
print(f"Exporting to {name} ({VERSION})") | ||
store = open_store(name) | ||
root = open_group(store) | ||
|
@@ -245,7 +256,14 @@ def plate_to_zarr(plate: omero.gateway._PlateWrapper, args: argparse.Namespace) | |
total = n_rows * n_cols * (n_fields[1] - n_fields[0] + 1) | ||
|
||
target_dir = args.output | ||
name = os.path.join(target_dir, "%s.zarr" % plate.id) | ||
name_by = args.name_by | ||
|
||
if name_by == "name": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two quick notes:
|
||
plate_name = sanitize_name(plate.name) | ||
name = os.path.join(target_dir, "%s.ome.zarr" % plate_name) | ||
else: | ||
name = os.path.join(target_dir, "%s.zarr" % plate.id) | ||
|
||
store = open_store(name) | ||
print(f"Exporting to {name} ({VERSION})") | ||
root = open_group(store) | ||
|
@@ -296,6 +314,8 @@ def plate_to_zarr(plate: omero.gateway._PlateWrapper, args: argparse.Namespace) | |
print_status(int(t0), int(time.time()), count, total) | ||
|
||
# Update plate_metadata after each Well | ||
if len(well_paths) == 0: | ||
continue | ||
write_plate_metadata( | ||
root, | ||
row_names, | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That raises the question about the extension.
In both cases, the library is used to generate
ome.zarr
so in one case using.zarr
and in the other case.ome.zarr
is confusingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I think we've stated elsewhere:
.zarr
.ome.zarr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshmoore You're suggesting we update the default behaviour to be
[ID].ome.zarr
instead of[ID].zarr
?Always using
.ome.zarr
(for name.ome.zarr or ID.ome.zarr) is more consistent, so I'm happy to do that, but that is more of a breaking changeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking in the sense that you think current processes won't detect that something has already been exported and will re-export?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, just if you've got a workflow like:
that workflow will need to change because
1.zarr
will now be created as1.ome.zarr
But that's not a major concern, so happy to make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I'm personally a bit up in the air. A benefit of
.zarr
filesets are that other stuff can be stored in them which is why I don't think we should ever require.ome.zarr
. On the flip side, what we do now will likely be the model that other submitters to BIA tend to follow, so it does make sense to do what we think is most strategic (and update any existing workflows as necessary). All that being said, 💯 for doing whatever consistently.