-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_probe.py
39 lines (30 loc) · 1.24 KB
/
generate_probe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from kilosort.io import save_probe
from find_and_load_session_mat import findAndLoadSessionMat, extractSessionData, plotChannelMap
from pathlib import Path
import os
def generate_probe_json(basePath, probeLetter=None):
# Load session data
session, dataReader = findAndLoadSessionMat(basePath, probeLetter=probeLetter)
# Extract probe information
chanMap, xc, yc, kcoords, nChan, sampleRate, badChannels = extractSessionData(session, dataReader)
# Plot channel maps (optional, can be commented out if not needed)
plotChannelMap(xc, yc, kcoords, plotAllElectrodes=True)
plotChannelMap(xc, yc, kcoords, plotAllElectrodes=False)
# Create probe dictionary
probe = {
'chanMap': chanMap,
'xc': xc,
'yc': yc,
'kcoords': kcoords,
'n_chan': nChan
}
# Save probe to JSON file
if probeLetter:
save_probe(probe, basePath / f"probe{probeLetter}.json")
else:
save_probe(probe, basePath / "probe.json")
print(f"Probe JSON file saved to {basePath}")
# Example usage
basePath = Path(r"path\to\your\base") # Replace with your actual base path
probeLetter = "" # Replace with your probe letter or None if not applicable
generate_probe_json(basePath, probeLetter)