Arcadia-Science / readlif

Leica Image Format (LIF) file reader for Python
GNU General Public License v3.0
32 stars 13 forks source link

Question/suggestion : returning LifImage objects as NumPy arrays. #25

Closed b-grimaud closed 3 years ago

b-grimaud commented 3 years ago

The script I'm currently working with uses imageio (https://github.com/imageio/imageio) to read .tif files and return them as NumPy arrays containing pixel data for each individual frame.

NumPy provides a function to turn a Pillow object into an array, but as I understand it only individual frames obtained with, for example, get_iterm_m, are Pillow objects.

For now, the only solution I see is, for each LifImage object, have a frame by frame loop which appends an already existing array with data from said frame, while adding a column that stores frame numbers.

Is there, or could there be, a more elegant way to turn LifImage objects directly into NumPy arrays ?

nimne commented 3 years ago

You're correct that this package doesn't really deal with 3D images and numpy arrays well, I would really recommend the https://github.com/AllenCellModeling/aicsimageio project. It uses this library to read the .lif files, but then provides an excellent API to get the data as numpy or dask arrays.

b-grimaud commented 3 years ago

Thank you very much for your recommendation ! This is exactly what I was looking for.