MouseLand / Kilosort

Fast spike sorting with drift correction
https://kilosort.readthedocs.io/en/latest/
GNU General Public License v3.0
484 stars 248 forks source link

rez data #789

Closed Lorena-J closed 2 months ago

Lorena-J commented 2 months ago

Hi, I have a question about the rez file. I know that in Kilosort 2.5 and kilosrt 3 there was a ‘rez.mat’ file, and I was wondering if there could be any possibility to create this file with kilosrt 4, I know kilosort 4 is in python not in matlab, but the program I use to parse and do the manual clustering after kilsorot is in Matlab and uses the rez.mat file.

I've seen in the doc this code:

outputs saved to results_dir

results_dir = Path(settings['data_dir']).joinpath('kilosort4') ops = load_ops(results_dir / 'ops.npy') camps = pd.read_csv(results_dir / 'cluster_Amplitude.tsv', sep='\t')['Amplitude'].values contam_pct = pd.read_csv(results_dir / 'cluster_ContamPct.tsv', sep='\t')['ContamPct'].values chan_map = np.load(results_dir / 'channel_map.npy') templates = np.load(results_dir / 'templates.npy') chan_best = (templates*2).sum(axis=1).argmax(axis=-1) chan_best = chan_map[chan_best] amplitudes = np.load(results_dir / 'amplitudes.npy') st = np.load(results_dir / 'spike_times.npy') clu = np.load(results_dir / 'spike_clusters.npy') firing_rates = np.unique(clu, ret urn_counts=True)[1] 30000 / st.max() dshift = ops['dshift'] And I wondered if there is a way to create the rez file. Thank you so much!!

jacobpennington commented 2 months ago

We are not planning to recreate the rez.mat file in Kilosort4. Many of the variables do not translate directly to what was saved in KS2.5 and KS3 since some parts of the sorting pipeline have changed. If you want to use the same analysis pipeline for KS4 and older version of Kilosort, you would need to base it on the outputs saved for Phy instead. Those will be the same across versions, possibly with some files missing for KS4 that aren't implemented yet and some extra ones from KS4 that aren't actually used by Phy.