nel-lab / mesmerize-core

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

Running mcorr doesn't computer pnr image #220

Closed X4ndri closed 1 year ago

X4ndri commented 1 year ago

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[30], line 1
----> 1 selected_row.caiman.get_pnr_image()

File ~/miniconda3/envs/mescore/lib/python3.10/site-packages/mesmerize_core/caiman_extensions/_utils.py:25, in validate.<locals>.dec.<locals>.wrapper(self, *args, **kwargs)
     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)

File ~/miniconda3/envs/mescore/lib/python3.10/site-packages/mesmerize_core/caiman_extensions/common.py:570, in CaimanSeriesExtensions.get_pnr_image(self)
    562 @validate()
    563 def get_pnr_image(self) -> np.ndarray:
    564     """
    565     Returns
    566     -------
    567     np.ndarray
    568         pnr image
    569     """
--> 570     path = self._series.paths.resolve(self._series["outputs"]["pnr-image-path"])
    571     return np.load(str(path))

KeyError: 'pnr-image-path'

Indeed the outputs dictionary does not have a pnr-image-path key. Is that normal? I can compute it manually by importing caiman's built-in utils nonetheless.

kushalkolar commented 1 year ago

You're right, the PNR image isn't calculated in any of the algo runners. We probably put that there as a placeholder.

Anyways, we decided that it doesn't make sense to calculate the PNR in a batch item. You can use it interactively to decide the corr pnr thresholds for seeding CNMFE, explained in the demo: https://github.com/nel-lab/mesmerize-core/blob/master/notebooks/cnmfe.ipynb

kushalkolar commented 1 year ago

closing due to inactivity, welcome to reopen :)