Пример #1
0
def update_all(filename, ext_electrodes, save_folder, intr_electrode = 1, data_part = 'all'):
    """ should be done each time the data is to be run from the beginning to the end again"""
    # read all the data
    data_all, fs = ispw.update_datafile(filename, ext_electrodes, save_folder, data_file = 'data', data_part = data_part)
    data_dspl, fs_dspl = ispw.update_downsample(data_all, fs, save_folder, data_file = 'data_dspl')
    data_bas, fs_bas = ispw.update_databas(data_dspl, fs_dspl, save_folder, data_file = 'data_bas') # move to baseline
    
    # update filtered data
    SPW_freq = [1.5, 500.0]
    ripple_freq = [100.0, 300.0]
    fast_freq = [750.0, -1]
    data_spw, freq, fs_data = ispw.update_filtered(data_bas, fs_bas, save_folder, SPW_freq, 'spw_data')
    data_ripple, freq, fs_ripple = ispw.update_filtered(data_bas, fs_bas, save_folder, ripple_freq, "ripple_data")
    data_fast, freq, fs_fast = ispw.update_filtered(data_bas, fs_bas, save_folder, fast_freq, "fast_data")
    #uspl = 1
    #data_uspl_extra, fs_new_up = update_upsample(data_all, fs, save_folder, uspl = uspl, data_file = 'data_uspl_extra')
    spike_idxs, spikes_ampl, fs_espikes = ispw.update_extraspikes(data_all, fs, save_folder, save_file = "ex_spikes")
    spike_idxs, all_valley_to_peak, all_half_valley_width, all_half_peak_width, fs_new = ispw.update_expikes_params(data_all, fs_espikes, save_folder, spike_idxs, save_file = "ex_sparamas")
    spw_idxs, spw_maxs, starts_spw, ends_spw, lengths_spw, fs_spws = ispw.update_spws(data_bas, data_fast, data_spw, fs_bas, save_folder, save_file = 'SPWs')
    rip_idxs, fs_ripple = ispw.update_ripples(data_ripple, fs_ripple, save_folder, data_file = 'ripples')
    ris_all, iris_no_all = ispw.update_spw_ripple(starts_spw, ends_spw, spw_idxs, save_folder, data_file = 'spw_ripple')
    
    if fs_spws != fs_espikes:
        fs_div = fs_espikes/ fs_spws  # if the sampling rate is different  
        print np.shape(spw_idxs[0])
        for i in range(len(spw_idxs)):
            for g in range(len(spw_idxs[i])):
                spw_idxs[i][g] = spw_idxs[i][g] * fs_div
                starts_spw[i][g] = starts_spw[i][g] * fs_div
                ends_spw[i][g] = ends_spw[i][g] * fs_div
   
        spw_idxs = ispw.round_spike_idxs(spw_idxs)
        starts_spw = ispw.round_spike_idxs(starts_spw)
        ends_spw = ispw.round_spike_idxs(ends_spw)
        fs_spws = fs_spws * fs_div
        
    distances, min_distances, fs, max_dist = ispw.update_dist_fromSpike(starts_spw, spike_idxs, fs_spws, save_folder, data_file = 'dist_fromSPW')

    if intr_electrode != -1:
        data_intra, fs = ispw.update_datafile(filename, [intr_electrode], save_folder, data_file = 'intra', data_part = data_part)
        data_dspl_intra, fs_new_down = ispw.update_downsample(data_intra, fs, save_folder, dspl = 2, data_file = 'data_dspl_intra')
        sp_idx_first, sp_idx_all, fs = ispw.update_intraSpikes(data_intra[0], fs, save_folder, save_file = "intra_spikes", pulse_len = 500)
        
        # compare extra and intra data
        
        distances, min_distances, fs, max_dist = ispw.update_dist_fromSpike(sp_idx_all, spike_idxs, fs, save_folder, data_file = 'dist_fromSpike', max_dist = 3)
        distances, min_distances, fs, max_dist = ispw.update_dist_fromSpike(sp_idx_first, starts_spw, fs, save_folder, data_file = 'dist_SpwfromSpike', max_dist = 10)
Пример #2
0
def up_downsample_intra(save_folder, dspl = 2):
    """ updates only downsampling data"""
    data_intra, fs = reader.read_datafile(save_folder, 'intra.npz') # read existing data
    data_dspl_intra, fs_new_down = ispw.update_downsample(data_intra, fs, save_folder, dspl = 2, data_file = 'data_dspl_intra')
    return data_dspl_intra, fs_new_down
Пример #3
0
def up_downsample(save_folder, dspl = 2, data_file = 'data_dspl'):
    """ updates only downsampling data"""
    data_all, fs = reader.read_datafile(save_folder) # read existing data
    data_dspl, fs_dspl = ispw.update_downsample(data_all, fs, save_folder, dspl, data_file = 'data_dspl')
    return data_dspl, fs_dspl