classdef CheckingClicks < matlab.apps.AppBase % Properties that correspond to app components properties (Access = public) UIFigure matlab.ui.Figure AmpAxes matlab.ui.control.UIAxes FreqAxes matlab.ui.control.UIAxes BearingAxes matlab.ui.control.UIAxes ACTIONSPanel matlab.ui.container.Panel LOADFILEButton matlab.ui.control.Button SAVEButton matlab.ui.control.Button ForwClick matlab.ui.control.Button ClickNumber matlab.ui.control.EditField BackClick matlab.ui.control.Button DELETEButton matlab.ui.control.Button PorpsButton matlab.ui.control.Button KylieButton matlab.ui.control.Button NextDayButton matlab.ui.control.Button PrevDayButton matlab.ui.control.Button Day matlab.ui.control.NumericEditField PorpsVal matlab.ui.control.NumericEditField DateLabel matlab.ui.control.Label LOADapartButton matlab.ui.control.Button WaveAxes matlab.ui.control.UIAxes SpectrogramAxes matlab.ui.control.UIAxes PowerSpecAxes matlab.ui.control.UIAxes end properties (Access = private) Fs= 500000; % Sampling frequency CTTemp = []; % Click Train temporal ClicksFile = []; % Day1 = []; Day2 = []; Day3 = []; XMin = 0; XMax = 1; end methods (Access = private) function CTTemp = NewICI(app, CTTemp, Fs) % This function calculates the inter-click interval (ICI) % and repetition rate as clicks per second (CPS) CTTemp(1).ICI = 0; for j = 2:length(CTTemp) CTTemp(j).ICI = (CTTemp(j).startSample - CTTemp(j-1).startSample)/(Fs/1000); CTTemp(j).CPS = 1000/CTTemp(j).ICI; end CTTemp(1).CPS = 0; end function UpdatePlots(app, CTTemp, ClickNum) assignin('base', 'ClickID', CTTemp(ClickNum).id) cla(app.AmpAxes, 'reset') cla(app.BearingAxes, 'reset') cla(app.FreqAxes, 'reset') app.ClickNumber.Value = num2str(ClickNum); app.DateLabel.Text = CTTemp(ClickNum).realDate; app.CTTemp = CTTemp; app.CTTemp = NewICI(app, app.CTTemp, app.Fs); app.PorpsVal.Value = app.CTTemp(ClickNum).Porps; app.CTTemp(1).SumMs = 0; for i = 2:length(app.CTTemp) app.CTTemp(i).SumMs = app.CTTemp(i-1).SumMs + app.CTTemp(i).ici; app.CTTemp(i).SumMs = app.CTTemp(i).SumMs/1000; assignin('base', "CTTemp", app.CTTemp) end CT1HQ = app.CTTemp([app.CTTemp.Porps] == 1); CT1LQ = app.CTTemp([app.CTTemp.Porps] == 0); % Plot amplitude stem(app.AmpAxes, [CT1HQ.date], [CT1HQ.Amp], 'marker', '.', 'color', 'red') hold (app.AmpAxes, 'on'); stem(app.AmpAxes, [CT1LQ.date], [CT1LQ.Amp], 'marker', '.', 'color', [0.0, 0.502, 1.00]) % [0.5843 0.8157 0.9882]) plot(app.AmpAxes, [app.CTTemp(ClickNum).date], [app.CTTemp(ClickNum).Amp], 'o', 'color', 'black') hold(app.AmpAxes,'off') YLimAmpMin = 80; YLimAmpMax = 200; ylim(app.AmpAxes, [YLimAmpMin, YLimAmpMax]) xlim(app.AmpAxes, [app.CTTemp(ClickNum-5).date, app.CTTemp(end).date]) app.AmpAxes.XTick = []; app.AmpAxes.YLabel.String = 'Amplitude (dB)'; % Plot bearing plot(app.BearingAxes, [CT1HQ.date], [CT1HQ.bearing], '.', 'color', 'red') hold (app.BearingAxes, 'on'); plot(app.BearingAxes, [CT1LQ.date], [CT1LQ.bearing], '.', 'color', [0.0, 0.502, 1.00]) %[0.5843 0.8157 0.9882]) plot(app.BearingAxes, [app.CTTemp(ClickNum).date], [app.CTTemp(ClickNum).bearing], 'o', 'color', 'black') hold (app.BearingAxes, 'off'); app.BearingAxes.YDir = 'reverse'; YLimBearMin = 0; YLimBearMax = 180; ylim(app.BearingAxes, [YLimBearMin, YLimBearMax]) app.BearingAxes.XTick = []; app.BearingAxes.YLabel.String = 'Bearing'; xlim(app.BearingAxes, [app.CTTemp(ClickNum-5).date, app.CTTemp(end).date]) % Plot centroid frequency stem(app.FreqAxes, [CT1HQ.date], [CT1HQ.CF]/1000, '.', 'color', 'red') hold (app.FreqAxes, 'on'); stem(app.FreqAxes, [CT1LQ.date], [CT1LQ.CF]/1000, '.', 'color', [0.0, 0.502, 1.00]) %[0.5843 0.8157 0.9882]) plot(app.FreqAxes, [app.CTTemp(ClickNum).date], [app.CTTemp(ClickNum).CF]/1000, 'o', 'color', 'black') hold (app.FreqAxes, 'off'); ylim(app.FreqAxes, [0, 200]) app.FreqAxes.XTick = []; app.FreqAxes.YLabel.String = 'Centroid Freq'; xlim(app.FreqAxes, [app.CTTemp(ClickNum-5).date, app.CTTemp(end).date]) %% Plot clicks click = app.CTTemp(ClickNum).wave; [PSD, f] = periodogram(click,[],[],app.Fs,'power'); % Waveform int = 1000000/app.Fs; dur = int*length(click); t = 1:int:dur; cla(app.WaveAxes, 'reset') plot(app.WaveAxes, t, click) app.WaveAxes.YTick = []; app.WaveAxes.YLabel.String = 'Waveform'; % Power spectrum cla(app.PowerSpecAxes, 'reset') plot(app.PowerSpecAxes, f/1000, PSD) app.PowerSpecAxes.YTick = []; app.PowerSpecAxes.YLabel.String = 'Power Spectrum'; % Wigner plot cla(app.SpectrogramAxes, 'reset') FFT = 512; windowSize=32; overlap=round(windowSize*0.80); [s, f1, t] = spectrogram(click,windowSize,overlap,FFT,app.Fs,'yaxis'); imagesc(app.SpectrogramAxes, t, f1/1000, log(1+abs(s))) app.SpectrogramAxes.XTick = []; app.SpectrogramAxes.YLim = [0,250]; app.SpectrogramAxes.YLabel.String = 'Spectrogram'; app.XMin = app.AmpAxes.XLim(1); app.XMax = app.AmpAxes.XLim(2); end end methods (Access = private) % Button pushed function: LOADFILEButton function OpenFile(app, event) TempClicksFile = load('PotClicks.mat'); % potencial clicks 1048 app.ClicksFile = TempClicksFile.PotClicks; app.Day1 = app.ClicksFile([app.ClicksFile.date] < 736637.794466215); app.Day2 = app.ClicksFile([app.ClicksFile.date] >= 736637.794466215); app.Day2 = app.Day2([app.Day2.date] < 736942.703638565); app.Day3 = app.ClicksFile(([app.ClicksFile.date] >= 736942.703638565)); app.CTTemp = app.Day1; UpdatePlots(app, app.CTTemp, 1) end % Button pushed function: SAVEButton function Save(app, event) PotClicks = app.ClicksFile; save('PotClicks.mat', 'PotClicks'); end % Button pushed function: DELETEButton function DeleteClick(app, event) ClickNum = str2double(app.ClickNumber.Value); %DayNum = app.Day.Value; ClickID = app.CTTemp(ClickNum).id; app.ClicksFile([app.ClicksFile.id] == ClickID) = []; app.CTTemp([app.CTTemp.id] == ClickID) = []; app.CTTemp = NewICI(app, app.CTTemp, app.Fs); UpdatePlots(app, app.CTTemp, ClickNum) end % Button pushed function: BackClick function Backward(app, event) ClickNum = str2double(app.ClickNumber.Value); if ClickNum ~= 1 ClickNum = ClickNum - 1; end %DayNum = app.Day.Value; app.ClickNumber.Value = num2str(ClickNum); UpdatePlots(app, app.CTTemp, ClickNum) end % Button pushed function: ForwClick function Forward(app, event) ClickNum = str2double(app.ClickNumber.Value); if ClickNum < length(app.CTTemp) ClickNum = ClickNum + 1; end app.ClickNumber.Value = num2str(ClickNum); UpdatePlots(app, app.CTTemp, ClickNum) end % Button pushed function: PorpsButton function MakePorp(app, event) % This function adds a 1 to column Porps to indicate it is a % porpoise click ClickNum = str2double(app.ClickNumber.Value); ClickID = app.CTTemp(ClickNum).id; app.ClicksFile([app.ClicksFile.id] == ClickID).Porps = 1; app.CTTemp([app.CTTemp.id] == ClickID).Porps = 1; app.PorpsVal.Value = app.CTTemp([app.CTTemp.id] == ClickID).Porps; UpdatePlots(app, app.CTTemp, ClickNum) end % Button pushed function: KylieButton function MakeKylie(app, event) % This function adds a 1 to column Porps to indicate it is a % dolphin click ClickNum = str2double(app.ClickNumber.Value); ClickID = app.CTTemp(ClickNum).id; app.ClicksFile([app.ClicksFile.id] == ClickID).Porps = 0; app.CTTemp([app.CTTemp.id] == ClickID).Porps = 0; app.PorpsVal.Value = app.CTTemp([app.CTTemp.id] == ClickID).Porps; UpdatePlots(app, app.CTTemp, ClickNum) end % Button pushed function: NextDayButton function NextDay(app, event) DayNum = app.Day.Value; if DayNum == 1 DayNum = 2; app.Day.Value = 2; app.CTTemp = app.Day2; elseif DayNum == 2 DayNum = 3; app.Day.Value = 3; app.CTTemp = app.Day3; else app.CTTemp = app.Day3; end UpdatePlots(app, app.CTTemp, 1) end % Button pushed function: PrevDayButton function PrevDay(app, event) DayNum = app.Day.Value; if DayNum == 1 app.CTTemp = app.Day1; elseif DayNum == 2 DayNum = 1; app.Day.Value = 1; app.CTTemp = app.Day1; elseif DayNum == 3 DayNum = 2; app.Day.Value = 2; app.CTTemp = app.Day2; end UpdatePlots(app, app.CTTemp, 1) end % Button pushed function: LOADapartButton function UploadApart(app, event) % INACTIVATED end end % App initialization and construction methods (Access = private) % Create UIFigure and components function createComponents(app) % Create UIFigure app.UIFigure = uifigure; app.UIFigure.Position = [100 100 896 514]; app.UIFigure.Name = 'UI Figure'; % Create AmpAxes app.AmpAxes = uiaxes(app.UIFigure); title(app.AmpAxes, '') xlabel(app.AmpAxes, '') ylabel(app.AmpAxes, '') app.AmpAxes.XTick = []; app.AmpAxes.Position = [37 291 491 138]; % Create FreqAxes app.FreqAxes = uiaxes(app.UIFigure); title(app.FreqAxes, '') xlabel(app.FreqAxes, '') ylabel(app.FreqAxes, '') app.FreqAxes.XTick = []; app.FreqAxes.Position = [37 20 492 113]; % Create BearingAxes app.BearingAxes = uiaxes(app.UIFigure); title(app.BearingAxes, '') xlabel(app.BearingAxes, '') ylabel(app.BearingAxes, '') app.BearingAxes.XTick = []; app.BearingAxes.Position = [37 151 492 131]; % Create ACTIONSPanel app.ACTIONSPanel = uipanel(app.UIFigure); app.ACTIONSPanel.Title = 'ACTIONS'; app.ACTIONSPanel.Position = [13 443 884 59]; % Create LOADFILEButton app.LOADFILEButton = uibutton(app.ACTIONSPanel, 'push'); app.LOADFILEButton.ButtonPushedFcn = createCallbackFcn(app, @OpenFile, true); app.LOADFILEButton.Position = [6 9 70 22]; app.LOADFILEButton.Text = 'LOAD FILE'; % Create SAVEButton app.SAVEButton = uibutton(app.ACTIONSPanel, 'push'); app.SAVEButton.ButtonPushedFcn = createCallbackFcn(app, @Save, true); app.SAVEButton.Position = [814 9 52 22]; app.SAVEButton.Text = 'SAVE'; % Create ForwClick app.ForwClick = uibutton(app.ACTIONSPanel, 'push'); app.ForwClick.ButtonPushedFcn = createCallbackFcn(app, @Forward, true); app.ForwClick.Position = [219 9 20 22]; app.ForwClick.Text = '>'; % Create ClickNumber app.ClickNumber = uieditfield(app.ACTIONSPanel, 'text'); app.ClickNumber.HorizontalAlignment = 'center'; app.ClickNumber.Position = [183 9 36 22]; app.ClickNumber.Value = '1'; % Create BackClick app.BackClick = uibutton(app.ACTIONSPanel, 'push'); app.BackClick.ButtonPushedFcn = createCallbackFcn(app, @Backward, true); app.BackClick.Position = [163 9 20 22]; app.BackClick.Text = '<'; % Create DELETEButton app.DELETEButton = uibutton(app.ACTIONSPanel, 'push'); app.DELETEButton.ButtonPushedFcn = createCallbackFcn(app, @DeleteClick, true); app.DELETEButton.Position = [399 9 56 22]; app.DELETEButton.Text = 'DELETE'; % Create PorpsButton app.PorpsButton = uibutton(app.ACTIONSPanel, 'push'); app.PorpsButton.ButtonPushedFcn = createCallbackFcn(app, @MakePorp, true); app.PorpsButton.Position = [466 9 54 22]; app.PorpsButton.Text = 'Porps'; % Create KylieButton app.KylieButton = uibutton(app.ACTIONSPanel, 'push'); app.KylieButton.ButtonPushedFcn = createCallbackFcn(app, @MakeKylie, true); app.KylieButton.Position = [556 9 53 22]; app.KylieButton.Text = 'Kylie'; % Create NextDayButton app.NextDayButton = uibutton(app.ACTIONSPanel, 'push'); app.NextDayButton.ButtonPushedFcn = createCallbackFcn(app, @NextDay, true); app.NextDayButton.Position = [732 9 60 22]; app.NextDayButton.Text = 'Next Day'; % Create PrevDayButton app.PrevDayButton = uibutton(app.ACTIONSPanel, 'push'); app.PrevDayButton.ButtonPushedFcn = createCallbackFcn(app, @PrevDay, true); app.PrevDayButton.Position = [638 9 60 22]; app.PrevDayButton.Text = 'Prev Day'; % Create Day app.Day = uieditfield(app.ACTIONSPanel, 'numeric'); app.Day.HorizontalAlignment = 'center'; app.Day.Position = [698 9 34 22]; app.Day.Value = 1; % Create PorpsVal app.PorpsVal = uieditfield(app.ACTIONSPanel, 'numeric'); app.PorpsVal.HorizontalAlignment = 'center'; app.PorpsVal.Position = [521 9 36 22]; % Create DateLabel app.DateLabel = uilabel(app.ACTIONSPanel); app.DateLabel.Position = [255 9 149 22]; app.DateLabel.Text = 'Date'; % Create LOADapartButton app.LOADapartButton = uibutton(app.ACTIONSPanel, 'push'); app.LOADapartButton.ButtonPushedFcn = createCallbackFcn(app, @UploadApart, true); app.LOADapartButton.Position = [83 9 74 22]; app.LOADapartButton.Text = 'LOAD apart'; % Create WaveAxes app.WaveAxes = uiaxes(app.UIFigure); title(app.WaveAxes, '') xlabel(app.WaveAxes, '') ylabel(app.WaveAxes, '') app.WaveAxes.PlotBoxAspectRatio = [2.96894409937888 1 1]; app.WaveAxes.XTick = []; app.WaveAxes.Position = [573 291 296 138]; % Create SpectrogramAxes app.SpectrogramAxes = uiaxes(app.UIFigure); title(app.SpectrogramAxes, '') xlabel(app.SpectrogramAxes, '') ylabel(app.SpectrogramAxes, '') app.SpectrogramAxes.PlotBoxAspectRatio = [3.46376811594203 1 1]; app.SpectrogramAxes.XTick = []; app.SpectrogramAxes.Position = [573 20 296 126]; % Create PowerSpecAxes app.PowerSpecAxes = uiaxes(app.UIFigure); title(app.PowerSpecAxes, '') xlabel(app.PowerSpecAxes, '') ylabel(app.PowerSpecAxes, '') app.PowerSpecAxes.PlotBoxAspectRatio = [2.96894409937888 1 1]; app.PowerSpecAxes.XTick = [0 50 100 150 200]; app.PowerSpecAxes.XTickLabel = {'0'; '50'; '100'; '150'; '200'}; app.PowerSpecAxes.Position = [573 151 296 138]; end end methods (Access = public) % Construct app function app = CheckingClicks % Create and configure components createComponents(app) % Register the app with App Designer registerApp(app, app.UIFigure) if nargout == 0 clear app end end % Code that executes before app deletion function delete(app) % Delete UIFigure when app is deleted delete(app.UIFigure) end end end