%% Audiograms with isoresponse lines PLOT % This script plots the mean audiogram thresholds and isoresponse lines for % all species, which we measured ABRs from, as contour plots. It also % plots bandwidth ranges for communication and echolocation calls. clear all; %% Set data up % set this rootpaths to be the folder where you have the data folder rootpath=('C:\Users\omawe\Desktop\scripts_and_data\'); % Load files and define parameters for calls of each species load([rootpath 'all_levels.mat']); load([rootpath 'all_freqs.mat']); load([rootpath 'Call_freq_ranges.mat']); % definition for RMS values plotted in countour plot = defines lines of % contour plot z = [1, 2, 3, 4, 6, 8, 10, 12, 14]; % frequency ranges values for the different call types for the different % species territ = [[11 19.91];[NaN NaN];[NaN NaN];[NaN NaN];[NaN NaN];[NaN NaN];[NaN NaN];... [NaN NaN];[NaN NaN];[NaN NaN];[NaN NaN]]; contact = [[NaN NaN];[NaN NaN];[NaN NaN];[NaN NaN];[NaN NaN];[19.3 36.2];... [4.7 11.5];[NaN NaN];[49.15 65.34];[NaN NaN];[NaN NaN]]; contact2 = [[NaN NaN];[NaN NaN];[NaN NaN];[NaN NaN];[NaN NaN];[19.3 36.2];... [4.7 11.5];[NaN NaN];[15.69 35.6];[NaN NaN];[NaN NaN]]; alert = [[NaN NaN];[NaN NaN];[NaN NaN];[11.98 68.51];[NaN NaN];[NaN NaN];[NaN NaN];... [NaN NaN];[NaN NaN];[NaN NaN];[NaN NaN]]; % create empty structure for standard error stderr = []; %% Data processing % Load/access data for each species individually and plot it in a subplot for k=1:length(speciesnames) % run loop for each species spec = speciesnames(k); % select current species speclabel = char(strrep(spec,'_',' ')); % load data for current species load([rootpath char(spec) '_all_heatmaps.mat']); load([rootpath char(spec) '_overall_threshold.mat']); % check if all individuals are used for SEM calculation l = sum(isnan(thresholds),2); o = ones(11)*indnum; nonan = o(:,1)-l; %standard error of the mean (SEM) = std(data)/sqrt(length(data)); SEM = thresholds(:,indnum+4) ./ sqrt(nonan); mean = thresholds(:,indiv(k)+2); % Plot the contour lines subplot(subplot(6,2,k)), [C,h] = contour((all_freqs),all_levels(3:end),avrgheat(3:end,:,indiv(k)+1)*1000,... 'LevelList',z); h.LineWidth = 1.5; colormap(jet); caxis([-1,15]) clabel(C,h) set(gca,'xscale','log','xtick',[5 10 20 50 100],'ytick',(10:20:110)); xlim([4.7 137]) ylim([20 110]) title([speclabel ' (N = ' num2str(indiv(k)) ')'],'FontAngle', 'italic') hold on, % plot the mean and SEM data as a shaded errorbar (1 = transparent) shadedErrorBar(all_freqs,mean,SEM,'-k',1); % add number of individuals used to calculate SEM on the bottom of the % olot rowsToDelete = l==0; nonan = num2str(nonan); nonan(rowsToDelete,:) = ' '; h = labelpoints (all_freqs,20, nonan, 'N', 0.1, 1,'FontSize', 9,'Color', 'r'); % plot horizontal bars for the bandwidth of the different species-specific % calls plot(EC_wholeRange(k,:), [33, 33],'k', 'LineWidth',3); plot(IC_wholeRange(k,:), [30, 30],'r', 'LineWidth',3); plot(CT_wholeRange(k,:), [27, 27],'b', 'LineWidth',3); plot(contact(k,:), [27, 27],'g', 'LineWidth',3); plot(territ(k,:), [24, 24],'m', 'LineWidth',3); plot(contact2(k,:), [27, 27],'g', 'LineWidth',3); plot(alert(k,:), [24, 24],'m', 'LineWidth',3); % label the x- and y-axes if k == 1 || k == 5 || k == 9 ylabel('Tone pip level (dB peSPL)'); end if k == 10 || k == 11 xlabel('Frequency (kHz)'); end end % add annotation to plot % j = annotation('textbox','Position',[0.68 0.09 0.23 0.19], 'String',... % {'Coloured bars = Call frequency ranges';' ';'black - Echolocation call';... % 'red - Isolation call';'blue - Courtship call';'green - Contact call';... % 'magenta - Alert / Territorial call'},'VerticalAlignment','Bottom','Edgecolor','none');