mobie / mobie-utils-python

Python tools for MoBIE
MIT License
9 stars 5 forks source link

Support more table formats #98

Closed imagejan closed 1 year ago

imagejan commented 1 year ago

Adding segmentations using this Python library currently requires tables to be in the form of the MoBIE spec (label_id, anchor_{xy}, ...).

It would be great if the other table formats discussed in https://github.com/mobie/mobie-viewer-fiji/issues/935 were also supported (in particular the skimage table format, so we can directly add a DataFrame derived from regionprops measurements).

constantinpape commented 1 year ago

We currently don't support all the table formats listed in #935 in mobie projects yet, but only for opening arbitrary data via the MoBIE CLI. I think we should support this in MoBIE projects as well at some point, but I would wait with this until the MoBIE CLI and other new functionality is more stable. In particular I would wait till after the next release, that will include the MoBIE CLI and other features. (And that will also force us to better define the differences between MoBIE projects and what can be opened by the CLI).

constantinpape commented 1 year ago

After thinking about this again: maybe we support this for MoBIE projects in Fiji already. (And if yes it would be easy for me to also support this here). @tischi: Is it already possible to open tables in the skimage format etc. in MoBIE projects?

imagejan commented 1 year ago

I tried with headers corresponding to a scikit-image (regionprops) table, and while MoBIE apparently recognizes the right table type, it still looks for a label_id column (instead of label) at some point during the opening process, and throws an error accordingly.

constantinpape commented 1 year ago

Thanks for checking @imagejan!

@tischi: as said above I think we should in principle support all the table flavors in both MoBIE projects and the CLI. But of course it's up to you to prioritize when to implement this. Or maybe you would like to contribute this, @imagejan? I can then update the support for it here and also extend the documentation as soon as this is supported by MoBIE-Fiji.

tischi commented 1 year ago

It could be that this is very easy to fix in MoBIE (maybe the above commit does it already).

@imagejan Could you try it from the develop branch? If you clone it and go to test/java/develop/projects/ you find millions of examples for how to launch MoBIE from Java.

imagejan commented 1 year ago

Thanks @tischi!

I tried but got a null pointer exception here:

https://github.com/mobie/mobie-viewer-fiji/blob/1d9879c28315ffde61fa8f9671e450ead1aba5a5/src/main/java/org/embl/mobie/MoBIE.java#L1128

This quick fix for me worked fine then:

https://github.com/mobie/mobie-viewer-fiji/compare/develop...fmi-faim:mobie-viewer-fiji:fix-table-nullpointer

tischi commented 1 year ago

Thanks! The quick fix would fail in other cases, but I pushed a new commit to develop that should cover all cases. Could you please try?

imagejan commented 1 year ago

@tischi thanks, mobie-viewer-fiji from https://github.com/mobie/mobie-viewer-fiji/commit/2801f9656a21335a2fa2c633fc91620c8bf1f328 works fine for me 👍.

I tested both with "MoBIE-sytle" and with scikit-image-style headers inside a MoBIE dataset.

constantinpape commented 1 year ago

I have now added support for the skimage style tables in #102, but have not tested this yet. Let me know if this works for you @imagejan, or if you run into any issues with it. (It's now also very easy to add support for more table formats, but the skimage one is currently the only additional format which is explicitly described in https://github.com/mobie/mobie-viewer-fiji/issues/935).

constantinpape commented 1 year ago

Support for all current table flavors is now added. I will draft a new release and close this issue. Feel free to reopen if anything is still missing @imagejan.