Skip to content

Clean up code around create_sorting_analyzer and create/load_* functions in sortinganalyzer.py - #4680

Merged
alejoe91 merged 17 commits into
SpikeInterface:mainfrom
ecobost:cleanup_sa_loading
Jul 21, 2026
Merged

alejoe91 merged 17 commits into
SpikeInterface:mainfrom
ecobost:cleanup_sa_loading

Conversation

@ecobost

@ecobost ecobost commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This PR does not functionally change much. It is mainly for code refactoring and to improve legibility.

The only two functional changes are:

  • fix small bug when calling save_to_zarr("test.zarr") would add an extra .zarr to the filename (
    zarr_path = cache_folder / f"{name}.zarr"
    )
  • when return_scaled and return_in_uV are provided, prioritize return_in_uV. Currently, it prefers return_scaled over return_in_uV

Code quality improvements:

  • type hinting
  • Collect code into logical blocks (e..g, everything that has to do wit main indices together); add comment headers (e.g., Saving main indices) and reorder this blocks (e.g., expected stuff like sorting should be saved and loaded before any of the optional things like sparsity)
  • Make create_binary_folder parallel create_zarr (you can now see how they are both doing exactly the same).
  • Make load_binary_folder parallel load_zarr.
  • Preserve the same order of operations when loading and saving. If sorting was saved first, then load first and so on.
  • Tighten code when possible

@ecobost
ecobost force-pushed the cleanup_sa_loading branch from 3349bd9 to 754c84f Compare July 10, 2026 14:06

@zm711 zm711 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few initial comments.

Comment thread src/spikeinterface/core/base.py
Comment thread src/spikeinterface/core/sortinganalyzer.py
Comment thread src/spikeinterface/core/sortinganalyzer.py
Comment thread src/spikeinterface/core/sortinganalyzer.py Outdated
Comment thread src/spikeinterface/core/sortinganalyzer.py
@alejoe91 alejoe91 added core Changes to core module refactor Refactor of code, with no change to functionality Edinburgh hackathon 2026 PRs from Edinburgh hackathon 2026 labels Jul 14, 2026
@alejoe91 alejoe91 added this to the 0.105.0 milestone Jul 15, 2026
Comment thread src/spikeinterface/core/sortinganalyzer.py Outdated

@alejoe91 alejoe91 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @ecobost

Much cleaner :) I have a few suggestions/comments. Could you tackle them? Then this is good to go for me!

Comment thread src/spikeinterface/core/sortinganalyzer.py Outdated
Comment thread src/spikeinterface/core/sortinganalyzer.py Outdated
Comment thread src/spikeinterface/core/sortinganalyzer.py Outdated
Comment thread src/spikeinterface/core/sortinganalyzer.py Outdated
Comment thread src/spikeinterface/core/sortinganalyzer.py Outdated
Comment thread src/spikeinterface/core/sortinganalyzer.py
@ecobost

ecobost commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@alejoe91 Couple of comments still open. Let me know when this version is ok to fix merge issues (don't wanna pollute current version)

@alejoe91

Copy link
Copy Markdown
Member

@ecobost replied to the standing comments! Let's continue and fix the conflicts

@ecobost
ecobost force-pushed the cleanup_sa_loading branch from 0902f77 to 62154d2 Compare July 20, 2026 20:53
@ecobost
ecobost requested a review from alejoe91 July 20, 2026 21:15
Comment thread src/spikeinterface/core/sortinganalyzer.py Outdated
Comment thread src/spikeinterface/core/basesorting.py Outdated
Comment thread src/spikeinterface/core/sortinganalyzer.py

@chrishalcrow chrishalcrow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is fine by me. Would be great to propagate the PeakSign and PeakMode typing across the codebase. Would fix some incorrect typing (

amplitude_mode: Literal["extremum", "peak_to_peak"] = "extremum",
) !! Can do that in a follow up.

alejoe91 and others added 2 commits July 21, 2026 13:55
Co-authored-by: Chris Halcrow <57948917+chrishalcrow@users.noreply.github.com>
@alejoe91
alejoe91 merged commit 83b94f2 into SpikeInterface:main Jul 21, 2026
17 checks passed
@ecobost
ecobost deleted the cleanup_sa_loading branch July 22, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core module Edinburgh hackathon 2026 PRs from Edinburgh hackathon 2026 refactor Refactor of code, with no change to functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants