nel-lab / mesmerize-core

High level pandas-based API for batch analysis of Calcium Imaging data using CaImAn
Other
60 stars 15 forks source link

lazy loading hdf5 files #173

Closed vncntprvst closed 1 year ago

vncntprvst commented 1 year ago

Hi, This issue was discussed during the recent workshop. @kushalkolar and @ArjunPutcha mentioned that loading hdf5 files was part of a PR. Has this code been integrated yet? Or could you post an example code to load hdf5 files for mesmerize? This is an important feature for Bruker 2P setups, where data can be saved either in a binary file or individual tif files. In our analysis pipeline, we concatenate tif files and save the stack as hdf5 file (which is smaller than creating a tiff stack). We have a function to load that file into caiman, but that does not work for mesmerize. Thanks for your help.

kushalkolar commented 1 year ago

this should work as shown in the workshop

import h5py

def hdf5_reader(path):
    f = h5py.File(path)
    return f["your-key"]

just pass hdf5_reader to caiman.get_input_movie()

vncntprvst commented 1 year ago

Thanks! In case anyone looks for this, if one doesn't know the file's key(s) - e.g., if the data comes from someone else - they can be found for a file f = h5py.File(movie_path) with print(f.keys()).