[useful_functions.py] added true_eodf function
This commit is contained in:
		
							parent
							
								
									6faef3c004
								
							
						
					
					
						commit
						edc8d832e1
					
				@ -1,9 +1,5 @@
 | 
			
		||||
import glob
 | 
			
		||||
import pathlib
 | 
			
		||||
import numpy as np
 | 
			
		||||
import matplotlib.pyplot as plt
 | 
			
		||||
import rlxnix as rlx
 | 
			
		||||
from IPython import embed
 | 
			
		||||
from scipy.signal import welch
 | 
			
		||||
 | 
			
		||||
def all_coming_together(freq_array, power_array, points_list, categories, num_harmonics_list, colors, delta=2.5, threshold=0.5):
 | 
			
		||||
@ -513,6 +509,29 @@ def spike_times(stim):
 | 
			
		||||
    dt = ti.sampling_interval  
 | 
			
		||||
    return spikes, stim_dur, dt # se changed spike_times to spikes so its not the same as name of function
 | 
			
		||||
 | 
			
		||||
def true_eodf(eodf_file):
 | 
			
		||||
    '''
 | 
			
		||||
    Calculates the Eodf of the fish when it was awake from a nix file.
 | 
			
		||||
 | 
			
		||||
    Parameters
 | 
			
		||||
    ----------
 | 
			
		||||
    eodf_file : str
 | 
			
		||||
        path to the file with nix-file for the eodf.
 | 
			
		||||
 | 
			
		||||
    Returns
 | 
			
		||||
    -------
 | 
			
		||||
    orig_eodf : int
 | 
			
		||||
        The original eodf.
 | 
			
		||||
 | 
			
		||||
    '''
 | 
			
		||||
    eod_data = rlx.Dataset(eodf_file)#load eodf file
 | 
			
		||||
    baseline = eod_data.repro_runs('baseline')[0]
 | 
			
		||||
    eod, time = baseline.trace_data('EOD') # get time and eod
 | 
			
		||||
    dt = baseline.trace_info('EOD').sampling_interval
 | 
			
		||||
    eod_freq, eod_power = welch(eod, fs = 1/dt, nperseg = 2**16, noverlap = 2**15)
 | 
			
		||||
    orig_eodf = round(eod_freq[np.argmax(eod_power)])
 | 
			
		||||
    return orig_eodf
 | 
			
		||||
 | 
			
		||||
def valid_integrals(integral, local_mean, point, threshold = 0.1):
 | 
			
		||||
    """
 | 
			
		||||
    Check if the integral exceeds the threshold compared to the local mean and 
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user