Esempio n. 1
0
    data_raw_amp2.dataMatrix,
    event_times2, [-1, 1],
    sampling_freq,
    baseline_time=[-0.5, 0],
    sub_sample_freq=1000)

#for spikes
fn_adc = "C:\George\Data\ECoG_Juxta_Paired_Recordings\\14_04_03\Rec2\\adc2014-04-03T19_04_08.bin"
fn_amp = "C:\George\Data\ECoG_Juxta_Paired_Recordings\\14_04_03\Rec2\\amplifier2014-04-03T19_04_08.bin"

sampling_freq = 30000
threshold = 1.2 / 1000
inter_spike_distance = 0.03
channel = 1
data_raw_spikes = tl.load_raw_event_trace(fn_adc, 8, channel)
spike_times, spike_trace_in_V = tl.create_spike_triggered_events(
    data_raw_spikes.dataMatrix, threshold, inter_spike_distance, 1000)

data_raw_ecog = tl.load_raw_data(fn_amp, 64, np.float32)
tl_data, tl_avg_trials_data, sub_time_axis = tl.time_lock_raw_data(
    data_raw_ecog.dataMatrix,
    spike_times[:-37],
    times_to_cut=[-2, 2],
    sampling_freq=sampling_freq,
    baseline_time=[-1.9, -1],
    sub_sample_freq=1000)
tl_hpr_data, tl__hpr_avg_trials_data, sub_time_axis = tl.time_lock_raw_data(
    data_raw_ecog.dataMatrix,
    spike_times[:-37],
    times_to_cut=[-2, 2],
    sampling_freq=sampling_freq,
    baseline_time=[-1.9, -1],
import matplotlib.pyplot as plt
import matplotlib.animation as animation
plt.rcParams['animation.ffmpeg_path'] = "C:\\Users\\IntelligentSystem\[email protected]\george\Code\Python\ExtraRequirements\\ffmpeg-20140618-git-7f52960-win64-static\\bin\\ffmpeg.exe"
import mne as mne


sampling_freq = 30000


#Cell 1
fn_adc_c1 = "C:\\George\\Data\\ECoG_Juxta_Paired_Recordings\\2014_12_05_Jpak77\\2014_12_05_Jpak77_JuxtaCell1_ADC_Cell1.bin"
fn_amp_c1 = "C:\\George\\Data\\ECoG_Juxta_Paired_Recordings\\2014_12_05_Jpak77\\2014_12_05_Jpak77_JuxtaCell1_Amp_Cell1.bin"

threshold = 0.0003
cell_1_data_raw_spikes = tl.load_raw_event_trace(fn_adc_c1, number_of_channels=8, channel_used=0, dtype=np.uint16)
cell_1_event_times, cell_1_eventdata_in_V = tl.create_spike_triggered_events(cell_1_data_raw_spikes.dataMatrix, threshold = threshold, inter_spike_time_distance=0.001, amp_gain=1000,
                                  sampling_freq=sampling_freq, amp_y_digitization=65536, amp_y_range=10)

cell_1_event_times = cell_1_event_times[1:-120]
cell_1_data_raw_amp = tl.load_raw_data(fn_amp_c1, 64)


cell_1_tl_sub_reref_avg, sub_time_axis = tl.time_lock_raw_data(cell_1_data_raw_amp.dataMatrix, cell_1_event_times, times_to_cut=[-0.2, 0.2], sampling_freq=sampling_freq,
                                                               baseline_time=[-0.2, -0.05], sub_sample_freq=2000, avg_reref = True, keep_trials=False)


x_of_bad_channels = np.array([19, 136, 214, 87, 516])  #For 420 spikes average
y_of_bad_channels = np.array([88, 68, 94, -119, 64])
cell_1_tl_sub_reref_avg_nbc, bad_channels_cell_1_tl_sub_reref_avg = bad_channel_removal(x_of_bad_channels, y_of_bad_channels, cell_1_tl_sub_reref_avg)
pf.plot_video_topoplot(cell_1_tl_sub_reref_avg_nbc, sub_time_axis, pf.grid_layout_64channels(bad_channels_cell_1_tl_sub_reref_avg), times_to_plot = [-0.06, 0.1],
                       time_step = 0.001, sampling_freq = 1000, zlimits = [-60, 60], filename = 'C:\George\Analysis\Jpak77_Juxta\\Cell_1_LFPs.avi')
sampling_freq = 30000

#Cell 1
fn_adc_c1 = "C:\\George\\Data\\ECoG_Juxta_Paired_Recordings\\2014_12_05_Jpak77\\2014_12_05_Jpak77_JuxtaCell1_ADC_Cell1.bin"
fn_amp_c1 = "C:\\George\\Data\\ECoG_Juxta_Paired_Recordings\\2014_12_05_Jpak77\\2014_12_05_Jpak77_JuxtaCell1_Amp_Cell1.bin"

threshold = 0.0003
cell_1_data_raw_spikes = tl.load_raw_event_trace(fn_adc_c1,
                                                 number_of_channels=8,
                                                 channel_used=0,
                                                 dtype=np.uint16)
cell_1_event_times, cell_1_eventdata_in_V = tl.create_spike_triggered_events(
    cell_1_data_raw_spikes.dataMatrix,
    threshold=threshold,
    inter_spike_time_distance=0.001,
    amp_gain=1000,
    sampling_freq=sampling_freq,
    amp_y_digitization=65536,
    amp_y_range=10)

cell_1_event_times = cell_1_event_times[1:-120]
cell_1_data_raw_amp = tl.load_raw_data(fn_amp_c1, 64)

cell_1_tl_sub_reref_avg, sub_time_axis = tl.time_lock_raw_data(
    cell_1_data_raw_amp.dataMatrix,
    cell_1_event_times,
    times_to_cut=[-0.2, 0.2],
    sampling_freq=sampling_freq,
    baseline_time=[-0.2, -0.05],
    sub_sample_freq=2000,
    avg_reref=True,
sub_tl_data2, sub_tl_avg_data2, sub_time_axis2 = tl.time_lock_raw_data(data_raw_amp2.dataMatrix, event_times2, [-1, 1], sampling_freq, baseline_time=[-0.5, 0], sub_sample_freq=1000)





#for spikes
fn_adc = "C:\George\Data\ECoG_Juxta_Paired_Recordings\\14_04_03\Rec2\\adc2014-04-03T19_04_08.bin"
fn_amp = "C:\George\Data\ECoG_Juxta_Paired_Recordings\\14_04_03\Rec2\\amplifier2014-04-03T19_04_08.bin"

sampling_freq = 30000
threshold = 1.2/1000
inter_spike_distance = 0.03
channel = 1
data_raw_spikes = tl.load_raw_event_trace(fn_adc,8, channel)
spike_times, spike_trace_in_V = tl.create_spike_triggered_events(data_raw_spikes.dataMatrix,threshold,inter_spike_distance,1000)

data_raw_ecog = tl.load_raw_data(fn_amp,64,np.float32)
tl_data, tl_avg_trials_data, sub_time_axis = tl.time_lock_raw_data(data_raw_ecog.dataMatrix, spike_times[:-37], times_to_cut=[-2,2], sampling_freq=sampling_freq, baseline_time=[-1.9, -1], sub_sample_freq=1000)
tl_hpr_data, tl__hpr_avg_trials_data, sub_time_axis = tl.time_lock_raw_data(data_raw_ecog.dataMatrix, spike_times[:-37], times_to_cut=[-2,2], sampling_freq=sampling_freq, baseline_time=[-1.9, -1],high_pass_cutoff=400, rectify=True, sub_sample_freq=1000)



k=0
spikes_avg = np.zeros(120000)
spikes_all = np.zeros((120000,np.size(spike_times)))
for i in spike_times:
    if i>60000 and i<np.size(data_raw_spikes)-60000:
        temp = data_raw_spikes[i-60000: i+60000]
        spikes_avg = spikes_avg + temp
        spikes_all[:,k] = temp