shampoo icon indicating copy to clipboard operation
shampoo copied to clipboard

HDF5 Storage of ReconstructedWave object

Open LaurentRDC opened this issue 9 years ago • 5 comments

This has been discussed extensively, and Brett suggested the following hierarchy:

/t0000/hologram /t0000/wavelength0/intensity /t0000/wavelength0/phase /t0000/wavelength0/fourier_mask /t0000/wavelength1/intensity /t0000/wavelength1/phase /t0000/wavelength1/fourier_mask … /t0001/hologram /t0001/wavelength0/intensity /t0001/wavelength0/phase /t0001/wavelength0/fourier_mask ...

Let's discuss the practical implementation of this in this issue.

LaurentRDC avatar Nov 30 '16 21:11 LaurentRDC

Actually, I think that information should be stored in a separate object, a wrapper around h5py.File object. Then, the Hologram object and ReconstructedWave object could be instantiated from this wrapper. This avoids having to write different code for interacting with raw holograms and reconstructed holograms.

LaurentRDC avatar Nov 30 '16 21:11 LaurentRDC

This decision needs to be made simultaneously with another one: what's the API that we want for reconstructing time series holograms at multiple propagation distances?

Proposal: Would you like to interact with code like this:

from glob import glob
from shampoo import HologramSeries

propagation_distances = [0.3, 0.31, 0.32, 0.33]

# Create hologram time series object 
paths_to_holograms = glob("data/*.tif")
holograms = HologramSeries.from_tifs(paths_to_holograms)

# Reconstruct at multiple z's for each time, save to HDF5 archive, 
# return the hdf5_archive wrapper object
hdf5_archive = holograms.reconstruct_to_hdf5(propagation_distances, 
                                             filename='archive.hdf5')

Then I agree, there can be a sort of wrapper around the HDF5 archive which would be returned into hdf5_archive, which would be easy to parse. For example, hdf5_archive.hologram[0] might return the first time step's hologram, and hdf5_archive.phase[0, 10] might return the first time step's phase reconstruction, at the tenth propagation distance.

bmorris3 avatar Nov 30 '16 21:11 bmorris3

I might not be able to follow your language that well (I'm not sure what a wrapper does, what an API does, etc.)...but it does seem kinda weird to store the Fourier mask with each time step. Sorry guys, you may have to educate me a little bit here. Is the thinking that the time series of the raw holograms is one thing, and then the generation of a time series of phase/amplitude z-stacks is a separate thing?

jkentwallace avatar Dec 01 '16 23:12 jkentwallace

@jkentwallace I put the Fourier mask at every time point for generality. In HDF5 (just like a file system) items can be links to other items (just like a shortcut to a file) and so while the Fourier mask can appear at every time point for generality, it is actually only stored once (in the root '/' for example

This gives us the flexibility to actually have a different mask for every time point in the future (I don't know if that would ever be useful?)

@bmorris3 This API looks good to me!

LaurentRDC avatar Dec 03 '16 18:12 LaurentRDC

I propose an implementation in #35 . Similar API as above. Easily extensible to multiple wavelengths, and arbitrary time-series length.

LaurentRDC avatar Jan 13 '17 14:01 LaurentRDC