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

sim experiment - excitation wavelenght on dv extended header #290

Closed
carandraug opened this issue Nov 27, 2017 · 9 comments
Closed

sim experiment - excitation wavelenght on dv extended header #290

carandraug opened this issue Nov 27, 2017 · 9 comments
Labels
critical Issue requiring immediate attention; cause Cockpit to crash or a major loss of data.

Comments

@carandraug
Copy link
Collaborator

The base header of a mrc file has the emission wavelength. For SIM reconstruction we need the excitation wavelength. The mrc format does not have a place for this. The dv format seems to store it on the extended header but we don't have the specs for that.

This issue is point 2 on issue #288

We need to ask GE for the extended header specs and/or see what bioformats does. Seems like the OME team have some specs for the extended header but are unable to share them. We should be able to guess from their source code . See also bioformats page on the dv format and a recent bug report about wanting more up to date specs

@carandraug
Copy link
Collaborator Author

The fix seems to be that we will have cockpit writing dv files. What I gathered from reading the source bioformats and other dv readers, other than setting the right id on the mrc header, this would mean that the extender header becomes an array of 14 floats per plane. Each group of 14 floats the same order of the image planes on the data section. They will be order like so:

  1. photosensor reading, typically in mV
  2. elapsed time in seconds since experiment began
  3. x stage coordinates
  4. y stage coordinates
  5. z stage coordinates
  6. minimum intensity
  7. maximum intensity
  8. mean intensity
  9. exposure time in seconds
  10. neutral density (can be either a fraction of 1 or a percentage)
  11. excitation wavelength
  12. emission wavelength
  13. intensity scaling (usually 1)
  14. energy conversion factor (usually 1)

@iandobbie
Copy link
Collaborator

iandobbie commented Dec 18, 2017 via email

@iandobbie
Copy link
Collaborator

I think this will fix the issue in #168 as well

@iandobbie iandobbie added the critical Issue requiring immediate attention; cause Cockpit to crash or a major loss of data. label Feb 19, 2018
@carandraug
Copy link
Collaborator Author

I have started to fix this with commit carandraug/cockpit@a20c1a8

I need someone's help to actually get the required metadata which I don't know where is kept. See the three TODO's on that commit.

Where is the excitation wavelength for the each image? The CameraHandler.wavelength property is the emission not excitation, correct?

Also, I guess we could add the exposure time. There is CameraHandler.getExposureTime but if the writing of each plane is not synced with the image acquisition, then it's possible that at the time of writing, the camera exposure settings are different from the actual settings used for acquisition, correct?

@carandraug
Copy link
Collaborator Author

A side note because the only reason to have all this trouble is to use softWoRx for reconstruction.

Is the excitation wavelength information in the extended header used by softworx to create a correct call to OMXSIReconstruction? Or is the extended header inspected by OMXSIReconstruction itself? Because it seems that the excitation wavelength is a parameter to call the reconstruction program, like so:

OMXS [...] -channel_ex_linespacing $EX_WAVELENGTH $LINESPACING [...]

and so we could use it directly and not via softWoRx until we replace softWoRx.

@carandraug
Copy link
Collaborator Author

I have a fix for this on my branch extended-metadata. This seems to work for Mick with dummy devices. I have also tried it on Deepsim and the excitation wavelength is correct there. Ian, can you check if this is enough for softWoRx to do the reconstruction properly?

For this fix, we assume that all images from a specific camera have the same excitation wavelength. This is not great but according to @mickp is true if doing experiments with the cokpit interface.

I think that a long term fix for this will require passing to writeImage an image object that has the pixel values and the metadata for it. As it is, we only have the pixel values, and a timestamp from software. The rest we have to deduce from the camera that took the image.

carandraug added a commit that referenced this issue Jul 23, 2018
…#290)

We want to write dv files but we write the extended header metadata
in our own non-specified format (basically, only the timestamp).
This changes to write an extended header that is familiar to softWoRx
so we can then use it for analysis.  This only puts the right shape
of the extended header, we still need to figure out how to obtain the
rest of the metadata which currently is not avaliable to
DataSaver.writeImage().

In addition, move computations with imageData outside the file lock,
and reduce try/catch to the actual writing of the file.
carandraug added a commit that referenced this issue Jul 23, 2018
This assumes that all images from a camera have the same excitation.
We can assume that, it's a limitation of the cockpit interface.

This also assumes that each image has only one excitation wavelength
worth of being included in the metadata.  We need to assume that,
that's a limitation the DV format, even if cockpit does allow multiple
light sources for each image.
@carandraug
Copy link
Collaborator Author

I have pushed commits 26e32f7...6ef282b after testing this on DeepSIM with Ian. This writes an extended header of 14 floats per image plane that bioformats and the ImageJ Deltavision Opener plugin can read. However, OMXSIReconstruction still fails to pick the excitation wavelength values. We don't know where OMXSIReconstruction is looking for that data.

The extended header is a group of floats and ints per image plane. The existing open source readers skip all the ints and read the first 14 floats. So the changes pushed now write only 14 floats. But reading actual dv files, it seems that it's writing 8 ints and 32 floats. We have no idea what may go on the other values, but maybe that shape of extended header is required to make OMXSIReconstruction happy:

>>> import struct
>>> fh = open(..., 'r')
>>> fh.seek(128)
>>> struct.unpack('h', fh.read(2)) # number of int
(8,)
>>> struct.unpack('h', fh.read(2)) # number of float
(32,)
>>> fh.seek(1024)
>>> struct.unpack('8i32f', fh.read(8*4 + 32*4))
(0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 16640.0, 13462.0, 5520.75, -4002.38134765625, 4026.86279296875, 125.80743408203125, 60.0, 1.0, 488.0, 525.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)

carandraug added a commit that referenced this issue Jul 23, 2018
…290)

This does not add more metadata to the extended header.  This only
makes it longer (filled with zeros) so that softworx reconstruction
picks up the excitation wavelength.

Existing open source tools only use the first 14 floats in the
extended header.  However, actual dv files from softWoRx write longer
extended headers.  One file we had around has 8 ints and 32 floats.
We still only know what goes in the first 14 floats though.
@carandraug
Copy link
Collaborator Author

Writing down 8 ints and 32 floats per plane, even though all filled with zero fixed the issue, i.e, softworx is now picking the right excitation wavelength for reconstruction. Pushed fix in commit 961a3cc. Closing as fixed.

Note that we don't know what all that new data is meant to have on the extended header. I left the code in place ready to fill the metadata if we ever get to know about them.

@iandobbie
Copy link
Collaborator

iandobbie commented Jul 23, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical Issue requiring immediate attention; cause Cockpit to crash or a major loss of data.
Projects
None yet
Development

No branches or pull requests

2 participants