henrypinkard / Pygellan

[DEPREACATED] Python interface for data-driven microscopy with Micro-manager/Micro-Magellan
BSD 3-Clause "New" or "Revised" License
14 stars 3 forks source link

Reading Expt Details Question #22

Closed kdmarchuk closed 4 years ago

kdmarchuk commented 4 years ago

When trying to read information pertinent to packing an .hdf5 file, how would you pull information from the Magellan dataset? x, y, z, t resolution are most interesting. I can access the micromanager metadata but z and t resolution aren't in there I believe.

Thanks, Kyle

henrypinkard commented 4 years ago

This should have everything you need: https://github.com/henrypinkard/LymphoSight/blob/master/registration/data_reading.py

henrypinkard commented 4 years ago

Did Imaris file converter not work then?

kdmarchuk commented 4 years ago

Sweet. That helps.

The Imaris File Converter (IFC) was never going to work on Magellan files directly. On the way to getting a non-RAM limited, Python based Imaricumpiler up and running, my quick solution is to write tif files with a file naming convention easy for the IFC regex to understand; 'file_name_t0_c0_z0.tif' and iterate through the stack. As long as an individual z slice of 1 channel is less than RAM, I don't see too much of a problem.

This was pretty easy to do and I have simple working code for this. What I'd like to do is add some metadata to the tifs so that the the IFC can pack that into the .ims file directly.

Once this is working, I can be more clever and pack directly into an hdf5 format, but I need something that can handle the file sizes coming off the SPIM sooner than later.

The other option is to write a non Imaris hdf5 file structure without the downsampling and convert on that.

Quick and dirty for now.

Kyle

henrypinkard commented 4 years ago

It would probably be easier to just write into an HDF5 file and don't bother with downsampling to lower resolutions. You could do this with a few lines of code. Something like:

file = h5py.File('path/to/file')
channel = 0
file['Timepoint']['channel'] = magellan.as_array(stitched=True)[0, channel]

(Probably not exactly right but pretty close)

Then you could just put this into the imaris file converter and it would make a new file with the correct pyramid structure. When you want to make it one step just add pyramid making code in python

kdmarchuk commented 4 years ago

You're probably right (write?). I was going to go this route more directly, but after installing h5py I had it clash with dask in some weird ways. Have you experienced this at all? I didn't flesh that issue out, I just switched gears to try and find a quick solution.

Just got my new computer in, so I'll be more careful in setting up environments and all that this time around.

Kyle

henrypinkard commented 4 years ago

Haven't seen it. Might be worth filing an issue with dask. But you should be able to just call np.array() on some slice of the dask array to convert it to numpy array and then pass that to h5py

kdmarchuk commented 4 years ago

The issue was something about after installing h5py the dask package wasn't able to open a dask array. I wasn't even trying to manipulate anything at the time.

Anyways, I'll pay more attention to it when I try this out and report to dask.

henrypinkard commented 4 years ago

just install anaconda then you don't have to worry about this manually

kdmarchuk commented 4 years ago

I have anaconda.

henrypinkard commented 4 years ago

Then you shouldn't need to install anything besides pygellan (https://docs.anaconda.com/anaconda/packages/old-pkg-lists/4.3.1/py35/)