forked from FlyCourtship/FlySongSegmenter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFetchParams.m
executable file
·83 lines (69 loc) · 3.89 KB
/
FetchParams.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
%script to set default parameters, and load user specified changes.
%
%the values below are overwritten by the custom parameter file specified as an input
%argument to FlySongSegmenter and fly_song_segmenter, or, if that is not specified,
%by params.m
%SET DEFAULT PARAMETERS
Params.Fs = 10000; % sampling frequency, in Hertz
Params.keep_mediumrare_data = false; % if false, Sines.MultiTaper.A, Sines.*.clips, Pulses.cmh*,
% Pulses.*.x, and Pulses.pulse_model*.allZ* are not saved
Params.copy_raw_data = true; % if false, Data.d/hyg/daqinfo are not saved in the .mat file
Params.sines_first = false; % if false, segment pulse, then sine.
% if true, segment sine, then pulse, then sine
Params.raw_model = true; % if true, then estimate pulse model from all pulses
% if false, use pulses that best fit provided first harmonic model
% to build new first harmonic model, same for second harmonic
%estimating noise
Params.low_freq_cutoff = 100; % exclude data below this frequency
Params.high_freq_cutoff = 1000; % exclude data above this frequency
Params.cutoff_sd = 3; % exclude data above this multiple of the std. deviation
%pulse song: wavelet transform
Params.fc = [100:25:750]; % wavelet scales, in Hertz
Params.DoGwvlt = [2:3]; % Derivative of Gaussian wavelets examined
%pulse song: segment
Params.pWid = round(Params.Fs/250)+1; % 4 * pWid is length of pulse kept in ticks ; approx pulse width
Params.minIPI = round(Params.Fs/100); % lowest acceptable IPI, in ticks (even, rounded)
Params.thresh = 4; % multiple of smoothed threshold over which pulses are counted
%pulse song: cull with heuristics
Params.minAmplitude = 6; %multiple of the mean noise which pulses must exceed
Params.maxIPI = round(Params.Fs/5); %if no other pulse within this many ticks, do not count as a pulse
Params.frequency = 700; %if best matched scale is greater than this frequency, do not count as a pulse
Params.close = round(Params.Fs/50); %if pulse peaks are this close together, only keep the larger pulse
%pulse song: cull with model
Params.pulse_model='pulse_model_melanogaster.mat';
%find sine song? Code is MUCH faster if you don't search for sine.
Params.find_sine = true;
% sine song: multi-taper
Params.NW = 12; % time-bandwidth product for tapers
Params.K = 20; % numver independent tapers to average over, must be < 2*NW
Params.dT = 0.1; % FFT window length, in seconds
Params.dS = 0.01; % FFT window step size, in seconds
Params.pval = 0.05; % criterion for F-test
Params.fwindow = [0 1000]; % frequency range to analyze, in Hertz
%sine song: segment
Params.sine_low_freq = 100; % lowest frequency to include as sine, in Hertz
Params.sine_high_freq = 300; % highest frequency to include as sine, in Hertz
Params.sine_range_percent = 0.2; % tolerance to merge harmonically-related frequencies
Params.discard_less_sec = .03; % minimum length for sine song, in seconds
%sine song: winnow
Params.max_pulse_pause = 0.070; %max_pulse_pause in seconds, used to winnow apparent sine between pulses
Params.mask_pulses = 'ModelCull2';
%READ IN USER DEFINED PARAMETERS, SOME OF WHICH MAY REPLACE DEFAULTS
if ~exist('params_path', 'var') || isempty(params_path)
params;
else
% run(params_path);
fid = fopen(params_path);
if fid < 0
error('Could not open the parameters file at %s', params_path);
end
params_code = fread(fid, '*char')';
fclose(fid);
try
% disp(params_code);
eval(params_code);
catch ME
error('Could not load the parameters from %s (%s)', params_path, ME.message);
end
end
load(Params.pulse_model);