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:
@@ -6,16 +6,20 @@ from thunderhopper.model import process_signal
|
||||
from IPython import embed
|
||||
|
||||
# GENERAL SETTINGS:
|
||||
target = '*'
|
||||
example_file = 'Pseudochorthippus_parallelus_micarray-short_JJ_20240815T160355-20240815T160755-1m10s690ms-1m13s614ms'
|
||||
mode = ['song', 'noise'][1]
|
||||
mode = ['song', 'noise'][0]
|
||||
example_file = dict(
|
||||
song='Pseudochorthippus_parallelus_micarray-short_JJ_20240815T160355-20240815T160755-1m10s690ms-1m13s614ms',
|
||||
noise='merged_noise'
|
||||
)[mode]
|
||||
search_path = f'../data/field/processed/{mode}/'
|
||||
data_paths = search_files(target, ext='npz', dir=search_path)
|
||||
data_paths = search_files('*', ext='npz', dir=search_path)
|
||||
ref_path = '../data/inv/field/ref_measures.npz'
|
||||
stages = ['raw', 'filt', 'env', 'log', 'inv', 'conv', 'feat']
|
||||
save_path = f'../data/inv/field/{mode}/'
|
||||
|
||||
# ANALYSIS SETTINGS:
|
||||
distances = np.load('../data/field/recording_distances.npy')
|
||||
distances = np.load('../data/field/recording_distances.npy')[::-1]
|
||||
thresh_rel = 0.5
|
||||
|
||||
# SUBSET SETTINGS:
|
||||
kernels = np.array([
|
||||
@@ -30,6 +34,11 @@ kernels = None
|
||||
types = None#np.array([-1])
|
||||
sigmas = None#np.array([0.001, 0.002, 0.004, 0.008, 0.016, 0.032])
|
||||
|
||||
# PREPARATION:
|
||||
if thresh_rel is not None:
|
||||
# Get threshold values from pure-noise response SD:
|
||||
thresh_abs = np.load(ref_path)['conv'] * thresh_rel
|
||||
|
||||
# EXECUTION:
|
||||
for data_path, name in zip(data_paths, crop_paths(data_paths)):
|
||||
save_detailed = example_file in name
|
||||
@@ -39,6 +48,10 @@ for data_path, name in zip(data_paths, crop_paths(data_paths)):
|
||||
data, config = load_data(data_path, files='raw')
|
||||
song, rate = data['raw'], config['rate']
|
||||
|
||||
if thresh_rel is not None:
|
||||
# Set kernel-specific thresholds:
|
||||
config['feat_thresh'] = thresh_abs
|
||||
|
||||
# Reduce to kernel subset:
|
||||
if any(var is not None for var in [kernels, types, sigmas]):
|
||||
kern_inds = find_kern_specs(config['k_specs'], kernels, types, sigmas)
|
||||
@@ -59,6 +72,9 @@ for data_path, name in zip(data_paths, crop_paths(data_paths)):
|
||||
|
||||
# Process snippet:
|
||||
signals, rates = process_signal(config, returns=stages, signal=song, rate=rate)
|
||||
for stage in stages:
|
||||
# Sort largest to smallest distance:
|
||||
signals[stage] = signals[stage][..., ::-1]
|
||||
|
||||
# Store results:
|
||||
for stage in stages:
|
||||
@@ -68,6 +84,10 @@ for data_path, name in zip(data_paths, crop_paths(data_paths)):
|
||||
measures[mkey] = signals[stage][segment, ...].mean(axis=0)
|
||||
else:
|
||||
measures[mkey] = signals[stage][segment, ...].std(axis=0)
|
||||
|
||||
if measures[mkey].ndim == 2:
|
||||
# Make shape (distances, kernels):
|
||||
measures[mkey] = np.moveaxis(measures[mkey], 1, 0)
|
||||
|
||||
# Log optional snippet data:
|
||||
if save_detailed:
|
||||
|
||||
Reference in New Issue
Block a user