saalfeldlab / paintera

GNU General Public License v2.0
100 stars 17 forks source link

Support for loading BigDataViewer data #249

Open hanslovsky opened 5 years ago

hanslovsky commented 5 years ago

While based on BDV, Paintera currenlty does not support the BDV data format. @tpietzsch suggested we add least add some rudimentary support for it so people in the SPIM world have access to Paintera.

Quoting myself from an e-mail that I sent to @tpietzsch

I had a look at the structure of the BDV example h5 (drosophila.h5) file at http://fly.mpi-cbg.de/~pietzsch/bdv-example/ If I understand correctly, the actual dataset is not located at

t00000/s00/0 

but rather in

t00000/s00/0/cells

which, if I parse correctly, results in a scheme

<time>/<setup??>/<scale??>/<name??>

which is not trivially compatible with Paintera's currently supported (but discouraged in favor of Paintera's own format) multi-scale format

<name>/<scale>

The difference is, as far as I understand, that Paintera treats the

as a dataset, while in BDV format it is a group that contains a dataset. Also, Paintera does not recognize affine transforms but only resolution and offset inside the metadata. I think it is probably best to add actual support for the BDV file format if there is some desire to load it into Paintera instead of trying to unify loading data from formats that are not really compatible. This is, of course, only true if I did parse the BDV format correctly (correct me if I am wrong). > How do you know downsampling factors per level? They are stored as attribute in the attributes of each level, e.g. "downsamplingFactors":[2.0,2.0,1.0] but it may be better to store the resolution and offset at each level instead, such that each scale level could be loaded as single-scale dataset with appropriate resolution and offset, as well. Full support of BDV files would require: - [ ] support for viewing time series in Paintera (just add controls to change the time point) - [ ] data structures/sources for BDV files (maybe re-use what is in BDV already): - [ ] actual source implementations - [ ] openers - [ ] serializers - [ ] support for painting in time series/time series label dataa (optional)
hanslovsky commented 5 years ago

I slightly misunderstood the group and dataset hierarchy inside h5 files in BDV format:

Instead of

<time>/<setup>/<scale>/<name>`

It actually is

<time>/<setup??>/<scale??>/cells

Where cells is always the same name. This makes importing and discovering single time points of single setups a lot more compatible multi-scale support in Paintera.

Thanks to @tpietzsch for clarifying!

What we should do (in my opinion) is

  1. Add an optional field "affineTransformation" to each dataset and in particular to each scale level. This field would take precedence over "offset" and "resolution", if present.
  2. Adapt UI for opening (multi-scale) data to support that field (internally, offset and resolution are already translated into a AffineTransform3D).
  3. Copy this meta data from the XML into the appropriate locations in the h5 file.

This is much simpler than fully supporting BDV format. I will leave this issue open because it might be good to actually have full support of BDV format at some point.