Skip to content

Commit

Permalink
Merge branch 'main' into waveform_tools_speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin authored Sep 12, 2023
2 parents e37b051 + 31f679f commit 4466884
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black
files: ^src/
2 changes: 1 addition & 1 deletion src/spikeinterface/preprocessing/normalize_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def __init__(
means = means[None, :]
stds = np.std(random_data, axis=0)
stds = stds[None, :]
gain = 1 / stds
gain = 1.0 / stds
offset = -means / stds

if int_scale is not None:
Expand Down
15 changes: 10 additions & 5 deletions src/spikeinterface/preprocessing/tests/test_normalize_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,18 @@ def test_zscore():
assert np.all(np.abs(np.mean(tr, axis=0)) < 0.01)
assert np.all(np.abs(np.std(tr, axis=0) - 1) < 0.01)


def test_zscore_int():
seed = 1
rec = generate_recording(seed=seed, mode="legacy")
rec_int = scale(rec, dtype="int16", gain=100)
with pytest.raises(AssertionError):
rec4 = zscore(rec_int, dtype=None)
rec4 = zscore(rec_int, dtype="int16", int_scale=256, mode="mean+std", seed=seed)
tr = rec4.get_traces(segment_index=0)
trace_mean = np.mean(tr, axis=0)
trace_std = np.std(tr, axis=0)
zscore(rec_int, dtype=None)

zscore_recording = zscore(rec_int, dtype="int16", int_scale=256, mode="mean+std", seed=seed)
traces = zscore_recording.get_traces(segment_index=0)
trace_mean = np.mean(traces, axis=0)
trace_std = np.std(traces, axis=0)
assert np.all(np.abs(trace_mean) < 1)
assert np.all(np.abs(trace_std - 256) < 1)

Expand Down

0 comments on commit 4466884

Please sign in to comment.