Script2_Analysis.m 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. clear all;
  2. close all;
  3. % fixed variables
  4. fs = 192000; % sampling rate in Hz
  5. gain_comp=156; % mic gain compensation
  6. dur_min=0.005; % minimum call duration (excluding echolocation calls) in sec
  7. factor_freq=1/1e3; % converting frequency values into kHz
  8. factor_dur=1000; % converting duration values into ms
  9. % load matrix with call values
  10. rootpath=['D:\Documents\Manuskripte\PitchShift_artificial_template\scripts\'];
  11. fn=uigetfile([rootpath '*.mat']);
  12. load([rootpath fn]);
  13. % extract batname and start/stop date and day from file name
  14. batnum=char(fn(10));
  15. %% define start and stop dates for the six bats
  16. if batnum=='2',
  17. batname='DAM'; % Bat ID
  18. startdate='17/03/08';
  19. stopdate='17/08/10';
  20. pre={'17/03/08';'17/03/09';'17/03/10';'17/03/13';'17/03/14'};
  21. post30={'17/05/09';'17/05/10';'17/05/11';'17/05/12';'17/05/19'};
  22. post60={'17/07/05';'17/07/13';'17/07/14';'17/07/17';'17/07/18'};
  23. nofi={'17/07/27';'17/07/28';'17/07/31';'17/08/01';'17/08/02'};
  24. noshi={'17/08/04';'17/08/07';'17/08/08';'17/08/09';'17/08/10'};
  25. elseif batnum=='4',
  26. batname='DID';
  27. startdate='16/12/13';
  28. stopdate='17/07/28';
  29. pre={'16/12/13';'16/12/15';'16/12/19';'16/12/20';'16/12/23'};
  30. post30={'17/02/21';'17/02/22';'17/02/28';'17/03/01';'17/03/06'};
  31. post60={'17/04/27';'17/04/28';'17/05/08';'17/05/09';'17/05/10'};
  32. nofi={'17/07/13';'17/07/14';'17/07/17';'17/07/18';'17/07/19'};
  33. noshi={'17/07/21';'17/07/24';'17/07/25';'17/07/27';'17/07/28'};
  34. elseif batnum=='5',
  35. batname='MAR';
  36. startdate='16/12/15';
  37. stopdate='17/07/28';
  38. pre={'16/12/15';'16/12/16';'16/12/19';'16/12/20';'16/12/23'};
  39. post30={'17/02/20';'17/02/21';'17/02/22';'17/02/28';'17/03/01'};
  40. post60={'17/04/24';'17/04/25';'17/04/26';'17/04/28';'17/05/08'};
  41. nofi={'17/07/13';'17/07/14';'17/07/17';'17/07/18';'17/07/19'};
  42. noshi={'17/07/21';'17/07/24';'17/07/25';'17/07/27';'17/07/28'};
  43. elseif batnum=='6',
  44. batname='PAU';
  45. startdate='17/02/07';
  46. stopdate='17/08/10';
  47. dur_min=0.025; % excluding all of PAU short calls!!!
  48. pre={'17/02/07';'17/02/09';'17/02/10';'17/02/14';'17/02/15'};
  49. post30={'17/04/06';'17/04/07';'17/04/10';'17/04/11';'17/04/12'};
  50. post60={'17/06/23';'17/06/26';'17/06/27';'17/06/28';'17/06/29'};
  51. nofi={'17/07/27';'17/07/31';'17/08/01';'17/08/02';'17/08/03'};
  52. noshi={'17/08/04';'17/08/07';'17/08/08';'17/08/09';'17/08/10'};
  53. elseif batnum=='1',
  54. batname='ARN'; % Bat ID
  55. startdate='17/03/10';
  56. stopdate='17/07/19';
  57. pre={'17/03/10';'17/03/13';'17/03/14';'17/03/15';'17/03/16';'17/03/17'};
  58. post30={'17/05/10';'17/05/11';'17/05/12';'17/05/18';'17/05/19';'17/05/22'};
  59. post60={'17/07/05';'17/07/13';'17/07/14';'17/07/17';'17/07/18';'17/07/19'};
  60. elseif batnum=='3',
  61. batname='DAV'; % Bat ID
  62. startdate='17/03/21';
  63. stopdate='17/08/01';
  64. pre={'17/03/21';'17/03/22';'17/03/23';'17/03/27';'17/03/28'};
  65. post30={'17/05/30';'17/05/31';'17/06/01';'17/06/02';'17/06/06'};
  66. post60={'17/07/25';'17/07/27';'17/07/28';'17/07/31';'17/08/01'};
  67. end
  68. % absolut number of calls found in the recordings
  69. ncalls=size(result.call);
  70. ncalls=ncalls(2);
  71. % calculate the mean fundamental frequency for all calls longer than min.
  72. % call duration
  73. mf0s=zeros(ncalls,1); % create zeros-vector with length=ncalls
  74. for callnum=1:ncalls, % go through all calls
  75. f0m=result.call(callnum).f0;
  76. % extract call day and time info for the calls
  77. callday(callnum,:)=result.call(callnum).day;
  78. calltime(callnum,:)=result.call(callnum).time;
  79. % use only calls which are longer than minimum call duration
  80. if result.call(callnum).dur>=dur_min,
  81. mf0s(callnum)=nanmean(f0m(:,2));
  82. else
  83. mf0s(callnum)=nan;
  84. end
  85. end
  86. % create pre and post data vectors
  87. pre_level=[];
  88. pre_dur=[];
  89. pre_f0=[];
  90. post30_level=[];
  91. post30_dur=[];
  92. post30_f0=[];
  93. post60_level=[];
  94. post60_dur=[];
  95. post60_f0=[];
  96. nofi_level=[];
  97. nofi_dur=[];
  98. nofi_f0=[];
  99. noshi_level=[];
  100. noshi_dur=[];
  101. noshi_f0=[];
  102. % extract variables from the structure
  103. for cn=1:ncalls,
  104. current_date=result.call(cn).day;
  105. if strcmp(current_date,pre{1}) | strcmp(current_date,pre{2}) | strcmp(current_date,pre{3}) | strcmp(current_date,pre{4}) | strcmp(current_date,pre{5}),
  106. pre_level=[pre_level result.call(cn).level];
  107. pre_dur=[pre_dur result.call(cn).dur];
  108. mf0=result.call(cn).f0;
  109. mf0=nanmean(mf0(:,2));
  110. pre_f0=[pre_f0 mf0];
  111. elseif strcmp(current_date,post30{1}) | strcmp(current_date,post30{2}) | strcmp(current_date,post30{3}) | strcmp(current_date,post30{4}) | strcmp(current_date,post30{5}),
  112. post30_level=[post30_level result.call(cn).level];
  113. post30_dur=[post30_dur result.call(cn).dur];
  114. mf0=result.call(cn).f0; % extract matrix
  115. mf0=nanmean(mf0(:,2)); % generate mean of second column
  116. post30_f0=[post30_f0 mf0]; % save
  117. elseif strcmp(current_date,post60{1}) | strcmp(current_date,post60{2}) | strcmp(current_date,post60{3}) | strcmp(current_date,post60{4}) | strcmp(current_date,post60{5}),
  118. post60_level=[post60_level result.call(cn).level];
  119. post60_dur=[post60_dur result.call(cn).dur];
  120. mf0=result.call(cn).f0; % extract matrix
  121. mf0=nanmean(mf0(:,2)); % generate mean of second column
  122. post60_f0=[post60_f0 mf0]; % save
  123. end
  124. end
  125. if batnum == '1' | batnum=='3',
  126. short=1;
  127. else
  128. short=2;
  129. for cn=1:ncalls,
  130. current_date=result.call(cn).day;
  131. if strcmp(current_date,nofi{1}) | strcmp(current_date,nofi{2}) | strcmp(current_date,nofi{3}) | strcmp(current_date,nofi{4}) | strcmp(current_date,nofi{5}),
  132. nofi_level=[nofi_level result.call(cn).level];
  133. nofi_dur=[nofi_dur result.call(cn).dur];
  134. mf0=result.call(cn).f0; % extract matrix
  135. mf0=nanmean(mf0(:,2)); % generate mean of second column
  136. nofi_f0=[nofi_f0 mf0]; % save
  137. elseif strcmp(current_date,noshi{1}) | strcmp(current_date,noshi{2}) | strcmp(current_date,noshi{3}) | strcmp(current_date,noshi{4}) | strcmp(current_date,noshi{5}),
  138. noshi_level=[noshi_level result.call(cn).level];
  139. noshi_dur=[noshi_dur result.call(cn).dur];
  140. mf0=result.call(cn).f0; % extract matrix
  141. mf0=nanmean(mf0(:,2)); % generate mean of second column
  142. noshi_f0=[noshi_f0 mf0]; % save
  143. end
  144. end
  145. end
  146. % exclude calls shorter than call_dur and convert parameters in correct
  147. % units (incl. correcting for different microphone gains)
  148. pre_duration_indices=find(pre_dur>=dur_min);
  149. post30_duration_indices=find(post30_dur>=dur_min);
  150. post60_duration_indices=find(post60_dur>=dur_min);
  151. % pre days
  152. pre_level=pre_level(pre_duration_indices)'+gain_comp;
  153. pre_dur=pre_dur(pre_duration_indices)'.*factor_dur;
  154. pre_f0=pre_f0(pre_duration_indices)'.*factor_freq;
  155. % post 30 days
  156. post30_level=post30_level(post30_duration_indices)'+gain_comp;
  157. post30_dur=post30_dur(post30_duration_indices)'.*factor_dur;
  158. post30_f0=post30_f0(post30_duration_indices)'.*factor_freq;
  159. % post 60 days
  160. post60_level=post60_level(post60_duration_indices)'+gain_comp;
  161. post60_dur=post60_dur(post60_duration_indices)'.*factor_dur;
  162. post60_f0=post60_f0(post60_duration_indices)'.*factor_freq;
  163. if short==2,
  164. nofi_duration_indices=find(nofi_dur>=dur_min);
  165. noshi_duration_indices=find(noshi_dur>=dur_min);
  166. % nofi days
  167. nofi_level=nofi_level(nofi_duration_indices)'+gain_comp;
  168. nofi_dur=nofi_dur(nofi_duration_indices)'.*factor_dur;
  169. nofi_f0=nofi_f0(nofi_duration_indices)'.*factor_freq;
  170. % noshi days
  171. noshi_level=noshi_level(noshi_duration_indices)'+gain_comp;
  172. noshi_dur=noshi_dur(noshi_duration_indices)'.*factor_dur;
  173. noshi_f0=noshi_f0(noshi_duration_indices)'.*factor_freq;
  174. end
  175. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  176. %% This part of the script PLOTS extracted data
  177. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  178. % create vectors for boxplots
  179. x_dur=[pre_dur' post30_dur' post60_dur' nofi_dur' noshi_dur'];
  180. y_dur=[ones(size(pre_dur)); 2*ones(size(post30_dur)); 3*ones(size(post60_dur));4*ones(size(nofi_dur));5*ones(size(noshi_dur))];
  181. x_level=[pre_level' post30_level' post60_level' nofi_level' noshi_level'];
  182. y_level=[ones(size(pre_level)); 2*ones(size(post30_level)); 3*ones(size(post60_level));4*ones(size(nofi_level));5*ones(size(noshi_level))];
  183. x_f0=[pre_f0; post30_f0; post60_f0; nofi_f0; noshi_f0];
  184. y_f0=[ones(size(pre_f0)); 2*ones(size(post30_f0)); 3*ones(size(post60_f0));4*ones(size(nofi_f0));5*ones(size(noshi_f0))];
  185. % create Figure with subplots for the different parameters
  186. figure('Name',['Parameter summary boxplots of bat ' batnum],'NumberTitle','off','units','normalized','outerposition',[0 0 1 1]),
  187. % subplot for duration
  188. subplot(222),
  189. boxplot(x_dur, y_dur,'notch','on',...
  190. 'symbol','.','color','k','jitter',0.2,'width',0.75);
  191. set(gca,'xtick',1:length(y_dur),'xticklabel',1:length(y_dur),...
  192. 'XTickLabel',{'pre_filter' 'filter_30' 'filter_60' 'no_filter' 'no_ps'},'fontsize',14,'YGrid','on');
  193. ylabel('duration (ms)','fontsize',16);
  194. ylim([0 95]);
  195. box off
  196. h = findobj(gca,'Tag','Box');
  197. for j=1:length(h)
  198. patch(get(h(1,1),'XData'),get(h(1,1),'YData'),'r','FaceAlpha',.7);
  199. patch(get(h(2,1),'XData'),get(h(2,1),'YData'),'g','FaceAlpha',.7);
  200. patch(get(h(3,1),'XData'),get(h(3,1),'YData'),'c','FaceAlpha',.7);
  201. if short==2,
  202. patch(get(h(4,1),'XData'),get(h(4,1),'YData'),'b','FaceAlpha',.7);
  203. patch(get(h(5,1),'XData'),get(h(5,1),'YData'),'r','FaceAlpha',.7);
  204. end
  205. end
  206. title(['Bat ' batnum ' - Call duration']);
  207. % subplot for call level
  208. subplot(223),
  209. boxplot(x_level, y_level,'notch','on',...
  210. 'symbol','.','color','k','jitter',0.2,'width',0.75);
  211. set(gca,'xtick',1:length(y_level),'xticklabel',1:length(y_level),...
  212. 'XTickLabel',{'pre_filter' 'filter_30' 'filter_60' 'no_filter' 'no_ps'},'fontsize',14,'YGrid','on');
  213. ylabel('level (dB SPL)','fontsize',16);
  214. ylim([90 130]);
  215. box off
  216. h = findobj(gca,'Tag','Box');
  217. for j=1:length(h)
  218. patch(get(h(1,1),'XData'),get(h(1,1),'YData'),'r','FaceAlpha',.7);
  219. patch(get(h(2,1),'XData'),get(h(2,1),'YData'),'g','FaceAlpha',.7);
  220. patch(get(h(3,1),'XData'),get(h(3,1),'YData'),'c','FaceAlpha',.7);
  221. if short==2,
  222. patch(get(h(4,1),'XData'),get(h(4,1),'YData'),'b','FaceAlpha',.7);
  223. patch(get(h(5,1),'XData'),get(h(5,1),'YData'),'r','FaceAlpha',.7);
  224. end
  225. end
  226. title(['Bat ' batnum ' - Call level']);
  227. % subplot for mean fundamental frequency
  228. subplot(221),
  229. boxplot(x_f0, y_f0,'notch','on',...
  230. 'symbol','.','color','k','jitter',0.2,'width',0.75);
  231. set(gca,'xtick',1:length(y_f0),'xticklabel',1:length(y_f0),...
  232. 'XTickLabel',{'pre_filter' 'filter_30' 'filter_60' 'no_filter' 'no_ps'},'fontsize',14,'YGrid','on');
  233. ylabel('Mean f0 (kHz)','fontsize',16);
  234. ylim([12 22]);
  235. box off
  236. h = findobj(gca,'Tag','Box');
  237. for j=1:length(h)
  238. patch(get(h(1,1),'XData'),get(h(1,1),'YData'),'r','FaceAlpha',.7);
  239. patch(get(h(2,1),'XData'),get(h(2,1),'YData'),'g','FaceAlpha',.7);
  240. patch(get(h(3,1),'XData'),get(h(3,1),'YData'),'c','FaceAlpha',.7);
  241. if short==2,
  242. patch(get(h(4,1),'XData'),get(h(4,1),'YData'),'b','FaceAlpha',.7);
  243. patch(get(h(5,1),'XData'),get(h(5,1),'YData'),'r','FaceAlpha',.7);
  244. end
  245. end
  246. title(['Bat ' batnum ' - Mean fundamental frequency (f0)']);
  247. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  248. %% This part of the script runs the statistics
  249. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  250. % stats for the duration (dur)
  251. PRE_dur=[kstest(pre_dur),size(pre_dur),median(pre_dur),iqr(pre_dur)];
  252. POST30_dur=[kstest(post30_dur),size(post30_dur),median(post30_dur),iqr(post30_dur)];
  253. POST60_dur=[kstest(post60_dur),size(post60_dur),median(post60_dur),iqr(post60_dur)];
  254. p30_dur=ranksum(pre_dur,post30_dur);
  255. p60_dur=ranksum(pre_dur,post60_dur);
  256. p3060_dur=ranksum(post30_dur,post60_dur);
  257. if short ==2,
  258. NOFI_dur=[kstest(nofi_dur),size(nofi_dur),median(nofi_dur),iqr(nofi_dur)];
  259. NOSHI_dur=[kstest(noshi_dur),size(noshi_dur),median(noshi_dur),iqr(noshi_dur)];
  260. p60nofi_dur=ranksum(post60_dur,nofi_dur);
  261. pnofishi_dur=ranksum(nofi_dur,noshi_dur);
  262. end
  263. % stats for call level
  264. PRE_level=[kstest(pre_level),size(pre_level),median(pre_level),iqr(pre_level)];
  265. POST30_level=[kstest(post30_level),size(post30_level),median(post30_level),iqr(post30_level)];
  266. POST60_level=[kstest(post60_level),size(post60_level),median(post60_level),iqr(post60_level)];
  267. p30_level=ranksum(pre_level,post30_level);
  268. p60_level=ranksum(pre_level,post60_level);
  269. p3060_level=ranksum(post30_level,post60_level);
  270. if short==2,
  271. NOFI_level=[kstest(nofi_level),size(nofi_level),median(nofi_level),iqr(nofi_level)];
  272. NOSHI_level=[kstest(noshi_level),size(noshi_level),median(noshi_level),iqr(noshi_level)];
  273. p60nofi_level=ranksum(post60_level,nofi_level);
  274. pnofishi_level=ranksum(nofi_level,noshi_level);
  275. end
  276. % stats for mean fundamental frequency (f0)
  277. PRE_f0=[kstest(pre_f0),size(pre_f0),median(pre_f0),iqr(pre_f0)];
  278. POST60_f0=[kstest(post60_f0),size(post60_f0),median(post60_f0),iqr(post60_f0)];
  279. POST30_f0=[kstest(post30_f0),size(post30_f0),median(post30_f0),iqr(post30_f0)];
  280. p30_f0=ranksum(pre_f0,post30_f0);
  281. p60_f0=ranksum(pre_f0,post60_f0);
  282. p3060_f0=ranksum(post30_f0,post60_f0);
  283. if short==2,
  284. NOFI_f0=[kstest(nofi_f0),size(nofi_f0),median(nofi_f0),iqr(nofi_f0)];
  285. NOSHI_f0=[kstest(noshi_f0),size(noshi_f0),median(noshi_f0),iqr(noshi_f0)];
  286. p60nofi_f0=ranksum(post60_f0,nofi_f0);
  287. pnofishi_f0=ranksum(nofi_f0,noshi_f0);
  288. end
  289. %print tables with stats for comparison pre and post 30 days data
  290. ps1=[p30_dur;p30_dur;p30_level;p30_level;p30_f0;p30_f0];
  291. table1=[PRE_dur;POST30_dur;PRE_level;POST30_level;PRE_f0;POST30_f0];
  292. table1(:,3)=table1(:,4);
  293. table1(:,4)=table1(:,5);
  294. table1(:,5)=ps1;
  295. printmat(table1, 'Summary Stats pre and post30 data', 'pre_dur post30_dur pre_level post30_level pre_f0 post30_f0',...
  296. 'ks-test calls median IQR p-value')
  297. %print tables with stats for comparison pre and post 60 days data
  298. ps2=[p60_dur;p60_dur;p60_level;p60_level;p60_f0;p60_f0];
  299. table2=[PRE_dur;POST60_dur;PRE_level;POST60_level;PRE_f0;POST60_f0];
  300. table2(:,3)=table2(:,4);
  301. table2(:,4)=table2(:,5);
  302. table2(:,5)=ps2;
  303. printmat(table2, 'Summary Stats pre and post60 data', 'pre_dur post60_dur pre_level post60_level pre_f0 post60_f0',...
  304. 'ks-test calls median IQR p-value')
  305. % print tables with stats for comparison post 30 and post 60 days data
  306. ps3=[p3060_dur;p3060_dur;p3060_level;p3060_level;p3060_f0;p3060_f0];
  307. table3=[POST30_dur;POST60_dur;POST30_level;POST60_level;POST30_f0;POST60_f0];
  308. table3(:,3)=table3(:,4);
  309. table3(:,4)=table3(:,5);
  310. table3(:,5)=ps3;
  311. printmat(table3, 'Summary Stats post30 and post60 data', 'post30_dur post60_dur post30_level post60_level post30_f0 post60_f0',...
  312. 'ks-test calls median IQR p-value')
  313. if short==2,
  314. % print tables with stats for comparison post 60 days and no_filter data
  315. ps4=[p60nofi_dur;p60nofi_dur;p60nofi_level;p60nofi_level;p60nofi_f0;p60nofi_f0];
  316. table4=[POST60_dur;NOFI_dur;POST60_level;NOFI_level;POST60_f0;NOFI_f0];
  317. table4(:,3)=table4(:,4);
  318. table4(:,4)=table4(:,5);
  319. table4(:,5)=ps4;
  320. printmat(table4, 'Summary Stats post60 and no_filter data', 'post60_dur nofi_dur post60_level nofi_level post60_f0 nofi_f0',...
  321. 'ks-test calls median IQR p-value')
  322. % print tables with stats for comparison no_filter and no_shift data
  323. ps6=[pnofishi_dur;pnofishi_dur;pnofishi_level;pnofishi_level;pnofishi_f0;pnofishi_f0];
  324. table6=[NOFI_dur;NOSHI_dur;NOFI_level;NOSHI_level;NOFI_f0;NOSHI_f0];
  325. table6(:,3)=table6(:,4);
  326. table6(:,4)=table6(:,5);
  327. table6(:,5)=ps6;
  328. printmat(table6, 'Summary Stats no_filter and no_shift data', 'nofi_dur noshi_dur nofi_level noshi_level nofi_f0 noshi_f0',...
  329. 'ks-test calls median IQR p-value')
  330. end
  331. %%%%%%%%%%%%%%% mean and standard deviation script
  332. %pre days
  333. pre_level_mean=mean(pre_level);
  334. pre_dur_mean=mean(pre_dur);
  335. pre_f0_mean=mean(pre_f0);
  336. pre_level_std=std(pre_level);
  337. pre_dur_std=std(pre_dur);
  338. pre_f0_std=std(pre_f0);
  339. %post 30 days
  340. post30_level_mean=mean(post30_level);
  341. post30_dur_mean=mean(post30_dur);
  342. post30_f0_mean=mean(post30_f0);
  343. post30_level_std=std(post30_level);
  344. post30_dur_std=std(post30_dur);
  345. post30_f0_std=std(post30_f0);
  346. %post 60 days
  347. post60_level_mean=mean(post60_level);
  348. post60_dur_mean=mean(post60_dur);
  349. post60_f0_mean=mean(post60_f0);
  350. post60_level_std=std(post60_level);
  351. post60_dur_std=std(post60_dur);
  352. post60_f0_std=std(post60_f0);
  353. if short==2,
  354. %no_filter days
  355. nofi_level_mean=mean(nofi_level);
  356. nofi_dur_mean=mean(nofi_dur);
  357. nofi_f0_mean=mean(nofi_f0);
  358. nofi_level_std=std(nofi_level);
  359. nofi_dur_std=std(nofi_dur);
  360. nofi_f0_std=std(nofi_f0);
  361. %no_pitch-shift days
  362. noshi_level_mean=mean(noshi_level);
  363. noshi_dur_mean=mean(noshi_dur);
  364. noshi_f0_mean=mean(noshi_f0);
  365. noshi_level_std=std(noshi_level);
  366. noshi_dur_std=std(noshi_dur);
  367. noshi_f0_std=std(noshi_f0);
  368. % prints table with mean and std values
  369. table5=[pre_f0_mean;post30_f0_mean;post60_f0_mean;nofi_f0_mean;noshi_f0_mean;pre_f0_std;post30_f0_std;post60_f0_std;nofi_f0_std;noshi_f0_std];
  370. table5(1:5,2)=table5(6:10,1);
  371. table5(6:10,1)=0;
  372. printmat(table5, 'Summary stats for fundamental freq.', 'pre_f0 post30_f0 post60_f0 no_filter_f0 no_pitch_shift - - - - -',...
  373. 'mean std')
  374. %plots graphic with mean and std values
  375. y = [pre_f0_mean post30_f0_mean post60_f0_mean nofi_f0_mean noshi_f0_mean];
  376. x = [1 2 3 4 5];
  377. figure,
  378. err = [pre_f0_std post30_f0_std post60_f0_std nofi_f0_std noshi_f0_std];
  379. errorbar(x,y,err,'-s','LineWidth',3,'MarkerSize',3,...
  380. 'MarkerEdgeColor','k','MarkerFaceColor','k')
  381. set(gca,'XTickLabel',{'','pre_filter','','filter30','','filter60','','no_filter','','no_pitch-shift',''});
  382. grid on
  383. title(['Bat ' num2str(batnum) ' - change of mean fundamental frequency']);
  384. ylabel('mean f0 (kHz)')
  385. end
  386. if short ==1,
  387. % prints table with mean and std values
  388. table5=[pre_f0_mean;post30_f0_mean;post60_f0_mean;pre_f0_std;post30_f0_std;post60_f0_std];
  389. table5(1:3,2)=table5(4:6,1);
  390. table5(4:6,1)=0;
  391. printmat(table5, 'Summary stats for fundamental freq.', 'pre_f0 post30_f0 post60_f0 - - -',...
  392. 'mean std')
  393. %plots graphic with mean and std values
  394. y = [pre_f0_mean post30_f0_mean post60_f0_mean];
  395. x = [1 2 3];
  396. figure,
  397. err = [pre_f0_std post30_f0_std post60_f0_std];
  398. errorbar(x,y,err,'-s','LineWidth',3,'MarkerSize',3,...
  399. 'MarkerEdgeColor','k','MarkerFaceColor','k')
  400. set(gca,'XTickLabel',{'pre_filter','','','','','filter30','','','','','filter60'});
  401. grid on
  402. title([ 'Bat ' num2str(batnum) ' - change of mean fundamental frequency']);
  403. ylabel('mean f0 (kHz)')
  404. end