Added multi-thresh simulation to "full" and "short" (currently running).
Added complete "rect-lp" analysis except figure. Added multiple appendix figs. Overhauled normalization options across all condense scripts. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
42
python/save_ref_measures_field.py
Normal file
42
python/save_ref_measures_field.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import numpy as np
|
||||
from thunderhopper.filetools import search_files
|
||||
from thunderhopper.model import process_signal
|
||||
from thunderhopper.modeltools import load_data
|
||||
from IPython import embed
|
||||
|
||||
## SETTINGS:
|
||||
|
||||
# General:
|
||||
stages = ['raw', 'filt', 'env', 'log', 'inv', 'conv', 'feat']
|
||||
noise_path = search_files('merged_noise', dir='../data/field/processed/noise/')[0]
|
||||
save_path = '../data/inv/field/ref_measures.npz'
|
||||
channels = np.array([0, 1, 2, 3, 4, 5, 6, 7])
|
||||
|
||||
# PROCESSING:
|
||||
|
||||
# Load pure-noise starter representation:
|
||||
noise_data, config = load_data(noise_path, stages[0])
|
||||
# Accumulate channels in time-major order:
|
||||
starter = noise_data[stages[0]][:, channels].ravel(order='F')
|
||||
|
||||
# Get song segment to be analyzed:
|
||||
time = np.arange(starter.shape[0]) / config['rate']
|
||||
start, end = noise_data['songs_0'].ravel()
|
||||
segment = (time >= start) & (time <= end)
|
||||
|
||||
# Run pipeline:
|
||||
data = process_signal(config, stages, signal=starter, rate=config['rate'])[0]
|
||||
|
||||
# Get measures:
|
||||
measures = {}
|
||||
for stage in stages:
|
||||
if stage == 'feat':
|
||||
measures[stage] = data[stage][segment, :].mean(axis=0)
|
||||
else:
|
||||
measures[stage] = data[stage][segment, ...].std(axis=0)
|
||||
|
||||
# Save results:
|
||||
np.savez(save_path, **measures)
|
||||
|
||||
print('Done.')
|
||||
embed()
|
||||
Reference in New Issue
Block a user