diff --git a/caiman/source_extraction/cnmf/estimates.py b/caiman/source_extraction/cnmf/estimates.py index 432c670db..9351a6de1 100644 --- a/caiman/source_extraction/cnmf/estimates.py +++ b/caiman/source_extraction/cnmf/estimates.py @@ -1310,9 +1310,12 @@ def remove_duplicates(self, predictions=None, r_values=None, dist_thr=0.1, else: components_to_keep = np.arange(self.A.shape[-1]) - - - self.select_components(idx_components=components_to_keep) + if self.idx_components is None: + self.idx_components = np.arange(self.A.shape[-1]) + self.idx_components = np.intersect1d(self.idx_components, components_to_keep) + self.idx_components_bad = np.setdiff1d(np.arange(self.A.shape[-1]), self.idx_components) + if select_comp: + self.select_components(use_object=True) return components_to_keep