PeyracheLab / miniscoPy

A package to analyse calcium imaging data recorded with the Miniscope.
GNU General Public License v2.0
32 stars 9 forks source link

Allow passing of .hdf5 filename to normcorre() instead of .avi filenames #14

Closed linamnt closed 6 years ago

linamnt commented 6 years ago

This is more of a minor feature request.

I understand that it's impossible to have your code be able to read all video formats, but since miniscopy is already built to work with .hdf5, it might make sense to have users that use other file formats to convert their files to .hdf5 format (rather than converting to .avi) similar to the structure of the hdf5 files created in get_hdf_file(). This would bypass the first two lines of code in normcorre if the file is already .hdf5.

I can submit a PR if you'd like.

gviejo commented 6 years ago

Hi, This is easy things to do. Can you send me a small hdf5 example to have a look at how your would order dimensions? Best Guillaume

linamnt commented 6 years ago

Do you mean how we convert our videos to hdf5? Or do you mean a sample hdf5 file that we've converted?

This is basically the code:

    # where Y is the video in the shape: frames x width x height

    tdim, xdim, ydim = Y.shape
    movie = file.create_dataset('movie', shape = (tdim, xdim*ydim), chunks = True)

    file.attrs['folder'] = dirname
    file.attrs['filename'] = basename

    file['movie'].attrs['duration'] = tdim
    file['movie'].attrs['dims'] = (xdim, ydim)

    movie[:] = Y.reshape((tdim, xdim*ydim))

Thanks!

gviejo commented 6 years ago

Hello,

We have made the change you asked. To make it work :

  1. Write the path of your files in files = ['path/to/my/file.hdf5'] in the main script.
  2. The key of the movie should be 'original'. The key 'movie' is reserved for the corrected movie.
  3. If you restart a normcorre twice on the same hdf5 file, it will overwrite the previously corrected movie.

Let us know if it works.

Guillaume