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

Allow individual label images to be converted #135

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

melissalinkert
Copy link
Member

This loosens some of the restrictions on the Zarr hierarchy, and adds a -f option so that metadata can be copied from an existing image file.

I'd expect raw2ometiff input.zarr/0/labels/abc_mask/ mask.ome.tiff -f /path/to/original/image/file to be the pattern to use here, which would convert a single label image to a single OME-TIFF. If there are multiple label images under input.zarr/0/labels/, they would each need to be converted separately. The use of -f means that input.zarr/OME/METADATA.ome.xml does not need to exist (and in fact, would be ignored if it did).

Fake data can easily be used to test the -f option. If any of the XYZCT dimensions are incorrect, an informative exception should be thrown.

Assigning just @erindiel for now to make sure the required functionality has been captured correctly; can assign code reviewers afterwards.

@erindiel
Copy link
Member

Thanks @melissalinkert I copied some of our public OME-Zarr data locally for testing (s3://gs-public-zarr-archive/TCGA-OR-A5JB-01A-01-TS1.B68B5BAF-B262-4DAA-9F47-A285B3C497AF.ome.zarr).

% ~/raw2ometiff-0.8.0-SNAPSHOT/bin/raw2ometiff TCGA-OR-A5JB-01A-01-TS1.B68B5BAF-B262-4DAA-9F47-A285B3C497AF.ome.zarr/0/labels/455bee08-148a-4a88-8e11-411175d8f2b4 455bee08-148a-4a88-8e11-411175d8f2b4.ome.tiff -f TCGA-OR-A5JB-01A-01-TS1.B68B5BAF-B262-4DAA-9F47-A285B3C497AF.ome.zarr/OME/METADATA.ome.xml 
2025-01-15 16:47:56,375 [main] WARN  c.g.p.PyramidFromDirectoryWriter - Layout version not recorded; may be unsupported
2025-01-15 16:47:56,624 [main] WARN  c.g.p.PyramidFromDirectoryWriter - Series missing from hierarchy, assuming single pyramid
Exception in thread "main" picocli.CommandLine$ExecutionException: Error while calling command (com.glencoesoftware.pyramid.PyramidFromDirectoryWriter@5f9edf14): java.lang.RuntimeException: loci.formats.FormatException: Dimension mismatch: Z: Zarr (1), OME-XML: (3)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2050)
	at picocli.CommandLine.access$1500(CommandLine.java:148)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
	at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:2264)
	at picocli.CommandLine.parseWithHandlers(CommandLine.java:2664)
	at picocli.CommandLine.parseWithHandler(CommandLine.java:2599)
	at picocli.CommandLine.call(CommandLine.java:2875)
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.main(PyramidFromDirectoryWriter.java:536)
Caused by: java.lang.RuntimeException: loci.formats.FormatException: Dimension mismatch: Z: Zarr (1), OME-XML: (3)
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.call(PyramidFromDirectoryWriter.java:611)
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.call(PyramidFromDirectoryWriter.java:104)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
	... 9 more
Caused by: loci.formats.FormatException: Dimension mismatch: Z: Zarr (1), OME-XML: (3)
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.initialize(PyramidFromDirectoryWriter.java:1079)
	at com.glencoesoftware.pyramid.PyramidFromDirectoryWriter.call(PyramidFromDirectoryWriter.java:597)
	... 11 more

I believe this error is happening due to a mismatch in the channel count (although it says Z). The image here is 3-channel RGB data, while the label image is single channel. This is an expected condition where the label image would not match the input image in channel count. At least in the OMERO Plus universe, we assume all OME-Zarr label images are single channel. Could this dimension mismatch be accepted?

I would expect all spatial dimensions to match between the label image and image: X, Y and Z.

@melissalinkert
Copy link
Member Author

At least in the OMERO Plus universe, we assume all OME-Zarr label images are single channel. Could this dimension mismatch be accepted?

Can do. Should mismatches in the T dimension be allowed as well?

@erindiel
Copy link
Member

I propose we only allow mismatches in C, given we understand the reason for this. So let's please include X, Y, Z and T in dimensions that should match between the image and label image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants