nel-lab / mesmerize-core

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

How to pass var_name_hdf5 when running mcorr #197

Open oterocoronel opened 1 year ago

oterocoronel commented 1 year ago

I have some .h5 files that have the data in a field named 'data'. I have tried passing var_name_hdf5 = 'data' when adding an additional parameter like this:

df.caiman.add_item(
    algo='mcorr',
    input_movie_path=movie_path,
    params=mcorr_params1,
    item_name=movie_path.stem,  
    var_name_hdf5 = 'data'
) 

But when trying to actually run mcorr, it fails. The output is:

{'success': False,
 'traceback': 'Traceback (most recent call last):\n  File "/home/lab/.mambaforge/envs/mescore/lib/python3.10/site-packages/mesmerize_core/algorithms/mcorr.py", line 67, in run_algo\n    mc.motion_correct(save_movie=True)\n  File "/home/lab/.mambaforge/envs/mescore/lib/python3.10/site-packages/caiman/motion_correction.py", line 249, in motion_correct\n    mi = min(mi, next(iterator).min()[()])\n  File "/home/lab/.mambaforge/envs/mescore/lib/python3.10/site-packages/caiman/base/movies.py", line 2254, in load_iter\n    for y in Y:\nTypeError: \'NoneType\' object is not iterable\n'}

I suspect that the issue is that when trying to run MotionCorrection, it is only passing the motion parameters. This is easy to fix in CaImAn vanilla, because I can invoke it like this:

mc = MotionCorrect(fnames, dview=dview, var_name_hdf5='data', **opts.get_group('motion'))

Any suggestions? Thanks!

X4ndri commented 1 year ago

I was about to open an issue about the same thing.

kushalkolar commented 1 year ago

This would require adding a key to the params dict, call it "MotionCorrect-constructor", which is a dict of kwargs then checking if it exists and dumping it here: https://github.com/nel-lab/mesmerize-core/blob/master/mesmerize_core/algorithms/mcorr.py#L66

I could do a PR later today, unless you want to try it out?