Skip to content

Conversation

@m-beau
Copy link

@m-beau m-beau commented Jan 6, 2026

Implements #4294

  • Add widget

@alejoe91 alejoe91 changed the title good times extension Good times extension Jan 6, 2026
@alejoe91 alejoe91 added the postprocessing Related to postprocessing module label Jan 6, 2026
@alejoe91
Copy link
Member

alejoe91 commented Jan 7, 2026

Depends on #4302

return sorting_analyzer

def _prepare_sorting_analyzer(self, format, sparse, extension_class):
def _compute_extensions_recursively(self, sorting_analyzer, extension_class, params):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh boy, this is a handy lil function!

Comment on lines 138 to 139
axs[0].set_ylabel("FP Rate")
axs[1].set_ylabel("FN Rate")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make these more descriptive? As a user I forget which one is related to amplitudes and which one is related to rp violations. But there isn't much room on the axis. Hmm.

periods_for_unit = np.zeros(len(starts), dtype=unit_period_dtype)
periods_for_unit_w_margins = np.zeros(len(starts), dtype=unit_period_dtype)
for i, start in enumerate(starts):
end = start + period_size_samples
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
end = start + period_size_samples
end = min(start + period_size_samples, n_samples)

At the moment, end can go past the recording length.

), "Either period_duration_s_absolute or period_target_num_spikes must be positive."
assert isinstance(period_target_num_spikes, (int)), "period_target_num_spikes must be an integer."

# user_defined_periods formatting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this section we're being too lenient with the user and it's a bit of a mess. I think you should reuse the logic from core (

def select_sorting_periods(sorting: BaseSorting, periods) -> BaseSorting:
) and be a bit stricter on what we demand.



class ComputeValidUnitPeriods(AnalyzerExtension):
"""Compute good time periods per unit based on quality metrics.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This docstring needs a tidy up

sorting_analyzer: SortingAnalyzer | None = None,
segment_index: int | None = None,
unit_ids: list | None = None,
show_only_units_with_valid_periods: bool = True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would default this to False - I wanna see why my bad unit are failing!

# need to recompute for merged units
recompute = True
else:
# in case of user-defined periods, just merge periods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have taken the intersection of the user periods, instead of merging them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? If you merge, you probably want to keep the units you had before. Anyways, I think this user-defined period won't be really used much in "production", but the idea is to be able to test new ideas

recompute_dict[extension_name] = extension.params

if len(recompute_dict) > 0:
recompute_dict = _sort_extensions_by_dependency(recompute_dict)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
recompute_dict = _sort_extensions_by_dependency(recompute_dict)

compute_several_extensions handles this

recompute_dict = {}
for extension_name, extension in self.extensions.items():
extensions_to_compute = _sort_extensions_by_dependency(
{ext.name: ext.params for ext in self.extensions.values()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ext.name: ext.params for ext in self.extensions.values()}
{ext.extension_name: ext.params for ext in self.extensions.values()}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

postprocessing Related to postprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants