You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
44 lines
1.2 KiB
2 years ago
|
import pandas as pd
|
||
|
import numpy as np
|
||
|
import pickle as pkl
|
||
|
|
||
|
data_folder = "../data/"
|
||
|
|
||
|
stim_file = "Stiminfo_PVCre_2021_0012_s06_e14.csv"
|
||
|
stim = pd.read_csv(data_folder+stim_file)
|
||
|
|
||
|
spike_times_file = "Spiketimes_PVCre_2021_0012_s06_e14.npy"
|
||
|
spike_times = np.load(data_folder+spike_times_file, allow_pickle=True)
|
||
|
active = [len(spike_times[i]) > 0 for i in range(len(spike_times))]
|
||
|
spike_times = spike_times[np.where(active)]
|
||
|
|
||
|
num_unit = len(spike_times)
|
||
|
num_trial = len(stim)
|
||
|
|
||
|
# sort by firing rate
|
||
|
|
||
|
num_spike = list(map(len, spike_times))
|
||
|
# num_spike = np.array([len(spike_times[i]) for i in range(len(spike_times))])
|
||
|
spike_times = spike_times[np.argsort(num_spike)[::-1]]
|
||
|
|
||
|
files = ['stim_data.pkl', 'spike_data.pkl', 'corr_data.pkl']
|
||
|
for file_name in files:
|
||
|
print(file_name)
|
||
|
file = open(file_name, 'rb')
|
||
|
data = pkl.load(file)
|
||
|
print(data.keys())
|
||
|
for key, value in data.items():
|
||
|
globals()[key] = value
|
||
|
|
||
|
file.close()
|
||
|
|
||
|
def pkl_save(filename:str, object:object):
|
||
|
file = open(filename+'.pkl', 'wb')
|
||
|
pkl.dump(object, file, pkl.HIGHEST_PROTOCOL)
|
||
|
file.close()
|
||
|
|
||
|
def pkl_load(filename:str):
|
||
|
file = open(filename+'.pkl', 'rb')
|
||
|
a = pkl.load(file)
|
||
|
file.close()
|
||
|
return a
|