From 0b0d46a22950c5e8c0f4fee7f88efc28a0bd2e0b Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 30 Oct 2023 21:12:44 -0400 Subject: [PATCH 1/2] remove experimental warning for get_params_diff() --- mesmerize_core/caiman_extensions/common.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mesmerize_core/caiman_extensions/common.py b/mesmerize_core/caiman_extensions/common.py index 3cada53..c514329 100644 --- a/mesmerize_core/caiman_extensions/common.py +++ b/mesmerize_core/caiman_extensions/common.py @@ -245,7 +245,6 @@ def remove_item(self, index: Union[int, str, UUID], remove_data: bool = True, sa # Save new df to disc self._df.to_pickle(self._df.paths.get_batch_path()) - @warning_experimental("This feature is new and the might improve in the future") def get_params_diffs(self, algo: str, item_name: str) -> pd.DataFrame: """ Get the parameters that differ for a given `item_name` run with a given `algo` From adff581e1c621039e4c944cce86e1fb425702eba Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 30 Oct 2023 21:13:04 -0400 Subject: [PATCH 2/2] add option to add residuals when returning temporal --- mesmerize_core/caiman_extensions/cnmf.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mesmerize_core/caiman_extensions/cnmf.py b/mesmerize_core/caiman_extensions/cnmf.py index d3a4985..469fc4d 100644 --- a/mesmerize_core/caiman_extensions/cnmf.py +++ b/mesmerize_core/caiman_extensions/cnmf.py @@ -315,7 +315,11 @@ def get_contours( @_component_indices_parser @cnmf_cache.use_cache def get_temporal( - self, component_indices: Union[np.ndarray, str] = None, add_background: bool = False, return_copy=True + self, + component_indices: Union[np.ndarray, str] = None, + add_background: bool = False, + add_residuals: bool = False, + return_copy=True ) -> np.ndarray: """ Get the temporal components for this CNMF item, basically ``CNMF.estimates.C`` @@ -329,8 +333,11 @@ def get_temporal( | if ``"bad"`` uses bad components, i.e. ``Estimates.idx_components_bad`` | if ``np.ndarray``, uses the indices in the provided array - add_background: bool - if ``True``, add the temporal background, ``cnmf.estimates.C + cnmf.estimates.f`` + add_background: bool, default False + if ``True``, add the temporal background, adds ``cnmf.estimates.f`` + + add_residuals: bool, default False + if ``True``, add residuals, i.e. ``cnmf.estimates.YrA`` return_copy: bool | if ``True`` returns a copy of the cached value in memory. @@ -369,10 +376,14 @@ def get_temporal( C = cnmf_obj.estimates.C[component_indices] f = cnmf_obj.estimates.f + temporal = C + if add_background: - return C + f - else: - return C + temporal += f + elif add_residuals: + temporal += cnmf_obj.estimates.YrA + + return temporal @validate("cnmf") @_component_indices_parser