-
Notifications
You must be signed in to change notification settings - Fork 191
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 dtype of quality metrics before and after merging #3497
Open
zm711
wants to merge
16
commits into
SpikeInterface:main
Choose a base branch
from
zm711:merge-qc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6527c90
fix dtype of quality metrics after merging
zm711 1e596f8
fix test
zm711 2e53fbf
Merge branch 'main' into merge-qc
zm711 aeab562
Merge branch 'main' into merge-qc
zm711 812376e
Alessio's idea
zm711 4a6b1e3
add int test
zm711 af5b93a
Merge branch 'main' into merge-qc
zm711 81307a6
Merge branch 'merge-qc' of https://github.com/zm711/spikeinterface in…
zm711 1f2e2f1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0cc1fa1
try different dtype approach
zm711 e175bdc
wip
zm711 bf96fe1
fix synchrony
zm711 a132acc
Merge branch 'main' into merge-qc
zm711 5b77ba1
fix nan and empty units
zm711 91c8a84
Merge branch 'merge-qc' of https://github.com/zm711/spikeinterface in…
zm711 807e771
fix test
zm711 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,34 @@ def test_compute_quality_metrics(sorting_analyzer_simple): | |
assert "isolation_distance" in metrics.columns | ||
|
||
|
||
def test_merging_quality_metrics(sorting_analyzer_simple): | ||
|
||
sorting_analyzer = sorting_analyzer_simple | ||
|
||
metrics = compute_quality_metrics( | ||
sorting_analyzer, | ||
metric_names=None, | ||
qm_params=dict(isi_violation=dict(isi_threshold_ms=2)), | ||
skip_pc_metrics=False, | ||
seed=2205, | ||
) | ||
|
||
# sorting_analyzer_simple has ten units | ||
new_sorting_analyzer = sorting_analyzer.merge_units([[0, 1]]) | ||
|
||
new_metrics = new_sorting_analyzer.get_extension("quality_metrics").get_data() | ||
|
||
# we should copy over the metrics after merge | ||
for column in metrics.columns: | ||
assert column in new_metrics.columns | ||
|
||
# 10 units vs 9 units | ||
assert len(metrics.index) > len(new_metrics.index) | ||
|
||
# dtype should be fine after merge but is cast from Float64->float64 | ||
assert np.float64 == new_metrics["snr"].dtype | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can add a test on int coercion if we end up using the suggestion here: https://github.com/SpikeInterface/spikeinterface/pull/3497/files#r1827487180 |
||
|
||
|
||
def test_compute_quality_metrics_recordingless(sorting_analyzer_simple): | ||
|
||
sorting_analyzer = sorting_analyzer_simple | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ok for me.
pandas behavior is becoming quite cryptic for me.
using old_metrics[col].dtype could be also used no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. I agree Pandas is making their own dtypes like NADType which doesn't play nicely with numpy in my scipts I tend to just query based on numpy stuff). So I don't know for sure. I could test that later. Although for me I would prefer to coerce everything to numpy types since that's what I'm used to. None of my tables are big enough that I worry about dtype inefficiency stuff that Pandas has been working on with the new backend.