Skip to content

Allow run_sorter to accept dicts #4005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

chrishalcrow
Copy link
Member

@chrishalcrow chrishalcrow commented Jun 23, 2025

Allows run_sorter to accept dictionaries of recordings, and return a dict of sorters.

Longer-term aim, make this workflow just work:

pp_recs = si.common_reference(rec.split_by(‘group’))
sortings = si.run_sorter(pp_rec)
analyzer = si.create_sorting_analyzer(sortings, pp_recordings)

Think this PR is minimally invasive. The old function run_sorter can now accept a dict. If it gets a dict, it calls run_sorter for each recording and saves in a folder

{folder}/
    spikeinterface_info.json
    splitting_key_0/
      {whatever run_sorter spits outs}
    splitting_key_1
        {whatever run_sorter spits outs}
    …

And spikeinterface_info.json looks like e.g.:

{
    "version": "0.102.4",
    "dev_mode": true,
    "object": "dict of BaseSorting",
    "dict_keys": [
        4,
        5
    ],
    "split_by_property": “group”
}

Tried a bigger refactor here: https://github.com/chrishalcrow/spikeinterface/tree/sort-by-group which avoids the recurrent logic here, but it was a mess. This seems a lot nicer.

@chrishalcrow chrishalcrow changed the title Allow for sort_by_dict Allow run_sorter to accept dicts Jun 23, 2025
@chrishalcrow chrishalcrow added the enhancement New feature or request label Jun 23, 2025
@alejoe91
Copy link
Member

@chrishalcrow maybe worth saving the dict_keys dtype in the spikeinterface_info since this gets lost when dumping to json

@samuelgarcia
Copy link
Member

Thank you Chris, this is cool.

We also need to implement the spikeinterface.load that handle to open this new folder type.

We should discuss a bit more the "object": "dict of BaseSorting"
I add in mind something like "Group[Sorting]"

Also not sure to clearly understand why we need this "split_by_property" in the dict because the information is dump in all sub-folder in recording.json no ?

@chrishalcrow maybe worth saving the dict_keys dtype in the spikeinterface_info since this gets lost when dumping to json

Not sure I like this ugly hack in the format spikeinterface_info.json.
List of keys can be int or str no ? json handle it.
The list is in the dict to open back the sub folder in the good order and will converted to str for folder.
So I do not see why.

I would be happy to have a call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants