Apply AutoSort in real-time#
With AutoSort, real-time spike sorting and neural dynamics decoding can be performed while the electrophysiological data in recording through Intan system.
To achieve this, first go over Start with AutoSort section.
Next, use the trained AutoSort model for real-time analysis. We provide a function read_data_online to achieve this. The following code need be run in .py file.
[3]:
import os
from autosort_neuron import *
if __name__ == '__main__':
path='path_to_recording_data_folder/'
### load sensor positions
# sensor_positions = ...
# extremum_channels_ids_pth='./processed_data/Ephys_concat_0310_0315/mountainsort/extremum_channels_ids.csv'
### load model
args=config()
args.day_id_str=['0310'] ### day id of the training data
args.cluster_path='./AutoSort_data/' ### path of input data
args.set_time=0 ### set the first element as training data
args.group=np.arange(30) ### all electrodes
args.samplepoints=30 ### 30 points for each waveform
args.mode='load'
trained_AutoSort_model_path = "path_to_model_folder/"
device='cuda:0' if torch.cuda.is_available() else 'cpu'
autosort_model = run(args)
dir_list = os.listdir(path)
for i in dir_list:
print("Files and directories in '", path, "' :")
print(i)
data, header = read_data_online(path+i,autosort_model, sensor_positions, extremum_channels_ids_pth)