Closed tischi closed 1 year ago
Quiting @tischi from the forum post: Adding channel to ome.zarr via
"ome.zarr": {
"relativePath": "images/ome-zarr/HTM.ome.zarr/A/1/0",
"channel": 0
},
I think that's a good idea; we could do the same with setup_id
in bdv.xml.
In fact, it may be super easy:
Just here we would have to fetch the correct setupID
, based on (to be added) source.imageData.get( imageDataFormat ).channel
:
@tibuch this could be your first PR 😉
"channel": 0
is exactly what I was looking for!
Currently I can "hack" my way around this by creating a proxy-zarr-file with only one channel using symbolic links to point to the multi-channel sub-directories of the hsc-zarr-file:
/home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/
plate_01.ome.zarr
├── B // Row
│ ├── 02 // Column
│ │ ├── 0 // First field of view i.e. MIP_OVR with 4 channels
│ │ │ ├── 0 // Scale level 0
│ │ │ │ ├── 0 // Channel 0
│ │ │ │ ├── 1 // Channel 1
│ │ │ │ ├── 2 // Channel 2
│ │ │ │ └── 3 // Channel 3
│ │ │ ├── 1 // Scale level 1
│ │ │ │ ├── 0 // Channel 0
│ │ │ │ ├── 1 // ...
│ │ │ │ ├── 2
│ │ │ │ └── 3
│ │ │ ├── 2
│ │ │ │ ├── 0
│ │ │ │ ├── 1
│ │ │ │ ├── 2
│ │ │ │ └── 3
│ │ │ ├── 3
│ │ │ │ ├── 0
│ │ │ │ ├── 1
│ │ │ │ ├── 2
│ │ │ │ └── 3
│ │ │ └── 4
│ │ │ ├── 0
│ │ │ ├── 1
│ │ │ ├── 2
│ │ │ └── 3
│ │ ├── B02_MIP_OVR_C01 // proxy-zarr object with only a single channel pointing to the data above.
│ │ │ ├── 0
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/0/0
│ │ │ ├── 1
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/1/0
│ │ │ ├── 2
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/2/0
│ │ │ ├── 3
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/3/0
│ │ │ └── 4
│ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/4/0
│ │ ├── B02_MIP_OVR_C02
│ │ │ ├── 0
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/0/1
│ │ │ ├── 1
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/1/1
│ │ │ ├── 2
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/2/1
│ │ │ ├── 3
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/3/1
│ │ │ └── 4
│ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/4/1
│ │ ├── B02_MIP_OVR_C03
│ │ │ ├── 0
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/0/2
│ │ │ ├── 1
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/1/2
│ │ │ ├── 2
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/2/2
│ │ │ ├── 3
│ │ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/3/2
│ │ │ └── 4
│ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/4/2
│ │ └── B02_MIP_OVR_C04
│ │ ├── 0
│ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/0/3
│ │ ├── 1
│ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/1/3
│ │ ├── 2
│ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/2/3
│ │ ├── 3
│ │ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/3/3
│ │ └── 4
│ │ └── 0 -> /home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/4/3
│ ├── 03
│ │ ├── 0
│ │ │ ├── 0
But what @tischi is recommending sounds much nicer and cleaner!
I will have a look (hopefully today) and see if this could become my first PR ;)
I will have a look (hopefully today) and see if this could become my first PR ;)
That sounds great! I will also create a small example project for this today, so you would have something easier for development.
@tibuch
develop
branch, but this is broken right now. So you could use main
as a starting point.src/**test**/java/projects/...
there are tons of examples for how to open a project from within your IDE. That's how I usually do the development or debugging.@tibuch
develop
branch, so you could work against that.develop
branch and upload it to MoBIE-beta; I did that just now. Like this we can test/develop the latest features "in the wild" without screwing up the main update site. One more info:
The tests in the github actions are not running stable: https://github.com/mobie/mobie-viewer-fiji/issues/742
So for now don't worry if they fail.
You could mvn test
locally if you want to check.
Interesting:
/home/tibuch/Data/MoBIE-Test/data/Round1/images/ome-zarr/plate_01.ome.zarr/B/02/0/0/3
Can one can open this (channel?) separately, i.e. does it contain all the metadata to be opened as an individual OME-Zarr image?!
Does that always work or is it just a coincidence that the axis order allows for such a "subsetting-hack'?
The proxy zarr contains .zattrs
and .zgroup
and one level down is an adapted .zarray
file. The only thing that is replaced is the chunked data to avoid duplication.
I see, so this does not work "just like this".
Indeed. I wrote a little helper:
def create_proxy_zarr(root, name="0", channel="0", proxy_name="test"):
scale_levels = [os.path.basename(d) for d in glob(join(root, name, "**"))]
for s in scale_levels:
os.makedirs(join(root, proxy_name, s))
with open(join(root, name, s, ".zarray"), "r") as f:
zarray = json.load(f)
zarray["shape"][0] = 1
with open(join(root, proxy_name, s, ".zarray"), "w") as f:
json.dump(zarray, f, indent=4)
os.symlink(join(root, name, s, channel), join(root, proxy_name, s, "0"))
with open(join(root, name, ".zattrs"), "r") as f:
zattrs = json.load(f)
zattrs["multiscales"][0]["name"] = proxy_name
with open(join(root, proxy_name, ".zattrs"), "w") as f:
json.dump(zattrs, f, indent=4)
with open(join(root, name, ".zgroup"), "r") as f:
zgroup = json.load(f)
with open(join(root, proxy_name, ".zgroup"), "w") as f:
json.dump(zgroup, f, indent=4)
Ah, and Windows will not support this hack with the links. So better to go the way indicated by @tischi.
Hey @tibuch, I have added an example project here: https://github.com/mobie/spatial-transcriptomics-example-project
It is already available via s3, so you can directly open it via the github link. Of course mobie needs to be updated in order to understand it since it has the new {"imageData": {"ome.zarr.s3": {"s3Address": "....", "channel": 0}}}
feature.
(the dataset contains a single ome.zarr with 4 channels).
Thanks so much for looking into this! And let me know if anything is unclear or you need anything else.
Also one note: on the python site we had a check that the name in the ome.zarr metadata (multiscales:name
) is the same as the source name in MoBIE. This is not possible any more, becasue one ome.zarr file now corresponds to multiple sources in MoBIE. It was easy to disable the check in python (https://github.com/mobie/mobie-utils-python/blob/channel/mobie/validation/metadata.py#L112-L113), but there might be some logic in the Fiji plugin also depending on it that needs to be adapted.
Awesome! I will setup my IDE and start looking into. However, I don't think I will manage to finish today ;)
However, I don't think I will manage to finish today ;)
Of course! I am available next week, so just let me know if you run into any issues :). And have a nice weekend!
Hi @constantinpape,
Does this dataset work: https://github.com/mobie/spatial-transcriptomics-example-project
I think some data is not available.
Cheers
Hey @tischi and @constantinpape,
I made some progress and it works for single MoBIE sources
, but it does not work for sourceTransforms
(mergedGrid
). In the second case it ends up here: https://github.com/fmi-faim/mobie-viewer-fiji/blob/develop/src/main/java/org/embl/mobie/viewer/transform/MergedGridSource.java#L438 when it adds the images. Which is probably where it should end up. However, when it tries to display the data it throws continuously ArrayIndexOutOfBound
exceptions:
java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException
at net.imglib2.cache.ref.SoftRefLoaderCache.get(SoftRefLoaderCache.java:145)
at net.imglib2.cache.util.LoaderCacheAsCacheAdapter.get(LoaderCacheAsCacheAdapter.java:76)
at net.imglib2.cache.ref.WeakRefVolatileCache.getBlocking(WeakRefVolatileCache.java:484)
at net.imglib2.cache.ref.WeakRefVolatileCache.access$000(WeakRefVolatileCache.java:53)
at net.imglib2.cache.ref.WeakRefVolatileCache$FetchEntry.call(WeakRefVolatileCache.java:531)
at net.imglib2.cache.ref.WeakRefVolatileCache$FetchEntry.call(WeakRefVolatileCache.java:508)
at net.imglib2.cache.queue.FetcherThreads$Fetcher.run(FetcherThreads.java:181)
Caused by: java.lang.ArrayIndexOutOfBoundsException
Maybe I forgot to update something? Or is there something else broken in the branch? Just asking because @tischi mentioned that he hopes that he fixed the branch.
My changes are here: https://github.com/fmi-faim/mobie-viewer-fiji/tree/develop Additionally some changes on mobie-io: https://github.com/fmi-faim/mobie-io/tree/develop
Would be awesome if someone of you finds time to have a look and help me carry it over the finish line :shipit:
Cheers!
Hi @tibuch, first of all, thanks for working on this!
Does this dataset work: https://github.com/mobie/spatial-transcriptomics-example-project I think some data is not available.
I think all data is available, at least my python validation tool says it's there (can't open it directly in MoBIE, because we need the changes you're working on for this). Do you get some error message when trying to load it?
Maybe I forgot to update something? Or is there something else broken in the branch? Just asking because @tischi mentioned that he hopes that he fixed the branch.
I assume that the grid somehow needs this information beforehand... I will take a quick look later, but that's probably something @tischi has to check.
Should I be able to see/download the data from here: https://s3.embl.de/i2k-2020/spatial-transcriptomics-example/pos42/images/ome-zarr
Should I be able to see/download the data from here: https://s3.embl.de/i2k-2020/spatial-transcriptomics-example/pos42/images/ome-zarr
Sort of, but you need to give the address for an actual file, the "fake directories" in s3 don't work, so you can't actually list anything like this (you would need to do s3 api requests for this). This works: https://s3.embl.de/i2k-2020/spatial-transcriptomics-example/pos42/images/ome-zarr/MMStack_Pos42.ome.zarr/.zattrs
(but it shouldn't really matter in MoBIE, all the loading from s3 should work)
Just wanted to check if I can see it, which I can.
MoBIE also starts without errors, but BDV looks pretty black and empty...I guess there are still some bugs/issues.
MoBIE also starts without errors, but BDV looks pretty black and empty...I guess there are still some bugs/issues.
There might also be some issue with contrast limits ...
I will try to check out your branch later and see if I can build from it and adjust contrast limits.
If I click show raw images
I am getting a stack with all zeros.
I opened https://github.com/mobie/mobie-viewer-fiji/pull/797 and https://github.com/mobie/mobie-io/pull/98 to discuss the code changes. There are some changes in mobie-io that I am not so sure about and that might explain some of the issues we see here. @KateMoreva could you have a look at the PR in mobie-io as well? (@tibuch not sure I will have time to compile from your branches today to test it more, will ping you if I find the time later)
@tibuch Thanks for giving this a shot ❤️ I am currently on holidays and can help from middle of next week on.
@tibuch For debugging this you could first try opening the multi-channel OME-Zarr with the OMEZarrViewer
class that is also in this repo. There it should open all the channels. I think @constantinpape could point you to some "positive controls", i.e. multi-channel OME-Zarr that do open correctly there.
I think @constantinpape could point you to some "positive controls", i.e. multi-channel OME-Zarr that do open correctly there.
Sorry, I overlooked that comment. The examples that should work when opening the ome-zarr directly are here:
I am getting an error:
final OpenOMEZARRFromS3Command command = new OpenOMEZARRFromS3Command();
command.s3URL = "https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/czyx.ome.zarr";
command.run();
throws:
Exception in thread "main" java.lang.UnsupportedOperationException: Could not find multiscales at service endpoint: https://s3.embl.de; bucket: i2k-2020; container path: ngff-example-data/v0.4/czyx.ome.zarr; path: ; attribute: multiscales
at org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader.getMultiscale(N5OMEZarrImageLoader.java:281)
at org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader.initSetups(N5OMEZarrImageLoader.java:183)
at org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader.fetchSequenceDescriptionAndViewRegistrations(N5OMEZarrImageLoader.java:134)
at org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader.<init>(N5OMEZarrImageLoader.java:122)
at org.embl.mobie.io.ome.zarr.loaders.N5S3OMEZarrImageLoader.<init>(N5S3OMEZarrImageLoader.java:59)
at org.embl.mobie.io.ome.zarr.openers.OMEZarrS3Opener.readKey(OMEZarrS3Opener.java:41)
at org.embl.mobie.io.ome.zarr.openers.OMEZarrS3Opener.readURL(OMEZarrS3Opener.java:24)
at org.embl.mobie.viewer.command.OpenOMEZARRFromS3Command.openAndShow(OpenOMEZARRFromS3Command.java:51)
at org.embl.mobie.viewer.command.OpenOMEZARRFromS3Command.run(OpenOMEZARRFromS3Command.java:60)
at projects.OpenRemoteOMEZarr.main(OpenRemoteOMEZarr.java:48)
This is with <mobie-io.version>1.2.11</mobie-io.version>
.
Any ideas?
Is there also an v0.4
image without multiple channels that we can use as a control?
In the tests of mobie-io I found: https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/zyx.ome.zarr and this works.
I am getting an error:
final OpenOMEZARRFromS3Command command = new OpenOMEZARRFromS3Command(); command.s3URL = "https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/czyx.ome.zarr"; command.run();
throws:
Exception in thread "main" java.lang.UnsupportedOperationException: Could not find multiscales at service endpoint: https://s3.embl.de; bucket: i2k-2020; container path: ngff-example-data/v0.4/czyx.ome.zarr; path: ; attribute: multiscales at org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader.getMultiscale(N5OMEZarrImageLoader.java:281) at org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader.initSetups(N5OMEZarrImageLoader.java:183) at org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader.fetchSequenceDescriptionAndViewRegistrations(N5OMEZarrImageLoader.java:134) at org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader.<init>(N5OMEZarrImageLoader.java:122) at org.embl.mobie.io.ome.zarr.loaders.N5S3OMEZarrImageLoader.<init>(N5S3OMEZarrImageLoader.java:59) at org.embl.mobie.io.ome.zarr.openers.OMEZarrS3Opener.readKey(OMEZarrS3Opener.java:41) at org.embl.mobie.io.ome.zarr.openers.OMEZarrS3Opener.readURL(OMEZarrS3Opener.java:24) at org.embl.mobie.viewer.command.OpenOMEZARRFromS3Command.openAndShow(OpenOMEZARRFromS3Command.java:51) at org.embl.mobie.viewer.command.OpenOMEZARRFromS3Command.run(OpenOMEZARRFromS3Command.java:60) at projects.OpenRemoteOMEZarr.main(OpenRemoteOMEZarr.java:48)
This is with
<mobie-io.version>1.2.11</mobie-io.version>
.Any ideas?
Maybe there's something wrong on the server side. I can check later.
Hey @tischi,
there was an issue with czyx.ome.zarr
, it's fixed now and the data is available again at https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/zyx.ome.zarr.
I can use this (https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/zyx.ome.zarr https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/czyx.ome.zarr) example dataset with the new channel
attribute :slightly_smiling_face:
This (https://github.com/mobie/spatial-transcriptomics-example-project) does not show me anything. I tried playing around with the contrast limits, but it looks very empty.
The file name suggests that this only has one channel?! https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/zyx.ome.zarr
If I open https://s3.embl.de/i2k-2020/spatial-transcriptomics-example/pos42/images/ome-zarr/MMStack_Pos42.ome.zarr (the one from the spatial-transcriptomics-example-project) with the OME-Zarr command I can see 6 channels (4 image channels, 2 segmentations). However, I am only able to get some signal for the cell-segmentation channel. Everything else looks empty to me. Could that be?
OK!
Using this code (@tibuch you could also try this) in the develop
branch
final ImageJ imageJ = new ImageJ();
imageJ.ui().showUI();
final OpenOMEZARRFromS3Command command = new OpenOMEZARRFromS3Command();
command.s3URL = "https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/czyx.ome.zarr";
command.run();
It does open:
The channel naming needs fixing in mobie-io: https://github.com/mobie/mobie-io/issues/103
In fact in MoBIE, sources MUST have different names.
@tibuch to me that seems to suggest that in principle it can work. I think a next step could be to make it work for your data. Can you maybe share a (zip) of one multi-channel file that you generate for your data?
Just fyi, the data at https://s3.embl.de/i2k-2020/spatial-transcriptomics-example/pos42/images/ome-zarr/MMStack_Pos42.ome.zarr contains data for all channels; here's what I see when opening it in napari (using the napari ome zarr plugin):
But I think everything might still work correctly, and you just don't see anything due to issues with the contrast limits. I am at CVPR this week, but I can have another look at this next week.
Hi @tibuch,
just a quick update for you: we merged #797 today and pushed it to mobie-beta so I can test it. I tested it for https://s3.embl.de/i2k-2020/spatial-transcriptomics-example/. I also couldn't get any of the data to show, even setting the same contrast limits as in napari. However, I also tried to open https://s3.embl.de/i2k-2020/spatial-transcriptomics-example/pos42/images/ome-zarr/MMStack_Pos42.ome.zarr directly in BDV (BDV->Ome Zarr) and it also didn't open correctly there; and we haven't merged any of your changes in mobie-io yet. So there seems to be some issue with this data in mobie.io! (The data itself can be loaded in napari, see my post above).
I will go ahead and create another project with the data from https://s3.embl.de/i2k-2020/ngff-example-data/v0.4/czyx.ome.zarr (which can be opened via BDV->Ome Zarr) for testing. However, to check this I need the fix from #806.
Ok, so I guess the TODO for me is?!
Ok, so I guess the TODO for me is?!
* [ ] Correctly open https://s3.embl.de/i2k-2020/spatial-transcriptomics-example/pos42/images/ome-zarr/MMStack_Pos42.ome.zarr in mobie-io
Yes, that would be great!
But first, please check and release #806, then I can continue with creating an example project that should work.
Ok, so I guess the TODO for me is?!
- [ ] Correctly open https://s3.embl.de/i2k-2020/spatial-transcriptomics-example/pos42/images/ome-zarr/MMStack_Pos42.ome.zarr in mobie-io
I can help if you wish.
@KateMoreva
If you have time that would be very helpful, indeed! Please start from here: https://github.com/mobie/mobie-io/pull/98
Please also have a look here https://github.com/mobie/mobie-io/blob/multi-channel-fix/src/test/java/spimdata/OmeZarrV4S3SpimDataTests.java There I added a Test to extract the min and max values from the channels. Those should return the correct values!
@tischi @tibuch I created a simpler example now, you can find it here:
/g/kreshuk/pape/Work/data/mobie/multi-chan
(on the EMBL share)Opening the project works, and when opening it from the filesystem everything works correctly:
But when opening from s3, it seems to always load channel 0:
Both images show the viewer when displaying nuclei
, which is channel 1 in the ome.zarr. Filesystem shows it correctly, but s3 shows the membrane channel (channel 0).
@tibuch This works now in the mobie3 branch. If you want to develop/test things you should use the mobie3 branch from now on. Thanks!
@tibuch: just fyi: the spec has changed a bit as well, the updated version of the python library is here: https://github.com/mobie/mobie-utils-python/pull/85. I will look into merging this into main next week. And there is also a converter functions to get projects to the new spec in there if you need it.
https://forum.image.sc/t/create-plate-view-for-mobie/67795/4