% In these supplementary materials, we present the Octave code used to detect % the clicks in the data set. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % clicks DETECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % detection of clicks of dolphins in several files % inputs : - file ’list.txt’ with the list of all files of the data set % - the sound files from the list (.wav) % outputs : - one file 'Res**.txt' with dates (in s) of each detected click for each sound file % - a general file 'balanceTot.txt' with the number of detections by file % graphics software graphics toolkit(’gnuplot’) %%%%%%%%%%%%%%%%%%%% % GENERAL PARAMETERS %%%%%%%%%%%%%%%%%%%% % Files % Folder of the sound files Path = ’ adress of the folder of the files .wav ’; % List of the files FileName = textread(’list.txt’,’%s’); % Parameters of click detection % thresholds to detect the clicks threshold1=6; threshold2=1.25; % Frequency of the high pass filter (Hz) fcut=100000; % frecuency of comparation : band [f1;f2] (Hz) f1=30000; f2=90000; % minimal time lap between two clicks (in s) t_minim=2/1000; % t_chunk : time of each chunk analyzed (en s) t_chunk=30; %%%%%%%%%%%%%%%%%%%% % Loop on all sound files %%%%%%%%%%%%%%%%%%%% fileID = fopen(’balanceTot.txt’,’w’); fprintf(fileID,'Threshold: %f, coefthreshold %d, bandwidth %d - %d \n', threshold2,threshold1,f1,f2), fprintf(fileID,’ ’); fprintf(fileID,’File nb of detections ’); for k=1:1:length(FileName) % Reading of the file .wav SoundFile = [Path FileName{k}]; ResultFile = ['Resultats/Res_' FileName{k}(1:15) ’.txt’]; % Reading of the parameters of the sound file [Size_total, CHANNELS] = wavread (SoundFile, ”size”); [s,fm,dyn] = wavread(SoundFile,[1 10]); clear s; totaltime=Size_total/fm; N=floor(totaltime/t_chunk); % Loop to count the clicks each minute. dates_clicks=[]; for i=1:N t_in=(i-1)*t_chunk; t_out=t_in+t_chunk; beginningN = t_in * fm; endingN = t_out * fm; extract=wavread(SoundFile,[beginningN endingN]); signal = extract(:,1); % high pass filter [butter1,butter2]=butter(5,fcut/(fm/2),’high’); signal0=filter(butter1,butter2,signal); threshold = std(signal0)*threshold1; % looking for the moment of the signal when it is larger than the threshold. the number n counts the number of detections higher than the threshold n=0; while (max(signal0)>threshold) [x, ix] = max(signal0); spectra=abs(fft(signal(max(ix-255,1):min(ix+256,length(signal))))); energyat130 = mean(spectra(120:140)); energy_bandwidth=mean(spectra(f1/1000:f2/1000)); if (energyat130>threshold2*energy_bandwidth) dates_clicks=[dates_clicks (i-1)*t chunk+ix/fm]; n=n+1; endif signal0(max(1,ix-floor(t_minim*fm)):min(length(signal0),ix+floor(t_minim*fm)))=0; endwhile numberclicks(i)=n; clear signal; clear signal0; endfor % end of the loop on the chunks (i) % sorting of the dates of the clicks Dates_sorted=sort(dates_clicks)’; nbclicks= sum(numberclicks) % writing of the output files dlmwrite(ResultFile,Dates_sorted) fprintf(fileID,’%s %d', FileName{k}, sum(numeroclicks)); endfor % end of the loop on the wav files fclose(fileID); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % clickS PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Computation of the parameters of the clicks from the data set % inputs : - file ’list interesting files.txt’ with the list of all files with detections % - sound files from the list % outputs : - vectors of the parameters for each detected clicks %%%%%%%%%%%%%%%%%%% % GLOBAL PARAMETERS %%%%%%%%%%%%%%%%%%% % high pass filter fcut=100000; %cutting freq order=5; % butterworth filter order % duration of a chunk of the file opened around a click detection deltatmicros=500; deltat=deltatmicros/1000000; % initialisation clicks count totalclicks=0; % Importation of file list [NameFile] = textread(’list_interesting_files.txt’, ’%s’) ; N= length(NameFile) % vectors of parameters frequencypeak_total=[]; frequencycentr_total=[]; DeltaF_3dB_total=[]; Deltat_10dB_total=[]; DeltaF_10dB_total=[]; Deltat_20dB_total=[]; DeltaF_rms_total=[]; Deltat_rms_total=[]; ICI_total=[]; w=1; % counter of the number of events %%%%%%%%%%%%%%%%%%%% % PRINCIPAL LOOP %%%%%%%%%%%%%%%%%%%% for i=1:length(NameFile) % opening of the sound file + extraction parameters namefilewav=NameFile{i} Path = 'folder of the sound files'; filewav = [Path namefilewav]; [totalsize, CHANNELS] = wavread (filewav, ”size”); [s,fm,dyn] = wavread(filewav,[1 10]); clear s; Tm=1/fm; % opening of the detection file associated to the sound file date_and_hour=namefilewav(1:15); NameFiledetect=[’Res ’,date_and_hour,’.txt’]; Path = ’% folder of the detection files ’; filedetect = [Path NameFiledetect]; [date_detection_click] = textread(filedetect, ’%f’) ; M=length(date_detection_click) % test to know if the files are in the same event (less than 20 min of separation) if i==1 msg=’change of event’ frequencypeak=[]; frequencycentr=[]; DeltaF_3dB=[]; Deltat_10dB=[]; DeltaF_10dB=[]; Deltat_20dB=[]; DeltaF_rms=[]; Deltat_rms=[]; ICI=[]; test=1; else hour_raw=str2num(NameFile{i}(10:11)); min_raw=str2num(NameFile{i}(12:13)); hour_m1_raw=str2num(NameFile{i-1}(10:11)); min_m1_raw=str2num(NameFile{i-1}(12:13)); datemin=hour_raw*60+min_raw; datemin_m1=hour_m1_raw*60+min_m1_raw; if abs(datemin-datemin m1)>20 msg=’change of event’ w=w+1; test=1; else test=0; endif endif %%%%%%%%%%%%%%%%%%%% % second loop on each detected click of the file %%%%%%%%%%%%%%%%%%%% for j=1:M % ICI computation if j>1 ICI=[ICI date_detection_click(j)-date_detection_click(j-1)]; endif % opening of the chunk of sound around the click detection t_detect=date_detection_click(j); t_entree=t_detect-deltat; t_sortie=t_detect+deltat; tfinal=t sortie-t entree; t=[0:Tm:Tm*floor(tfinal/Tm)]’; beginningN = floor(t_entree * fm); endingN = beginningN + length(t) - 1; extract=wavread(filewav,[beginningN endingN]); signal = extract(:,1); % high pass filter [butter1,butter2]=butter(order,fcut/(fm/2),’high’); sfiltre=filter(butter1,butter2,signal); [val_max imax]=max(sfiltre); t0=imax*Tm; L=length(sfiltre); % computation Delta t -10dB envelope=abs(hilbert(sfiltre)); [valmax,indexmax]=max(envelope(200:300)); indexmax=indexmax+199; valplus=valmax; incrplus=0; while valplus>valmax/sqrt(10)incrplus=incrplus+1; valplus=envelope(indexmax+incrplus); endwhile valmoins=valmax; incrmoins=0; while valmoins>valmax/sqrt(10) incrmoins=incrmoins-1; valmoins=envelope(indexmax+incrmoins); endwhile delta_t_10dB=(incrplus-incrmoins)*Tm; % computation Delta t -20dB envelope=abs(hilbert(sfiltre)); [valmax,indexmax]=max(envelope(200:300)); indexmax=indexmax+199; valplus=valmax; incrplus=0; while (valplus>valmax/10) && (incrplus<255) incrplus=incrplus+1; valplus=envelope(indexmax+incrplus); endwhile valmoins=valmax; incrmoins=0; while (valmoins>valmax/10) && (incrmoins>-255) incrmoins=incrmoins-1; valmoins=envelope(indexmax+incrmoins); endwhile delta_t_20dB=(incrplus-incrmoins)*Tm; % delta t rms energyt=std(sfiltre); MOM2t=sum((t-t0).^2 . ∗ (sfiltre.^2 )); delta_t_rms=sqrt(MOM2t/energyt); % All Delta t Deltat_10dB=[Deltat_10dB delta_t_10dB]; Deltat_20dB=[Deltat_20dB delta_t_20dB]; Deltat_rms=[Deltat_rms delta t_rms]; %%%%%%%%%%%%%%%%%%%% % Estimation peak frequency and centroid frequency by FFT % eventual window hamming=0.54-0.46*cos([0:L-1]*2*pi/(L-1)); window=hamming; % Fourier transform % sfiltre window=sfiltre.*window; sfiltre_window=sfiltre; Tfourier=fft(sfiltre_window); % zoom in frequency coefzoom=2; zoom_Tfourier=Tfourier(1:floor(L/coefzoom)); f=[1:floor(L/coefzoom)]*fm/L; duree=Tm*L; % Peak frequency energy=abs(zoom_Tfourier(90:200)); [valmax,indexmax]=max(energy); fpeak=89000+indexmax*fm/L; % Centroid frequency E=sum(energy.^2); extractf=f(90:200); MOM1=sum(extractf.*energy’.^2); fcentr=MOM1/E; % Delta f -3bB energyplus=valmax; incrplus=0; while energyplus>valmax/sqrt(2) incrplus=incrplus+1; energyplus=abs(zoom Tfourier(indexmax+100+incrplus)); endwhile energymoins=valmax; incrmoins=0; while energymoins>valmax/sqrt(2) incrmoins=incrmoins-1; energymoins=abs(zoom Tfourier(indexmax+100+incrmoins)); endwhile deltaf 3dB=incrplus-incrmoins; % Delta f -10bB energyplus=valmax; incrplus=0; while energyplus>valmax/sqrt(10) incrplus=incrplus+1; energyplus=abs(zoom Tfourier(indexmax+100+incrplus)); endwhile energymoins=valmax; incrmoins=0; while energymoins>valmax/sqrt(10) incrmoins=incrmoins-1; energymoins=abs(zoom Tfourier(indexmax+100+incrmoins)); endwhile deltaf 10dB=incrplus-incrmoins; % Delta f rms E=sum(energy.^2); MOM2f=sum((extractf-fcentr).^2.*energy’.^2); deltaf rms=sqrt(MOM2f/E); % All frequency and bandwidth frequencypeak=[frequencypeak fpeak]; frequencycentr=[frequencycentr fcentr]; DeltaF_3dB=[DeltaF_3dB deltaf_3dB]; DeltaF_10dB=[DeltaF_10dB deltaf_10dB]; DeltaF_rms=[DeltaF_rms deltaf_rms]; endfor if (test==1) | (i == N ) frequencypeak_total=[frequencypeak_total frequencypeak]; frequencycentr_total=[frequencycentr_total frequencycentr]; DeltaF_3dB_total=[DeltaF_3dB_total DeltaF_3dB]; Deltat_10dB_total=[Deltat_10dB_total Deltat_10dB]; DeltaF_10dB_total=[DeltaF_10dB_total DeltaF_10dB]; Deltat_20dB_total=[Deltat_20dB_total Deltat_20dB]; DeltaF_rms_total=[DeltaF_rms_total DeltaF_rms]; Deltat_rms_total=[Deltat_rms_total Deltat_rms]; ICI_total=[ICI total_ICI]; frequencypeak=[]; frequencycentr=[]; DeltaF_3dB=[]; Deltat_10dB=[]; DeltaF_10dB=[]; Deltat_20dB=[]; DeltaF_rms=[]; Deltat_rms=[]; ICI=[]; endif % computation of the total number of clicks totalclicks=totalclicks+M; endfor