Skip to content

Commit 0759a76

Browse files
committed
Simplify environment
1 parent 2388b24 commit 0759a76

10 files changed

+71
-15
lines changed

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ dependencies:
99
- scikit-learn
1010
- hdbscan
1111
- colorcet
12+
- pytest

requirements.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
pytest
2-
ibl-neuropixel
31
spikeinterface
4-
cloudpickle

tests/test_detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import torch
33
from dartsort.detect.detect import detect_and_deduplicate
44
from dartsort.util.waveform_util import make_channel_index
5-
from neuropixel import dense_layout
5+
from test_util import dense_layout
66

77

88
def test_detect_and_deduplicate():

tests/test_enforce_decrease.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from dartsort.transform.enforce_decrease import (EnforceDecrease,
44
make_parents_index)
55
from dartsort.util.waveform_util import make_channel_index
6-
from neuropixel import dense_layout
6+
from test_util import dense_layout
77

88

99
def test_make_parents_index():
@@ -13,7 +13,5 @@ def test_make_parents_index():
1313
parents_index = make_parents_index(geom, channel_index)
1414
assert parents_index.shape[0] == channel_index.shape[0]
1515

16-
enfdec = EnforceDecrease(
17-
torch.as_tensor(channel_index), torch.as_tensor(geom)
18-
)
16+
enfdec = EnforceDecrease(torch.as_tensor(channel_index), torch.as_tensor(geom))
1917
assert enfdec is not None

tests/test_localize_torch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import torch
33
from dartsort.localize import localize_torch
44
from dartsort.util.waveform_util import make_channel_index
5-
from neuropixel import dense_layout
5+
from test_util import dense_layout
66

77

88
def test_localize_torch():

tests/test_relocate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
from dartsort.cluster import relocate
77
from dartsort.util import drift_util, waveform_util
8-
from neuropixel import dense_layout
8+
from test_util import dense_layout
99

1010
h = dense_layout()
1111
geom = np.c_[h["x"], h["y"]]

tests/test_subtract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from dartsort.localize.localize_torch import point_source_amplitude_at
1010
from dartsort.main import subtract
1111
from dartsort.util import waveform_util
12-
from neuropixel import dense_layout
12+
from test_util import dense_layout
1313

1414

1515
def test_fakedata_nonn():

tests/test_transform.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import neuropixel
21
import numpy as np
3-
import torch
42
from dartsort.transform import WaveformPipeline, transformers_by_class_name
53
from dartsort.util.waveform_util import make_channel_index
4+
from test_util import dense_layout
65

76

87
def test_all_transformers():
98
# make a bunch of fake waveforms, put all of the transformers into
109
# one long pipeline, and try running its fit and forward
11-
h = neuropixel.dense_layout()
10+
h = dense_layout()
1211
geom = np.c_[h["x"], h["y"]]
1312
channel_index = make_channel_index(geom, 100)
1413
rg = np.random.default_rng(0)

tests/test_util.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,64 @@ def no_overlap_recording_sorting(templates, fs=30000, trough_offset_samples=42,
2424
),
2525
)
2626
return rec, sorting
27+
28+
29+
def rc2xy(row, col, version=1):
30+
"""
31+
converts the row/col indices to um coordinates.
32+
:param row: row index on the probe
33+
:param col: col index on the probe
34+
:param version: neuropixel major version 1 or 2
35+
:return: dictionary with keys x and y
36+
"""
37+
if version == 1:
38+
x = col * 16 + 11
39+
y = (row * 20) + 20
40+
elif np.floor(version) == 2:
41+
x = col * 32
42+
y = row * 15
43+
return {"x": x, "y": y}
44+
45+
46+
def dense_layout(version=1, nshank=1, NC=384):
47+
"""Copied from ibl-neuropixel
48+
49+
Returns a dense layout indices map for neuropixel, as used at IBL
50+
:param version: major version number: 1 or 2 or 2.4
51+
:return: dictionary with keys 'ind', 'col', 'row', 'x', 'y'
52+
"""
53+
ch = {
54+
"ind": np.arange(NC),
55+
"row": np.floor(np.arange(NC) / 2),
56+
"shank": np.zeros(NC),
57+
}
58+
59+
if version == 1: # version 1 has a dense layout, checkerboard pattern
60+
ch.update({"col": np.tile(np.array([2, 0, 3, 1]), int(NC / 4))})
61+
elif (
62+
np.floor(version) == 2 and nshank == 1
63+
): # single shank NP1 has 2 columns in a dense patter
64+
ch.update({"col": np.tile(np.array([0, 1]), int(NC / 2))})
65+
elif (
66+
np.floor(version) == 2 and nshank == 4
67+
): # the 4 shank version default is rather complicated
68+
shank_row = np.tile(np.arange(NC / 16), (2, 1)).T[:, np.newaxis].flatten()
69+
shank_row = np.tile(shank_row, 8)
70+
shank_row += (
71+
np.tile(
72+
np.array([0, 0, 1, 1, 0, 0, 1, 1])[:, np.newaxis], (1, int(NC / 8))
73+
).flatten()
74+
* 24
75+
)
76+
ch.update(
77+
{
78+
"col": np.tile(np.array([0, 1]), int(NC / 2)),
79+
"shank": np.tile(
80+
np.array([0, 1, 0, 1, 2, 3, 2, 3])[:, np.newaxis], (1, int(NC / 8))
81+
).flatten(),
82+
"row": shank_row,
83+
}
84+
)
85+
# for all, get coordinates
86+
ch.update(rc2xy(ch["row"], ch["col"], version=version))
87+
return ch

tests/test_waveform_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import torch
33
import torch.nn.functional as F
44
from dartsort.util import waveform_util
5-
from neuropixel import dense_layout
5+
from test_util import dense_layout
66

77

88
def test_make_channel_index():

0 commit comments

Comments
 (0)