Пример #1
0
def up_fill_gap_between_ipsp_groups(save_folder, save_file, spw_file, data_file, reanalize = False):
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)

    if reanalize or not exists:
        # load the data        
        ispw.update_fill_gap_between_ipsp_groups(save_folder = save_folder, save_file = save_file, spw_file = spw_file, data_file = data_file)
    else:
        print 'Initiated SPWs were already saved'    
    gc.collect()  
Пример #2
0
def up_spws_spikes_ampl(save_folder, save_file = 'data.npz', load_spwsspike = 'SPWs_spikes.npz', load_spikefile = 'spikes_params.npz', reanalize = False):
    """ Finds which of the spikes detected is of the same amplitude as coresponding highest spike - it returns only the highest amplitude spikes"""
    
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:      
        ispw.update_SPW_spikes_ampl(load_spikefile, load_spwsspike, save_folder, save_file)  
    else:
        print 'spws were already analysed'        
    gc.collect()       
Пример #3
0
def equalize_number_spws(save_folder, save_file, induc_spont, load_distances, reanalize):
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)

    if reanalize or not exists:
        # load the data        
        ispw.update_equalize_number_spws(save_folder = save_folder, save_file = save_file, induc_spont = induc_spont, load_distances = load_distances)
    else:
        print 'Initiated SPWs were already saved'    
    gc.collect()      
Пример #4
0
def up_extraspikes(save_folder, filter_folder,  save_file = "ex_spikes", load_file = "data_dspl.npz", spikes_filter = 'filter_', reanalize = False):
    """ finding extracellular spikes in the data """
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:  
        ispw.update_extraspikes(data_load = load_file, filter_folder = filter_folder, save_folder = save_folder, save_file = save_file, save_filter = spikes_filter)
    else:
        print 'spikes were already found'
    gc.collect()
Пример #5
0
def up_remove_with_to_few_ipsps(save_folder, save_file, spw_file, to_remove, reanalize = False):
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)

    if reanalize or not exists:
        # load the data        
        ispw.update_remove_with_to_few_ipsps(save_folder = save_folder, save_file = save_file, spw_file = spw_file, to_remove = to_remove)
    else:
        print 'Initiated SPWs were already saved'    
    gc.collect()      
Пример #6
0
def up_expikes_params(save_folder, save_file = 'spw_data.npz', load_datafile = 'spw_data.npz', load_spikefile = 'spikefile.npz', reanalize = False):
    """ finds different parameters of the spike and returns them in ms"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:       
        ispw.update_expikes_params(load_datafile, load_spikefile, save_folder, save_file = save_file)  
    else:
        print 'spikes parameters were already calculated'
    gc.collect()
Пример #7
0
def up_intraSpikes(save_folder, save_file = 'intra_spikes.npz', load_file = 'data_intra.npz', reanalize = False):
    """ finds the spikes in the intracellular data"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        # load the data
        ispw.update_intraSpikes(save_folder, save_file = save_file, load_file = load_file, pulse_len = 500)
    else:
        print 'intracellular spikes were already found previously'    
    gc.collect()    
Пример #8
0
def up_add_missing_electrodes_SPW(save_folder, save_file, spw_file, data_file, reanalize = False, expected_min_ipsp_ampl = 30):
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)

    if reanalize or not exists:
        # load the data        
        ispw.update_add_missing_electrodes_SPW(save_folder = save_folder, save_file = save_file, spw_file = spw_file, data_file = data_file)
    else:
        print 'Initiated SPWs were already saved'    
    gc.collect()      
Пример #9
0
def up_group_ipsps(save_folder, ipsps_groups, load_spwsipsp, load_datafile, save_file, reanalize):
    """ groups the IPSPs and assigns to them groups"""
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        fig_fold_name = 'SPW_IPSPs/'
        fold_mng.create_folder(save_folder + fig_fold_name)
        # load the data   
        ispw.update_ipsps_groups(save_folder, ipsps_groups, load_spwsipsp, load_datafile, save_file)
    gc.collect()
Пример #10
0
def up_datafile(filename, save_folder, save_file = 'data.npz', ext_electrodes = [1], intr_electrode = 1, reanalize = False):
    """ updates only the datafile for the given values """
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        ispw.update_datafile(filename, ext_electrodes, save_folder, data_file = save_file)
    else:
        print 'raw data file already exists'
    gc.collect()
Пример #11
0
def up_induc_spont_spw(save_folder, save_file = 'i_s_spws', load_distances = 'distances.npz', load_spwfile = 'spws.npz', max_init_dist = 10, reanalize = False, ext = '.pdf'):
    """ it finds which spws are initiated and which are sponteneaus"""
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)

    if reanalize or not exists:
        # load the data        
        ispw.update_induc_spont_spw(save_folder = save_folder, save_file = save_file, load_distances = load_distances, load_spwfile = load_spwfile, max_dist =max_init_dist, ext = ext)
    else:
        print 'Initiated SPWs were already saved'    
    gc.collect()       
Пример #12
0
def up_SPW_ipsp(save_folder, filter_folder, save_file = 'spws_params.npz', load_datafile = "data_movavg.npz", load_waves = 'spws.npz', load_spikes = 'spws_potential', induced_dist = 7, reanalize = False):
    """ it finds the characteristics of each spw"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        # load the data        
        ispw.update_SPW_ipsp(load_datafile, filter_folder, load_waves, load_spikes, save_folder, save_file)
    else:
        print 'spws were already analysed'    
    gc.collect()
Пример #13
0
def up_correct_ipsps(save_folder, save_fig = 'spw_ipsp', save_file = 'save_it.npz', load_datafile = 'data.npz', load_spwsipsp = 'spws.npz', load_spwsspike = 'spw_spike.npz', reanalize = False, ext = '.pdf'):
    """analyse all the ipsps and correct them"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        fig_fold_name = 'SPW_IPSPs/'
        fold_mng.create_folder(save_folder + fig_fold_name)
          
        ispw.corect_ipsps(load_datafile, load_spwsipsp, load_spwsspike, save_folder, fig_fold_name + save_fig, save_file, ext)  
    gc.collect()    
Пример #14
0
def up_spikes_ampl(save_folder, save_file ='spikes_in_spws', load_spike_file = 'spikes.npz', reanalize = False):
    """ finds all the spikes for the given spw"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        # load the data   
        ispw.update_spikes_ampls(save_folder, save_file, load_spike_file)
    else:
        print 'origins of spikes were already calculated'
    gc.collect()    
Пример #15
0
def up_intrafile(filename, save_folder, save_file = 'data_intra.npz', int_electrodes = [1], reanalize = False):
    """ read intracellular data"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        # load the data
        ispw.update_datafile(filename, int_electrodes, save_folder, data_file = save_file)
    else:
        print 'raw intracellular data was already loaded'    
    gc.collect()
Пример #16
0
def up_spws_ipsp_beg(save_folder, filter_folder, save_fig = 'spw_ipsp', save_file = 'save_it.npz', load_datafile = 'data.npz', load_spwsipsp = 'spws.npz', load_spwsspike = 'spw_spike.npz', reanalize = False, ext = '.pdf', expected_min_ipsp_ampl = 30):       
    """analyse the ipsps in each SPWs - finds the beginnings, and removes those which are not correct"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        fig_fold_name = 'SPW_IPSPs/'
        fold_mng.create_folder(save_folder + fig_fold_name)
        # load the data   (save_folder, ipsps_groups, load_spwsipsp, load_datafile, save_file)
        ispw.update_spws_ipsp_beg(load_datafile, filter_folder, load_spwsipsp, load_spwsspike, save_folder, fig_fold_name + save_fig, save_file, ext, expected_min_ipsp_ampl)  
    gc.collect()
Пример #17
0
def up_spws_beg(save_folder, save_fig = 'spw_ipsp', save_file = 'save_it.npz', load_datafile = 'data.npz', load_spwsipsp = 'spws.npz', load_spwsspike = 'spw_spike.npz', reanalize = False, ext = '.pdf', expected_min_ipsp_ampl= 30): 
    """analyse the beginning of each SPW - finds the beginnings - time and location"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        fig_fold_name = 'SPW_IPSPs/'
        fold_mng.create_folder(save_folder + fig_fold_name)
          
        ispw.update_spws_beg(load_datafile, load_spwsipsp, load_spwsspike, save_folder, fig_fold_name + save_fig, save_file, ext, expected_min_ipsp_ampl = expected_min_ipsp_ampl)  
    gc.collect()
Пример #18
0
def up_divide_to_groups(load_datafile, load_spwsipsp, save_folder, save_file, reanalize): 
    """analyse the beginning of each SPW - finds the beginnings - time and location"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        fig_fold_name = 'SPW_IPSPs/'
        fold_mng.create_folder(save_folder + fig_fold_name)
          
        ispw.divide_to_groups(load_datafile, load_spwsipsp, save_folder, save_file)  
    gc.collect()
Пример #19
0
def up_spws_first_max(save_folder, save_file, spws, datafile, reanalize = False):
    """ alignes spws on the first maximum within the window"""
 # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        fig_fold_name = 'SPW_IPSPs/'
        fold_mng.create_folder(save_folder + fig_fold_name)
          
        ispw.update_spws_first_max(save_folder, spws, datafile, save_file, window = [-1, 3])
    gc.collect()
Пример #20
0
def up_remove_too_small_spws(save_folder, save_file, load_datafile, load_spwsipsp, min_ampl, reanalize = False, ext = '.pdf'):
    """analyse all the ipsps and correct them"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        fig_fold_name = 'SPW_IPSPs/'
        fold_mng.create_folder(save_folder + fig_fold_name)
          
        ispw.update_remove_too_small_spws(load_datafile, load_spwsipsp, min_ampl, save_folder, save_file, ext)  
    gc.collect() 
Пример #21
0
def up_highWaves(save_folder, filter_folder, save_file = "data_movavg.npz", load_datafile = 'data.npz', reanalize = False):
    """ it subtracts moving average from the data"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        # load the data       
        ispw.update_highWaves(load_datafile, filter_folder, save_folder, data_file = save_file, atten_len = 25)
    else:
        print 'raw data was already moved to the baseline' 
    gc.collect()
Пример #22
0
def up_databas(save_folder, save_file = "data_dspl.npz", load_file = 'data.npz', reanalize = False):
    """ it downsamples the data taken from the given file and saves it in another file"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        # load the data
        ispw.update_databas(data_load = load_file, save_folder = save_folder, data_file = save_file)
    else:
        print 'raw data was already moved to the baseline'    
    gc.collect()
Пример #23
0
def up_merge_close_groups(save_folder, save_file, spw_file, data_file, reanalize = False):
    """ it merges too close groups of IPSPs, it chooses the one which is lower if there are
    two on the same electrode"""
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)

    if reanalize or not exists:
        # load the data        
        ispw.update_merge_close_groups(save_folder = save_folder, save_file = save_file, spw_file = spw_file, data_file = data_file)
    else:
        print 'Initiated SPWs were already saved'    
    gc.collect()    
Пример #24
0
def up_highWaves_numb(save_folder, save_file = 'spws_params.npz', load_spwsfile = 'spws_potential', reanalize = False):
    """ it finds the characteristics of each spw"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:   
        # load spike params
       
        ispw.update_highWaves_numb(load_spwsfile, save_folder, save_file)
    else:
        print 'spws were already analysed'    
    gc.collect()
Пример #25
0
def up_dist_SpwfromSpike(save_folder, save_file = 'spw_dist.npz', load_intrafile = 'intra_data.npz', load_spwfile = 'spw_data.npz', spikes = 'all', reanalize = False):
    """ it finds the distance intracellular spike to each spw"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)

    if reanalize or not exists:
        # load the data        
        ispw.update_dist_SPWfromSpike(save_folder = save_folder, save_file = save_file, load_intrafile = load_intrafile, load_spwfile = load_spwfile, max_dist = 15, spikes = spikes)
    else:
        print 'distances of spws to intracellular spikes were already calculated'    
    gc.collect()    
Пример #26
0
def up_spws(save_folder, save_file = 'spw_data.npz', load_file = 'spw_data.npz', reanalize = False):
    """ updates details of the spws"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        npzfile = np.load(save_folder + load_file)
        data = npzfile['data']
        fs = npzfile['fs']        
        npzfile.close()
        
        spw_idxs, spw_maxs, starts_spw, ends_spw, lengths_spw, fs_spws = ispw.update_spws(data, fs = fs, save_folder = save_folder, save_file = save_file) 
    else:
        print 'raw data was already filtered' 
    gc.collect()
Пример #27
0
def up_filtered(save_folder, save_file = 'spw_data.npz', load_file = "data_dspl.npz", freq = [1.5, 500.0], reanalize = False):
    """ filteres the data from the given file to given frequencies"""
    # check if folder already exists
    fold_mng.create_folder(save_folder)
    
    # check if this file already exists
    exists = fold_mng.file_exists(save_folder, save_file)
    if reanalize or not exists:
        npzfile = np.load(save_folder + load_file)
        data = npzfile['data']
        fs = npzfile['fs']        
        npzfile.close()
        
        data_filt, freq, fs_data = ispw.update_filtered(data, fs, save_folder, freq, data_file = save_file)   
    else:
        print 'raw data was already filtered' 
    gc.collect()
Пример #28
0
        
        solutions_folder = get_save_folder() + 'solutions/'
        fold_mng.create_folder(solutions_folder)
        
        if cum_change_var:
            # gather all the cumulative change of variance and plot them on one plot
            file_name = name_used + 'cum_change_variance.npz'
            
            all_var_spont = []
            all_var_init = []
            
            for nex in range(len(all)):
                #import pdb; pdb.set_trace()
                filename, save_folder, intra  = find_folders(all[nex][0], all[nex][1], all[nex][2])
                # check if it exists:       
                exists = fold_mng.file_exists(save_folder, file_name)

                if exists:  
                    print all[nex][0]               
                    npzfile = np.load(save_folder + file_name)
                    
                    init_temp = npzfile['cum_change_init']
                    spont_temp = npzfile['cum_change_spont']
                    timeline = npzfile['timeline']
                    fs = npzfile['fs']
                    npzfile.close()
                    all_var_spont.append(spont_temp.tolist())
                    all_var_init.append(init_temp.tolist())
            fs = fs.tolist()
            fs = int(fs)      
            all_var_spont = np.array(all_var_spont)