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

gson error for images having extra dimension of size 1 #15

Open
karlduderstadt opened this issue Nov 30, 2020 · 3 comments
Open

gson error for images having extra dimension of size 1 #15

karlduderstadt opened this issue Nov 30, 2020 · 3 comments

Comments

@karlduderstadt
Copy link

First of all, it is really great to have the N5 import and export tools now included in Fiji by default! Thanks very much for this effort! I have been meaning to work with N5 for a while and this makes it much easier.

I have been testing importing and exporting with different images and I keep getting an error from gson when it tries to write an NaN (see below). I seem to get this error from images that have an extra dimension of size 1. For example, an image that contains a Z axis but where all T were collected for Z = 0. Something like X, Y, Z, Channel, Time = 1024, 1024, 1, 2, 160. I think somehow the Z dimension in these videos triggers writing the NaN and gson is set to not allow writing of NaN values, perhaps because they would end up being strings and can cause a lot of problems when parsing json later on...

The videos still seem to be written and I can open them. Should I just ignore this error and continue on? Obviously, another solution would be to always work with the minimal dimensions required - to never have dimensions of size 1. But it seems that the SCIFIO reader we are using opens videos this way with some dimensions of size 1. I don't seem to have the issue when opening the videos with IJ1.

I guess the error below is actually coming from the N5Writer and not really the plugins here, but I thought reporting the issue here would be best since it involves the way videos are opened in Fiji. If you want I can report it over there...

Thanks again for this cool format and helpful plugins. If you don't see this as an issue, I get it, and feel free to close it. But please let me know if you have any tips on how I could deal with this.

Screenshot 2020-11-30 at 12 59 46

@bogovicj
Copy link
Contributor

Thanks for reporting this, and your interest in the plugin / tools!

It looks like you're using the "N5 Viewer" metadata type when exporting - is that correct? One issue is that the N5Viewer metadata format does not support a time axis (officially). If it seems to work, it's an accident :p ( We should document this....)

If the above is correct, could you try the "ImageJ" metadata style? That format does support time and datasets of up to 5 dimensions.

@karlduderstadt
Copy link
Author

Thanks for the quick feedback! Yes I had used N5 Viewer mostly, but this error also occurs with the ImageJ metadata style option. Here are the settings I just tested with:

Screenshot 2020-11-30 at 15 37 13

That's interesting about the N5 Viewer mode, I didn't know that. In all cases, it seems to create the datasets. With the settings above, I only get the error near the end. I am still thinking it is related to having a dimension with size 1, but maybe it is something else...

@karlduderstadt
Copy link
Author

I haven't figured out what is causing the error, but I think I understand better what you meant by the N5 Viewer doesn't support a time axis.

I was hoping to migrate from HD5 to N5 for use in BDV because of the improved performance in creation and viewing. I guess at the moment, there is no support for N5 in BDV with a time axis. Looking at N5Source I see getSource(...) ignores time and N5Viewer always sets everything to one time point. Is there a plan to support time?

I was thinking about writing my own version of N5Source with a getSource(..) method and uses the time information to give back a resliced RandomAccessibleInterval for one given timepoint using Views.hyperSlice(...). Do you think this would be a reasonable strategy to add time information support for N5 / BDV ? Or would this not be optimal for performance?

At the moment, I was using Spim stuff (SpimSource, etc..) with HD5s. SpimSource has an ImgLoader that takes care of this. I didn't look at how that works yet.

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

No branches or pull requests

2 participants