update test.py & useful_functions.py
This commit is contained in:
parent
2f5a1d2754
commit
6551d21cc8
55
code/test.py
55
code/test.py
@ -129,6 +129,61 @@ def remove_poor(files):
|
||||
good_files.append(files[i])
|
||||
return good_files
|
||||
|
||||
def sam_data(sam):
|
||||
'''
|
||||
Gets metadata for each SAM
|
||||
|
||||
Parameters
|
||||
----------
|
||||
sam : ReproRun object
|
||||
The sam the metdata should be extracted from.
|
||||
|
||||
Returns
|
||||
-------
|
||||
sam_amp : float
|
||||
amplitude in percent, relative to the fish amplitude.
|
||||
sam_am : float
|
||||
Amplitude modulation frequency.
|
||||
sam_df : float
|
||||
Difference from the stimulus to the current fish eodf.
|
||||
sam_eodf : float
|
||||
The current EODf.
|
||||
sam_nyquist : float
|
||||
The Nyquist frequency of the EODf.
|
||||
sam_stim : float
|
||||
The stimulus frequency.
|
||||
|
||||
'''
|
||||
# create lists for the values we want
|
||||
amplitudes = []
|
||||
dfs = []
|
||||
eodfs = []
|
||||
stim_freqs = []
|
||||
amp_mods = []
|
||||
ny_freqs = []
|
||||
|
||||
# get the stimuli
|
||||
stimuli = sam.stimuli
|
||||
|
||||
# loop over the stimuli
|
||||
for stim in stimuli:
|
||||
amplitude, df, eodf, stim_freq, amp_mod, ny_freq = extract_stim_data(stim)
|
||||
amplitudes.append(amplitude)
|
||||
dfs.append(df)
|
||||
eodfs.append(eodf)
|
||||
stim_freqs.append(stim_freq)
|
||||
amp_mods.append(amp_mod)
|
||||
ny_freqs.append(ny_freq)
|
||||
|
||||
# get the means
|
||||
sam_amp = np.mean(amplitudes)
|
||||
sam_am = np.mean(amp_mods)
|
||||
sam_df = np.mean(dfs)
|
||||
sam_eodf = np.mean(eodfs)
|
||||
sam_nyquist = np.mean(ny_freqs)
|
||||
sam_stim = np.mean(stim_freqs)
|
||||
return sam_amp, sam_am,sam_df, sam_eodf, sam_nyquist, sam_stim
|
||||
|
||||
#find example data
|
||||
datafolder = "../../data"
|
||||
|
||||
|
@ -171,3 +171,58 @@ def remove_poor(files):
|
||||
# if its good or fair add it to the good files
|
||||
good_files.append(files[i])
|
||||
return good_files
|
||||
|
||||
def sam_data(sam):
|
||||
'''
|
||||
Gets metadata for each SAM
|
||||
|
||||
Parameters
|
||||
----------
|
||||
sam : ReproRun object
|
||||
The sam the metdata should be extracted from.
|
||||
|
||||
Returns
|
||||
-------
|
||||
sam_amp : float
|
||||
amplitude in percent, relative to the fish amplitude.
|
||||
sam_am : float
|
||||
Amplitude modulation frequency.
|
||||
sam_df : float
|
||||
Difference from the stimulus to the current fish eodf.
|
||||
sam_eodf : float
|
||||
The current EODf.
|
||||
sam_nyquist : float
|
||||
The Nyquist frequency of the EODf.
|
||||
sam_stim : float
|
||||
The stimulus frequency.
|
||||
|
||||
'''
|
||||
# create lists for the values we want
|
||||
amplitudes = []
|
||||
dfs = []
|
||||
eodfs = []
|
||||
stim_freqs = []
|
||||
amp_mods = []
|
||||
ny_freqs = []
|
||||
|
||||
# get the stimuli
|
||||
stimuli = sam.stimuli
|
||||
|
||||
# loop over the stimuli
|
||||
for stim in stimuli:
|
||||
amplitude, df, eodf, stim_freq, amp_mod, ny_freq = extract_stim_data(stim)
|
||||
amplitudes.append(amplitude)
|
||||
dfs.append(df)
|
||||
eodfs.append(eodf)
|
||||
stim_freqs.append(stim_freq)
|
||||
amp_mods.append(amp_mod)
|
||||
ny_freqs.append(ny_freq)
|
||||
|
||||
# get the means
|
||||
sam_amp = np.mean(amplitudes)
|
||||
sam_am = np.mean(amp_mods)
|
||||
sam_df = np.mean(dfs)
|
||||
sam_eodf = np.mean(eodfs)
|
||||
sam_nyquist = np.mean(ny_freqs)
|
||||
sam_stim = np.mean(stim_freqs)
|
||||
return sam_amp, sam_am,sam_df, sam_eodf, sam_nyquist, sam_stim
|
Loading…
Reference in New Issue
Block a user