Skip to content
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

Fix: Correct unit ID matching in sortingview curation #2037

Merged
merged 17 commits into from
Oct 2, 2023
Merged

Fix: Correct unit ID matching in sortingview curation #2037

merged 17 commits into from
Oct 2, 2023

Conversation

rkim48
Copy link
Contributor

@rkim48 rkim48 commented Sep 24, 2023

Issue:
In the process of applying sortingview curation for unit ids of dtype int, the function was using an "in" operator to match unit_id with unit_label, which resulted in false positives. For instance, a unit_id of 10 would mistakenly match a unit_label of 1.

Fix:
Enhanced the unit ID matching logic to handle both integer and string types properly, ensuring correct unit curation.
Added split logic for merged units to correctly identify individual unit parts.

Test introduced:
Introduced a unit test test_false_positive_curation() in test_sortingview_curation.py to capture the false-positive scenario, ensuring unit_id 10 doesn't get labeled when unit_label 1 is specified. It also ensures correct curation for both int and string type unit IDs.

Additional information:
I am using Mountainsort5.

rkim48 and others added 3 commits September 24, 2023 13:51
Refine the logic for matching unit IDs in the sortingview curation process.
Instead of using a potentially ambiguous containment check, unit IDs are
now split at the '-' character, ensuring accurate mapping between unit labels
and merged unit IDs.

Additionally, introduced a unit test to validate the improved behavior and
guard against potential false positives in future changes.
@alejoe91 alejoe91 added the curation Related to curation module label Sep 25, 2023
@alejoe91
Copy link
Member

Thanks @rkim48

I have one comment. In case of str units, after a merge, the merged unit (e.g. ,"8-9") inherits the labels from individual units. This is because if unit "8"` has a label, this line will be True:

if unit_label in unit_id_parts:

# "8" in ("8", "9"):

However, this is not the case for int units. My suggestion would be to convert all unit ids to strings when applying sortingview curation. Note that we have been discussing about forcing unit and channel IDs to always be strings: #1432

@rkim48
Copy link
Contributor Author

rkim48 commented Sep 27, 2023

@alejoe91

Thanks for the feedback. Can you check my latest commit?
I think it takes care of that issue.
I'm new to spikeinterface and pull requests so let me know if there is something I overlooked (using a lot of GPT-4).

Copy link
Collaborator

@zm711 zm711 left a comment

Choose a reason for hiding this comment

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

I don't think it is necessary to have print('success') statements in general for testing since in the case of success they will pass silently and in the case of failure they won't ever be triggered.

Copy link
Member

@alejoe91 alejoe91 left a comment

Choose a reason for hiding this comment

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

@rkim48 thanks for the changes. I think that we could simplify a lot the implementation.
See my comments (I hope they are clear!)

src/spikeinterface/curation/sortingview_curation.py Outdated Show resolved Hide resolved
src/spikeinterface/curation/sortingview_curation.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@rkim48 rkim48 left a comment

Choose a reason for hiding this comment

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

Requested changes have been made

@alejoe91 alejoe91 merged commit 8c35a3a into SpikeInterface:main Oct 2, 2023
8 checks passed
@rkim48 rkim48 deleted the fix-unit-id-matching branch October 2, 2023 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
curation Related to curation module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants