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

cnmfe component evaluation load batch hdf5 vs. mmap file #239

Closed zhouyi0812 closed 1 year ago

zhouyi0812 commented 1 year ago

Hello!

I wonder after cnmf-e I got batch of results with demo data. And then trying to viz and eval. But I found the files were saved as .hdf5 rather than .mmap, how can I continue with it? Thank you!

You can change this to plot the outputs for different batch items
index = 1

get the motion corrected input movie as a memmap
cnmf_movie = df.iloc[index].caiman.get_input_movie()

 we can get the contours of the spatial components
contours, coms = df.iloc[index].cnmf.get_contours("all", swap_dim=False)

 and temporal components
temporal = df.iloc[index].cnmf.get_temporal("all")

ixs_good = df.iloc[index].cnmf.get_good_components()
ixs_bad = df.iloc[index].cnmf.get_bad_components()

BatchItemUnsuccessfulError                Traceback (most recent call last)
Cell In[20], line 8
      5 cnmf_movie = df.iloc[index].caiman.get_input_movie()
      7 # we can get the contours of the spatial components
----> 8 contours, coms = df.iloc[index].cnmf.get_contours("all", swap_dim=False)
     10 # and temporal components
     11 temporal = df.iloc[index].cnmf.get_temporal("all")

File C:\Users\Public\anaconda3\envs\mescore\lib\site-packages\mesmerize_core\caiman_extensions\_utils.py:24, in validate.<locals>.dec.<locals>.wrapper(self, *args, **kwargs)
     22 if not self._series["outputs"]["success"]:
     23     tb = self._series["outputs"]["traceback"]
---> 24     raise BatchItemUnsuccessfulError(f"Batch item was unsuccessful, traceback from subprocess:\n{tb}")
     25 return func(self, *args, **kwargs)

BatchItemUnsuccessfulError: Batch item was unsuccessful, traceback from subprocess:
Traceback (most recent call last):
  File "C:\Users\Public\anaconda3\envs\mescore\lib\site-packages\mesmerize_core\algorithms\cnmfe.py", line 97, in run_algo
    d["cnmf-hdf5-path"] = cnmf_hdf5_path.relative_to(output_dir.parent)
  File "C:\Users\Public\anaconda3\envs\mescore\lib\pathlib.py", line 818, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: 'C:\\Users\\Public\\anaconda3\\caiman_data\\mesmerize-cnmfe\\fdeb586a-3947-4db7-bcab-fd77f0ebd466\\fdeb586a-3947-4db7-bcab-fd77f0ebd466.hdf5' is not in the subpath of '\\Users\\Public\\anaconda3\\caiman_data\\mesmerize-cnmfe' OR one path is relative and the other is absolute.
kushalkolar commented 1 year ago

Yes the output of CNMFE is an hdf5 file which is saved by caiman, it has the estimates object. df.iloc[index].cnmf.get_output() will give you the hdf5 file, and the other function will give you things like temporal components, contours etc.

Anyways the error message here is probably because you did not set the parent data path before running the cnmfe item.

kushalkolar commented 1 year ago

closing due to inactivity