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

Spacing image information in TIFF and PNG format #28

Open
fbudin69500 opened this issue Aug 30, 2016 · 3 comments
Open

Spacing image information in TIFF and PNG format #28

fbudin69500 opened this issue Aug 30, 2016 · 3 comments

Comments

@fbudin69500
Copy link
Contributor

fbudin69500 commented Aug 30, 2016

It seems that the image spacing information is not saved when using SCIFIO to save these formats.
I have written a small reader and writer that use SCIFIO, for test purposes:
https://github.com/fbudin69500/scifio-spacing-test

When using the default PNG and TIFF writers, the spacing information is saved in the image.
Is this a known issue? I looked in the bioformat library and I had the impression that the spacing was not handled [1] [2].

[1] https://github.com/openmicroscopy/bioformats/blob/v5.0.0/docs/sphinx/formats/png-metadata.txt
[2] https://github.com/openmicroscopy/bioformats/blob/v5.0.0/docs/sphinx/formats/tiff-metadata.txt

Additionally, the spacing information does not seem to be passed from scifio-imageio to bioformat:
https://github.com/scifio/scifio-itk-bridge/blob/master/src/main/java/io/scif/itk/SCIFIOITKBridge.java#L538-L550

@thewtex @ctrueden
Do you think I am doing anything wrong or that this issue would be easy to address?

@ctrueden
Copy link
Member

ctrueden commented May 9, 2017

@fbudin69500 Really sorry for dropping the ball on this till now. I am juggling a lot of things, so you are always welcome to ping me at regular intervals if I do not answer in a timely manner.

Upon cursory inspection, I think you are right about the calibrations not being propagated. In the meantime, has anyone at Kitware looked into a fix?

If this is still an outstanding issue, fixing it might be as simple as adding code like the following after the populateMetadata invocation:

meta.setPixelsPhysicalSizeX(FormatTools.getPhysicalSizeX(pSizeX), 0);
meta.setPixelsPhysicalSizeY(FormatTools.getPhysicalSizeY(pSizeY), 0);
meta.setPixelsPhysicalSizeZ(FormatTools.getPhysicalSizeZ(pSizeZ), 0);
meta.setPixelsTimeIncrement(FormatTools.getTime(pSizeT, null), 0);
double startingWavelength = getStartingWavelength(); // what should it be??
for (int c = 0; c < dimc; c++) {
	double wave = startingWavelength + c * pSizeC;
	meta.setChannelEmissionWavelength(FormatTools.getWavelength(wave), 0, c);
}

Note that Bio-Formats now has support for units; the code above assumes the default units, since the write method of SCIFIOITKBridge does not specify them. It is also unclear what the starting wavelength should be; perhaps the bridge needs to be updated to pass that along to the write method.

Lastly, note that the dims parameter of write is currently also unused; but I did not reflect on the ramifications of this.

@fbudin69500
Copy link
Contributor Author

Thanks for the input! As far as I know, nobody has tried to tackle this problem yet. The lines of code that you are suggesting might be very helpful! (CC @thewtex ).

@thewtex
Copy link
Member

thewtex commented May 9, 2017

Thanks @fbudin69500 for the great report and @ctrueden for the great suggestions. We should have an opportunity to test further in a few months.

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

3 participants