Creating a Kilosort4 probe dictionary
Kilosort4 uses a dictionary to track probe interformation. The dictionary needs the following keys, all of which correspond to NumPy ndarrays.
'chanMap': the channel indices that are included in the data.
'xc': the x-coordinates (in micrometers) of the probe contact centers.
'yc': the y-coordinates (in micrometers) of the probe contact centers.
'kcoords': shank or channel group of each contact (not used yet, set all to 0).
'n_chan': the number of channels.
To demonstrate, we’ll create a probe dictionary corresponding to a real example, a 128-channel probe from Diagnostic Biochips.
We’ll assume all channels are used, so ‘chanMap’ will just be the range of integers from 0 to 127. ‘kcoords’ can be set to all zeroes as mentioned above.
[8]:
import numpy as np
chanMap = np.arange(128)
kcoords = np.zeros(128)
n_chan = 128
Since the contacts are 11 micrometers wide (x) and 15 micrometers high (y), our first contact center has coordinates (5.5, 7.5). There is a single column of contacts, so all x-coordinates are the same. Finally, the diagram indicates that contacts are spaced 20 micrometers apart.
[9]:
xc = np.ones(128)*5.5
yc = np.array([7.5 + 20*i for i in range(128)])
So, our probe dictionary looks like:
[10]:
probe = {
'chanMap': chanMap,
'xc': xc,
'yc': yc,
'kcoords': kcoords,
'n_chan': n_chan
}
print(probe)
{'chanMap': array([ 0, 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, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]), 'xc': array([5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5,
5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5]), 'yc': array([ 7.5, 27.5, 47.5, 67.5, 87.5, 107.5, 127.5, 147.5,
167.5, 187.5, 207.5, 227.5, 247.5, 267.5, 287.5, 307.5,
327.5, 347.5, 367.5, 387.5, 407.5, 427.5, 447.5, 467.5,
487.5, 507.5, 527.5, 547.5, 567.5, 587.5, 607.5, 627.5,
647.5, 667.5, 687.5, 707.5, 727.5, 747.5, 767.5, 787.5,
807.5, 827.5, 847.5, 867.5, 887.5, 907.5, 927.5, 947.5,
967.5, 987.5, 1007.5, 1027.5, 1047.5, 1067.5, 1087.5, 1107.5,
1127.5, 1147.5, 1167.5, 1187.5, 1207.5, 1227.5, 1247.5, 1267.5,
1287.5, 1307.5, 1327.5, 1347.5, 1367.5, 1387.5, 1407.5, 1427.5,
1447.5, 1467.5, 1487.5, 1507.5, 1527.5, 1547.5, 1567.5, 1587.5,
1607.5, 1627.5, 1647.5, 1667.5, 1687.5, 1707.5, 1727.5, 1747.5,
1767.5, 1787.5, 1807.5, 1827.5, 1847.5, 1867.5, 1887.5, 1907.5,
1927.5, 1947.5, 1967.5, 1987.5, 2007.5, 2027.5, 2047.5, 2067.5,
2087.5, 2107.5, 2127.5, 2147.5, 2167.5, 2187.5, 2207.5, 2227.5,
2247.5, 2267.5, 2287.5, 2307.5, 2327.5, 2347.5, 2367.5, 2387.5,
2407.5, 2427.5, 2447.5, 2467.5, 2487.5, 2507.5, 2527.5, 2547.5]), 'kcoords': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0.]), 'n_chan': 128}
This probe dictionary can now be used as an argument for run_kilosort
, as demonstrated above. We can also save it to a .json
file for later use:
[ ]:
from kilosort.io import save_probe
save_probe(probe, '.../probe.json')
Now Kilsort4 can load the probe file and extract the contact coordinates and other relevant information. There are two ways to provide this information when running Kilosort4:
Specify the path to the probe file in the GUI.
Or
Load the probe using
kilosort.io.load_probe
and provide the resulting dictionary tokilosort.run_kilosort
using theprobe
keyword argument (demonstrated below).
[ ]:
from kilosort import run_kilosort
from kilosort.io import load_probe
# Abreviated arguments, for demonstration only.
p = load_probe('.../test_prb.prb')
results = run_kilosort(..., probe=p)