-
Notifications
You must be signed in to change notification settings - Fork 1
/
fig_normalizer_split_window.m
130 lines (109 loc) · 4.75 KB
/
fig_normalizer_split_window.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
% 2017 02 26 Revised from plot_normalizer_split_window_output()
% 2017 02 27 Revised to use plot_normalized_echogram()
% 2017 04 20 1) raw data use non-detrended echogram
% 2) change colormap for the normalized output
% Set up various paths
if isunix
addpath('~/internal_2tb/Dropbox/0_CODE/MATLAB/saveSameSize');
addpath('~/internal_2tb/Dropbox/0_CODE/MATLAB/epsutil');
addpath('~/internal_2tb/trex/trex_fish_code/Triplet_processing_toolbox');
base_save_path = '~/internal_2tb/trex/figs_results/';
base_data_path = '~/internal_2tb/trex/figs_results/';
else
addpath('F:\Dropbox\0_CODE\MATLAB\saveSameSize');
addpath('F:\Dropbox\0_CODE\MATLAB\epsutil');
addpath('F:\trex\trex_fish_code\Triplet_processing_toolbox');
base_save_path = 'F:\trex\figs_results';
base_data_path = 'F:\trex\figs_results';
end
% Set params
run_num = 131;
if run_num==87
ping_num = [100,164,183,197,231,462,766,835,873,936,...
134,167,201,857]; % run 087
ori_caxis = [180 210]; % wfm 1 of run 131
elseif run_num==131
% ping_num = [23,509,781]; % pings used in v7 figures
% ping_num = [13,103,113,261,441,507,651,781,797,813,893]; % run 131
ping_num = [23,509,49,95,103,113,441,455,...
507,589,781,795,797,813]; % pings from fig_energy_si_sun
if mod(ping_num(1),2)==0
ori_caxis = [178 208]; % wfm 2 of run 131
else
% ori_caxis = [180 210]; % wfm 1 of run 131--> detrended echo level
ori_caxis = [120 150]; % wfm 1 of run 131--> raw echo level
end
end
% Set params
cmap = 'jet';
sm_len = 150;
axis_lim = [-4.3 -1.3 -4.5 -1.5];
norm_caxis = [5 15];
norm_param.sm_len = sm_len; % smooth length
norm_param.aux_m = 200; % length of auxiliary band in [m]
norm_param.guard_num_bw = 2; % 2/BW
norm_detail_plot = 0;
% Set up various paths
data_path = sprintf('subset_beamform_cardioid_coherent_run%03d',run_num);
[~,script_name,~] = fileparts(mfilename('fullpath'));
save_path = fullfile(base_save_path,sprintf('%s_run%03d_smlen%03d',script_name,run_num,sm_len));
if ~exist(save_path,'dir')
mkdir(save_path);
end
% Set up figure
fig = figure('position',[280 60 800 560]);
corder = get(gca,'colororder');
% Loop through each ping
for iP=1:length(ping_num)
fname = sprintf('%s_ping%04d.mat', data_path,ping_num(iP));
ping_num_curr = ping_num(iP);
save_fname = sprintf('%s_run%03d_ping%04d',script_name,run_num,ping_num_curr);
disp(['Processing ',fname])
A = load(fullfile(base_data_path,data_path,fname));
title_text = sprintf('Run %d, Ping %d, %02d:%02d:%02d',...
run_num,ping_num_curr,A.data.time_hh_local,...
A.data.time_mm_local,A.data.time_ss_local);
% Get normalizer output
[beamform_norm,meta,fig_norm] = normalizer_split_window(A,norm_param,norm_detail_plot);
if norm_detail_plot
suptitle(title_text);
saveas(fig_norm,fullfile(save_path,[save_fname,'_smcmp.fig']))
saveSameSize_300(gcf,'file',fullfile(save_path,[save_fname,'_smcmp.png']),...
'format','png');
end
% Plotting
% fig = figure('position',[280 60 800 560]);
% corder = get(gca,'colororder');
figure(fig)
suptitle(title_text)
h_ori = plot_small_echogram_raw(subplot(121),A,sm_len,ori_caxis,axis_lim);
caxis([65 95])
colorbar('Ticks',65:10:95,'location','southoutside')
set(gca,'fontsize',12,'xtick',-4.3:1:-1.3,'ytick',-4.5:1:-1.5);
axis([-4.3 -1.3 -4.5 -1.5]);
xlabel('Distance (km)','fontsize',16)
ylabel('Distance (km)','fontsize',16)
set(gca,'layer','top')
% Get normalizer output
plot_normalized_echogram(subplot(122),beamform_norm,meta,norm_param,norm_caxis,axis_lim);
tt = title(sprintf('sm%d, aux%dm, guard%d',...
norm_param.sm_len,norm_param.aux_m, ...
norm_param.guard_num_bw));
set(tt,'fontsize',12);
caxis([5 15])
colorbar('Ticks',5:2:15,'location','southoutside');
set(gca,'fontsize',12,'xtick',-4.3:1:-1.3,'ytick',-4.5:1:-1.5);
axis([-4.3 -1.3 -4.5 -1.5]);
xlabel('Distance (km)','fontsize',16)
ylabel('Distance (km)','fontsize',16)
set(gca,'layer','top')
saveas(fig,fullfile(save_path,[save_fname,'.fig']),'fig');
epswrite(fullfile(save_path,[save_fname,'.eps']));
saveSameSize_150(gcf,'file',fullfile(save_path,[save_fname,'.png']),...
'format','png');
% % bw version
% colormap(brewermap([],'Greys'))
% epswrite(fullfile(save_path,[save_fname,'_bw.eps']))
% saveSameSize_150(gcf,'file',fullfile(save_path,[save_fname,'_bw.png']),...
% 'format','png');
end