Skip to content

Commit

Permalink
feat(spike_sorting): handle cases when no units/spikes are found
Browse files Browse the repository at this point in the history
  • Loading branch information
ttngu207 committed Oct 8, 2024
1 parent 3ab94dd commit 463ec52
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions element_array_ephys/spike_sorting/si_spike_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,17 @@ def make(self, key):

analyzer_output_dir = output_dir / sorter_name / "sorting_analyzer"

has_units = si_sorting.unit_ids.size > 0

@memoized_result(
uniqueness_dict=postprocessing_params,
output_directory=analyzer_output_dir,
)
def _sorting_analyzer_compute():
if not has_units:
log.info("No units found in sorting object. Skipping sorting analyzer.")
return

# Sorting Analyzer
sorting_analyzer = si.create_sorting_analyzer(
sorting=si_sorting,
Expand All @@ -303,6 +309,8 @@ def _sorting_analyzer_compute():

_sorting_analyzer_compute()

do_si_export = postprocessing_params.get("export_to_phy", False) or postprocessing_params.get("export_report", False)

self.insert1(
{
**key,
Expand All @@ -311,8 +319,7 @@ def _sorting_analyzer_compute():
datetime.utcnow() - execution_time
).total_seconds()
/ 3600,
"do_si_export": postprocessing_params.get("export_to_phy", False)
or postprocessing_params.get("export_report", False),
"do_si_export": do_si_export and has_units,
}
)

Expand Down

0 comments on commit 463ec52

Please sign in to comment.