UnitMatchPy 3.3.1__py3-none-any.whl → 3.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- UnitMatchPy/default_params.py +5 -1
- UnitMatchPy/param_functions.py +8 -0
- UnitMatchPy/utils.py +68 -6
- {unitmatchpy-3.3.1.dist-info → unitmatchpy-3.4.0.dist-info}/METADATA +12 -8
- {unitmatchpy-3.3.1.dist-info → unitmatchpy-3.4.0.dist-info}/RECORD +8 -8
- {unitmatchpy-3.3.1.dist-info → unitmatchpy-3.4.0.dist-info}/WHEEL +0 -0
- {unitmatchpy-3.3.1.dist-info → unitmatchpy-3.4.0.dist-info}/licenses/LICENSE +0 -0
- {unitmatchpy-3.3.1.dist-info → unitmatchpy-3.4.0.dist-info}/top_level.txt +0 -0
UnitMatchPy/default_params.py
CHANGED
|
@@ -17,7 +17,6 @@ def get_default_param(param = None):
|
|
|
17
17
|
tmp = {'spike_width' : 82, # will automatically update after loading in the waveform
|
|
18
18
|
'waveidx' : np.arange(33,56), # what idxs cover the spike
|
|
19
19
|
'channel_radius' : 150, # the max distance channels which a unit will consider
|
|
20
|
-
'peak_loc' : 40, # were the spike peak will be aligned to
|
|
21
20
|
'max_dist' : 100, # max distance for possible matches
|
|
22
21
|
'neighbour_dist' : 50,
|
|
23
22
|
'stepsz' : 0.01, # size of of a step in probability distributions
|
|
@@ -39,4 +38,9 @@ def get_default_param(param = None):
|
|
|
39
38
|
else:
|
|
40
39
|
#Add default parameters to param dictionary, does not overwrite pre existing param values
|
|
41
40
|
out = tmp | param
|
|
41
|
+
|
|
42
|
+
# peak_loc always follows floor(spike_width / 2) unless the caller set it explicitly
|
|
43
|
+
if param is None or 'peak_loc' not in param:
|
|
44
|
+
out['peak_loc'] = int(np.floor(out['spike_width'] / 2))
|
|
45
|
+
|
|
42
46
|
return out
|
UnitMatchPy/param_functions.py
CHANGED
|
@@ -196,6 +196,14 @@ def decay_and_average_waveform(waveform, channel_pos, good_idx, max_site, max_si
|
|
|
196
196
|
tmp_amp = tmp_amp[dist_to_max_chan != 0]
|
|
197
197
|
dist_to_max_chan = dist_to_max_chan[dist_to_max_chan != 0]
|
|
198
198
|
|
|
199
|
+
if len(tmp_amp) == 0:
|
|
200
|
+
# Only the max channel itself is within the radius — no spatial decay can be estimated.
|
|
201
|
+
# Fall back to channel_radius so downstream code has a safe d_10 value.
|
|
202
|
+
spatial_decay_fit[i, cv] = np.nan
|
|
203
|
+
spatial_decay[i, cv] = np.nan
|
|
204
|
+
d_10[i, cv] = channel_radius
|
|
205
|
+
continue
|
|
206
|
+
|
|
199
207
|
# there is variation in how different programming languages/options fit to a curve
|
|
200
208
|
popt, pcurve = sp.optimize.curve_fit(
|
|
201
209
|
exponential_func,
|
UnitMatchPy/utils.py
CHANGED
|
@@ -99,6 +99,48 @@ def get_within_session(session_id, param):
|
|
|
99
99
|
|
|
100
100
|
return within_session
|
|
101
101
|
|
|
102
|
+
def filter_units_by_index(waveform, session_id, session_switch, good_units, kept_idx, param):
|
|
103
|
+
"""
|
|
104
|
+
Re-synchronise all per-unit data structures after some units have been dropped
|
|
105
|
+
(e.g. by get_snippets filtering bad waveforms).
|
|
106
|
+
|
|
107
|
+
Parameters
|
|
108
|
+
----------
|
|
109
|
+
waveform : ndarray (n_units, spike_width, n_channels, cv)
|
|
110
|
+
session_id : ndarray (n_units,)
|
|
111
|
+
session_switch : ndarray (n_sessions+1,)
|
|
112
|
+
good_units : list of per-session cluster-ID arrays
|
|
113
|
+
kept_idx : ndarray of int — indices into the original n_units dimension that were kept
|
|
114
|
+
param : dict
|
|
115
|
+
|
|
116
|
+
Returns
|
|
117
|
+
-------
|
|
118
|
+
waveform, session_id, session_switch, within_session, good_units, param — all filtered
|
|
119
|
+
"""
|
|
120
|
+
n_dropped = len(session_id) - len(kept_idx)
|
|
121
|
+
if n_dropped > 0:
|
|
122
|
+
print(f"Filtering {n_dropped} unit(s) that were rejected by get_snippets.")
|
|
123
|
+
|
|
124
|
+
new_waveform = waveform[kept_idx]
|
|
125
|
+
n_sessions = param['n_sessions']
|
|
126
|
+
|
|
127
|
+
new_good_units = []
|
|
128
|
+
for s in range(n_sessions):
|
|
129
|
+
start, end = int(session_switch[s]), int(session_switch[s + 1])
|
|
130
|
+
in_session = kept_idx[(kept_idx >= start) & (kept_idx < end)] - start
|
|
131
|
+
new_good_units.append(good_units[s][in_session])
|
|
132
|
+
|
|
133
|
+
n_units_per_session = np.array([len(g) for g in new_good_units])
|
|
134
|
+
n_units, new_session_id, new_session_switch, _ = get_session_data(n_units_per_session)
|
|
135
|
+
|
|
136
|
+
param['n_units'] = n_units
|
|
137
|
+
param['good_units'] = new_good_units
|
|
138
|
+
param['n_channels'] = new_waveform.shape[2]
|
|
139
|
+
new_within_session = get_within_session(new_session_id, param)
|
|
140
|
+
|
|
141
|
+
return new_waveform, new_session_id, new_session_switch, new_within_session, new_good_units, param
|
|
142
|
+
|
|
143
|
+
|
|
102
144
|
def load_good_waveforms(wave_paths, unit_label_paths, param, good_units_only=True):
|
|
103
145
|
if len(wave_paths) == len(unit_label_paths):
|
|
104
146
|
n_sessions = len(wave_paths)
|
|
@@ -189,10 +231,13 @@ def load_good_waveforms(wave_paths, unit_label_paths, param, good_units_only=Tru
|
|
|
189
231
|
param['n_channels'] = waveform.shape[2]
|
|
190
232
|
param['n_units_per_session'] = n_units_per_session_all
|
|
191
233
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
234
|
+
actual_width = waveform.shape[1]
|
|
235
|
+
if param['spike_width'] != actual_width:
|
|
236
|
+
print(f"Warning: loaded waveform spike_width ({actual_width}) does not match "
|
|
237
|
+
f"param['spike_width'] ({param['spike_width']}). Updating to match data.")
|
|
238
|
+
param['spike_width'] = actual_width
|
|
239
|
+
param['peak_loc'] = int(np.floor(actual_width / 2))
|
|
240
|
+
param['waveidx'] = np.arange(param['peak_loc'] - 8, param['peak_loc'] + 15, dtype=int)
|
|
196
241
|
|
|
197
242
|
return waveform, session_id, session_switch, within_session, good_units, param
|
|
198
243
|
|
|
@@ -506,7 +551,7 @@ def fill_missing_pos(KS_dir, n_channels):
|
|
|
506
551
|
' Have returned the known channel positions and NaN')
|
|
507
552
|
return channel_pos
|
|
508
553
|
|
|
509
|
-
def paths_from_KS(KS_dirs, custom_raw_waveform_paths=None, custom_bombcell_paths=None):
|
|
554
|
+
def paths_from_KS(KS_dirs, param=None, custom_raw_waveform_paths=None, custom_bombcell_paths=None):
|
|
510
555
|
"""
|
|
511
556
|
This function will find specific paths to required files from a KiloSort directory
|
|
512
557
|
or use custom paths if provided
|
|
@@ -515,6 +560,9 @@ def paths_from_KS(KS_dirs, custom_raw_waveform_paths=None, custom_bombcell_paths
|
|
|
515
560
|
----------
|
|
516
561
|
KS_dirs : list
|
|
517
562
|
The list of paths to the KiloSort directory for each session
|
|
563
|
+
param : dict, optional
|
|
564
|
+
Parameter dictionary. If provided, spike_width and peak_loc are updated
|
|
565
|
+
from the waveform files found in KS_dirs.
|
|
518
566
|
custom_raw_waveform_paths : list, optional
|
|
519
567
|
Custom paths to raw waveform directories for each session. If provided,
|
|
520
568
|
these will be used instead of searching within KS_dirs
|
|
@@ -556,16 +604,30 @@ def paths_from_KS(KS_dirs, custom_raw_waveform_paths=None, custom_bombcell_paths
|
|
|
556
604
|
wave_paths.append( os.path.join(KS_dirs[i],'bombcell', 'RawWaveforms'))
|
|
557
605
|
else:
|
|
558
606
|
raise Exception('Could not find RawWaveforms folder')
|
|
559
|
-
#load in a waveform from each session to get the number of channels
|
|
607
|
+
#load in a waveform from each session to get the number of channels and spike_width
|
|
560
608
|
n_channels = []
|
|
609
|
+
spike_widths = []
|
|
561
610
|
for i in range(n_sessions):
|
|
562
611
|
path_tmp = wave_paths[i]
|
|
563
612
|
file = os.listdir(path_tmp)
|
|
564
613
|
waveform_tmp = np.load(os.path.join(path_tmp,file[0]))
|
|
565
614
|
n_channels.append(waveform_tmp.shape[1])
|
|
615
|
+
spike_widths.append(waveform_tmp.shape[0])
|
|
566
616
|
|
|
567
617
|
os.chdir(tmp)
|
|
568
618
|
|
|
619
|
+
if param is not None:
|
|
620
|
+
unique_widths = set(spike_widths)
|
|
621
|
+
if len(unique_widths) > 1:
|
|
622
|
+
print(f"Warning: sessions have inconsistent spike_width values {spike_widths}. "
|
|
623
|
+
f"Using the first session's value ({spike_widths[0]}); check your data.")
|
|
624
|
+
detected_width = spike_widths[0]
|
|
625
|
+
if 'spike_width' in param and param['spike_width'] != detected_width:
|
|
626
|
+
print(f"Updating spike_width from {param['spike_width']} to {detected_width} based on waveform files.")
|
|
627
|
+
param['spike_width'] = detected_width
|
|
628
|
+
param['peak_loc'] = int(np.floor(detected_width / 2))
|
|
629
|
+
param['waveidx'] = np.arange(param['peak_loc'] - 8, param['peak_loc'] + 15, dtype=int)
|
|
630
|
+
|
|
569
631
|
#Load channel_pos
|
|
570
632
|
channel_pos = []
|
|
571
633
|
for i in range(n_sessions):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: UnitMatchPy
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Automatic matching of neurons across sessions
|
|
5
5
|
Author: Enny van Beest, Célian Bimbard, Suyash Agarwal, Wentao Qiu
|
|
6
6
|
License: CC BY-NC-SA 4.0 International
|
|
@@ -13,16 +13,20 @@ Classifier: Operating System :: OS Independent
|
|
|
13
13
|
Requires-Python: <3.13,>=3.9
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: numpy<
|
|
17
|
-
Requires-Dist: scipy<2.0,>=1.
|
|
18
|
-
Requires-Dist: pandas<3.0,>=
|
|
19
|
-
Requires-Dist: matplotlib<4.0,>=3.
|
|
16
|
+
Requires-Dist: numpy<3.0,>=1.21
|
|
17
|
+
Requires-Dist: scipy<2.0,>=1.13
|
|
18
|
+
Requires-Dist: pandas<3.0,>=2.2
|
|
19
|
+
Requires-Dist: matplotlib<4.0,>=3.9
|
|
20
20
|
Requires-Dist: joblib<2.0,>=1.2
|
|
21
21
|
Requires-Dist: tqdm<5.0,>=4.64
|
|
22
|
-
Requires-Dist: h5py<4.0,>=3.
|
|
23
|
-
Requires-Dist: scikit-learn<2.0,>=1.
|
|
22
|
+
Requires-Dist: h5py<4.0,>=3.11
|
|
23
|
+
Requires-Dist: scikit-learn<2.0,>=1.5
|
|
24
24
|
Requires-Dist: mtscomp
|
|
25
|
-
Requires-Dist: torch<3.0,>=2.
|
|
25
|
+
Requires-Dist: torch<3.0,>=2.3
|
|
26
|
+
Requires-Dist: tensorboard
|
|
27
|
+
Requires-Dist: seaborn
|
|
28
|
+
Requires-Dist: matplotlib_venn
|
|
29
|
+
Requires-Dist: statsmodels
|
|
26
30
|
Provides-Extra: full
|
|
27
31
|
Requires-Dist: mat73<1.0,>=0.62; extra == "full"
|
|
28
32
|
Requires-Dist: spikeinterface<0.120,>=0.100; extra == "full"
|
|
@@ -4,14 +4,14 @@ UnitMatchPy/UM Logo.ico,sha256=slwTUp3OGJzWtb0HkEu1xugU_CMeNv3ZrxrfnzKK4Pw,14872
|
|
|
4
4
|
UnitMatchPy/__init__.py,sha256=k7uCoTM8FbOhi1TV3tIgBUtuUwhRxh_pl5bebKAHwiM,268
|
|
5
5
|
UnitMatchPy/assign_unique_id.py,sha256=sBsjfamkuy6yY9GxHQ7oQJSvpUSxXk2uoVYNpxMF83k,8413
|
|
6
6
|
UnitMatchPy/bayes_functions.py,sha256=3sP-4cWcTTRtuE7HjKJHwN1iFDBY3Y-cmufetCgUZ_A,4511
|
|
7
|
-
UnitMatchPy/default_params.py,sha256=
|
|
7
|
+
UnitMatchPy/default_params.py,sha256=hMFCBbqUTD--kmuNK2HbNUgklC20MOi_ty3ozOcrJlM,1954
|
|
8
8
|
UnitMatchPy/extract_raw_data.py,sha256=BaPT5sSj3mVxHJomnlJWELbxDgwbC-VnUbako9JwFAk,10767
|
|
9
9
|
UnitMatchPy/metric_functions.py,sha256=oCINKcyr8qccaqvXnla_h54_dYK2s0WPisL3QzxcwZM,42371
|
|
10
10
|
UnitMatchPy/overlord.py,sha256=-TJi1ZnDWYdNlI-b27MW4-9BmzO94P9m0K6WC9yRKfY,6371
|
|
11
|
-
UnitMatchPy/param_functions.py,sha256=
|
|
11
|
+
UnitMatchPy/param_functions.py,sha256=XKj3zpyjJIcIvO4gavWu0F6wMlMawOjEG2csK9gvjdw,17108
|
|
12
12
|
UnitMatchPy/run.py,sha256=pA0lQntiEQt8jTuxfC1eoIdESCkWttyBw3eheuk5hMA,5350
|
|
13
13
|
UnitMatchPy/save_utils.py,sha256=ZPlI60JYKt5cmZPiTYI2sPeA1OeKdgcWjeAT5yG4QyA,18672
|
|
14
|
-
UnitMatchPy/utils.py,sha256=
|
|
14
|
+
UnitMatchPy/utils.py,sha256=5owvqRm0PmOFG__JcvFANDiY0JzjHJ2tLMAYmNncg7I,43752
|
|
15
15
|
UnitMatchPy/TkinterTheme/awthemes-10.4.0/LICENSE,sha256=QLti2X2WgO5MQ5_zSH1BpTVF2KHSCliQa9HG1s4skQk,2215
|
|
16
16
|
UnitMatchPy/TkinterTheme/awthemes-10.4.0/README.txt,sha256=OszYA8mn7QelmAYtz0bHi6sf9YOvrXLGgmuCx3bRoJ4,15419
|
|
17
17
|
UnitMatchPy/TkinterTheme/awthemes-10.4.0/awdark.tcl,sha256=bGeLj0wiuOkXQR3R7lP9FpkdE1-mAJruUATnxdCmy0c,2024
|
|
@@ -279,8 +279,8 @@ UnitMatchPy/TkinterTheme/awthemes-10.4.0/i/awthemes/treeview/solid/tree-arrow-do
|
|
|
279
279
|
UnitMatchPy/TkinterTheme/awthemes-10.4.0/i/awthemes/treeview/solid/tree-arrow-right-n-base.svg,sha256=rhgTHm-xIGRkRz9sCSwNNZ3uKfDrK78lroyYbBJAZsk,2386
|
|
280
280
|
UnitMatchPy/TkinterTheme/awthemes-10.4.0/i/awthemes/treeview/solid/tree-arrow-right-n.svg,sha256=8x1rGSDH8eyFeQDJ-glAc63K1hl-UveaJTNBkDmP6vA,2497
|
|
281
281
|
UnitMatchPy/TkinterTheme/awthemes-10.4.0/i/awthemes/treeview/solid/tree-arrow-right-sn.svg,sha256=8x1rGSDH8eyFeQDJ-glAc63K1hl-UveaJTNBkDmP6vA,2497
|
|
282
|
-
unitmatchpy-3.
|
|
283
|
-
unitmatchpy-3.
|
|
284
|
-
unitmatchpy-3.
|
|
285
|
-
unitmatchpy-3.
|
|
286
|
-
unitmatchpy-3.
|
|
282
|
+
unitmatchpy-3.4.0.dist-info/licenses/LICENSE,sha256=WAMqgXMZUjcGirAtQplIvDIz2OaFjRud39xH47vD2Ec,20844
|
|
283
|
+
unitmatchpy-3.4.0.dist-info/METADATA,sha256=NpIrZuiuqBnFMtWhLAAjhF2G8FzXuD1bglx1YxEspVM,5425
|
|
284
|
+
unitmatchpy-3.4.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
285
|
+
unitmatchpy-3.4.0.dist-info/top_level.txt,sha256=EjaC3TLtFxUHy5xVS71T_IrmNpDUVUlXf-7GO32tuDI,12
|
|
286
|
+
unitmatchpy-3.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|