function varargout = Classify(varargin)
% CLASSIFY M-file for Classify.fig
%      CLASSIFY, by itself, creates a new CLASSIFY or raises the existing
%      singleton*.
%
%      H = CLASSIFY returns the handle to a new CLASSIFY or the handle to
%      the existing singleton*.
%
%      CLASSIFY('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CLASSIFY.M with the given input arguments.
%
%      CLASSIFY('Property','Value',...) creates a new CLASSIFY or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Classify_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Classify_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Classify

% Last Modified by GUIDE v2.5 06-May-2005 15:12:04

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Classify_OpeningFcn, ...
                   'gui_OutputFcn',  @Classify_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Classify is made visible.
function Classify_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Classify (see VARARGIN)

% Choose default command line output for Classify
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Classify wait for user response (see UIRESUME)
% uiwait(handles.figure1);

handles.prefs = varargin{1};
guidata(hObject, handles);

% Set initial call number to 1 (this may change based on user in future)
handles.Call = 1;
guidata(hObject, handles);

seg_hold = [];
a = 0;

if exist(strcat(handles.prefs.proj_dir,'Files.mat'))
    load(strcat(handles.prefs.proj_dir,'Files.mat'))
    if length(handles.prefs.filenames) ~= length(files_used)
        handles.loadclass = 0;
        %disp('wrg length')
    else
        for n = 1:length(handles.prefs.filenames)
            file_hold = strvcat(handles.prefs.filenames{n},files_used{n});
            filen1 = file_hold(1,1:size(file_hold,2));
            filen2 = file_hold(2,1:size(file_hold,2));
            if filen1 ~= filen2
                handles.loadclass = 0;
                %disp('wrg name')
            end
        end
        handles.loadclass = 1;
        %disp('right')
    end
else
    handles.loadclass = 0;
    %disp('not exist')
end

%mink = handles.loadclass

for n_f = 1:length(handles.prefs.filenames)
    filename = strcat(handles.prefs.proj_dir,'seg_data_',strrep(handles.prefs.filenames{n_f},'.wav','.mat'));
    load(filename)
    
    filename = strcat(handles.prefs.proj_dir,'param_data_',strrep(handles.prefs.filenames{n_f},'.wav','.mat'));
    load(filename)
    
    
    
    % CHANGED HERE %
    seg_data=seg_data.reg_arr;
    
    % CHANGED HERE %
    for n = (1+a):(size(seg_data)+a)
        handles.file_num(n) = n_f;
        guidata(hObject, handles);
    end
    a = n;
    
    % CHANGED HERE %
    if n_f==1
        seg_hold=seg_data;
        data_hold=data;
    elseif n_f>1    
        seg_hold = cat(1, seg_hold, seg_data);
        data_hold = cat(2, data_hold, data);
    end
end
seg_data = seg_hold;
handles.data=data_hold;
handles.seg_data=seg_data;
% Total number of calls needs to be calc dynamically

handles.prefs.NoOfCalls = size(seg_data,1);
guidata(hObject, handles);

% handles.NoOfFiles = size(handles.prefs.filenames,1);
% guidata(hObject, handles);

if exist(strcat(handles.prefs.proj_dir,'Class.mat'),'file') & handles.loadclass == 1
    load(strcat(handles.prefs.proj_dir,'class.mat'))
    handles.data_class = call_class;
    guidata(hObject, handles);
elseif handles.prefs.NoOfCalls >0
    handles.data_class = ones(handles.prefs.NoOfCalls,1);
    guidata(hObject, handles);
else
    dial.text1='Warning: No calls found';
    dial.butt_text='OK';
    dial.win_title='Warning';
    DB=dial_box(dial);
end

handles.CallType = handles.data_class(1);
guidata(hObject, handles);
NumCallType = linspace(1,10,10);
pos = find(NumCallType ~= handles.CallType);
HandHold = [handles.Other, handles.Null, handles.A, handles.B, handles.C, handles.D, handles.E, handles.F, handles.G, handles.H];
off = HandHold(pos);
mutual_exclude(off)

if handles.CallType == 1 
    set(handles.Other,'Value',1)
elseif handles.CallType == 2
    set(handles.Null,'Value',1)
elseif handles.CallType == 3
    set(handles.A,'Value',1)
elseif handles.CallType == 4
    set(handles.B,'Value',1)
elseif handles.CallType == 5
    set(handles.C,'Value',1)
elseif handles.CallType == 6
    set(handles.D,'Value',1)
elseif handles.CallType == 7
    set(handles.E,'Value',1)
elseif handles.CallType == 8
    set(handles.F,'Value',1)
elseif handles.CallType == 9
    set(handles.G,'Value',1)
else
    set(handles.H,'Value',1)
end

% handles.Rand = 'this is random';
% guidata(hObject, handles);

% handles.calltypehold = zeros(10,1);
% guidata(hObject, handles);
% handles.calltypehold

refresh(hObject, handles)

set(handles.ParaDisp, 'Value', 1);
refresh(hObject, handles)



% --- Outputs from this function are returned to the command line.
function varargout = Classify_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;
%varargout{2} = handles.prefs;
%-------------------------------------
% --------------------------------------------------------------------



% --------------------------------------------------------------------
% --- CALL TYPE RADIO BUTTONS

% --- Executes on button press in Other.
function Other_Callback(hObject, eventdata, handles)
% hObject    handle to Other (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of Other
off = [handles.A, handles.B, handles.C, handles.D, handles.E, handles.F, handles.G, handles.H, handles.Null];
mutual_exclude(off)

if get(handles.Other,'Value') == 0
    set(handles.Other,'Value',1)
end

handles.CallType = 1;
guidata(hObject, handles);

refresh(hObject, handles)
%-------------------------------------

% --- Executes on button press in Null.
function Null_Callback(hObject, eventdata, handles)
% hObject    handle to Null (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of Null
off = [handles.A, handles.B, handles.C, handles.D, handles.E, handles.F, handles.G, handles.H, handles.Other];
mutual_exclude(off)

if get(handles.Null,'Value') == 0
    set(handles.Null,'Value',1)
end

handles.CallType = 2;
guidata(hObject, handles);

refresh(hObject, handles)
%-------------------------------------

% --- Executes on button press in A.
function A_Callback(hObject, eventdata, handles)
% hObject    handle to A (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of A
off = [handles.B, handles.C, handles.D, handles.E, handles.F, handles.G, handles.H, handles.Other, handles.Null];
mutual_exclude(off)

if get(handles.A,'Value') == 0
    set(handles.A,'Value',1)
end

handles.CallType = 3;
guidata(hObject, handles);

refresh(hObject, handles)
%------------------------------------

% --- Executes on button press in B.
function B_Callback(hObject, eventdata, handles)
% hObject    handle to B (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of B
off = [handles.A, handles.C, handles.D, handles.E, handles.F, handles.G, handles.H, handles.Other, handles.Null];
mutual_exclude(off)

if get(handles.B,'Value') == 0
    set(handles.B,'Value',1)
end

handles.CallType = 4;
guidata(hObject, handles);

refresh(hObject, handles)
%-------------------------------------

% --- Executes on button press in C.
function C_Callback(hObject, eventdata, handles)
% hObject    handle to C (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of C
off = [handles.A, handles.B, handles.D, handles.E, handles.F, handles.G, handles.H, handles.Other, handles.Null];
mutual_exclude(off)

if get(handles.C,'Value') == 0
    set(handles.C,'Value',1)
end

handles.CallType = 5;
guidata(hObject, handles);

refresh(hObject, handles)
%-------------------------------------

% --- Executes on button press in D.
function D_Callback(hObject, eventdata, handles)
% hObject    handle to D (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of D
off = [handles.A, handles.B, handles.C, handles.E, handles.F, handles.G, handles.H, handles.Other, handles.Null];
mutual_exclude(off)

if get(handles.D,'Value') == 0
    set(handles.D,'Value',1)
end

handles.CallType = 6;
guidata(hObject, handles);

refresh(hObject, handles)
%-------------------------------------

% --- Executes on button press in E.
function E_Callback(hObject, eventdata, handles)
% hObject    handle to E (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of E
off = [handles.A, handles.B, handles.C, handles.D, handles.F, handles.G, handles.H, handles.Other, handles.Null];
mutual_exclude(off)

if get(handles.E,'Value') == 0
    set(handles.E,'Value',1)
end

handles.CallType = 7;
guidata(hObject, handles);

refresh(hObject, handles)
%-------------------------------------

% --- Executes on button press in F.
function F_Callback(hObject, eventdata, handles)
% hObject    handle to F (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of F
off = [handles.A, handles.B, handles.C, handles.D, handles.E, handles.G, handles.H, handles.Other, handles.Null];
mutual_exclude(off)

if get(handles.F,'Value') == 0
    set(handles.F,'Value',1)
end

handles.CallType = 8;
guidata(hObject, handles);

refresh(hObject, handles)
%-------------------------------------

% --- Executes on button press in G.
function G_Callback(hObject, eventdata, handles)
% hObject    handle to G (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of G
off = [handles.A, handles.B, handles.C, handles.D, handles.E, handles.F, handles.H, handles.Other, handles.Null];
mutual_exclude(off)

if get(handles.G,'Value') == 0
    set(handles.G,'Value',1)
end

handles.CallType = 9;
guidata(hObject, handles);

refresh(hObject, handles)
%-------------------------------------

% --- Executes on button press in H.
function H_Callback(hObject, eventdata, handles)
% hObject    handle to H (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of H
off = [handles.A, handles.B, handles.C, handles.D, handles.E, handles.F, handles.G, handles.Other, handles.Null];
mutual_exclude(off)

if get(handles.H,'Value') == 0
    set(handles.H,'Value',1)
end

handles.CallType = 10;
guidata(hObject, handles);

refresh(hObject, handles)
%-------------------------------------

% --- Mutually Exclusive radio button function
function mutual_exclude(off)
set(off,'Value',0);

%-------------------------------------

%--- End of Call type
%------------------------------------------------------------------------



%------------------------------------------------------------------------
% --- Executes on button press in ClassDone.
function ClassDone_Callback(hObject, eventdata, handles)
% hObject    handle to ClassDone (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

filename = strcat(handles.prefs.proj_dir,'Class');
call_class = handles.data_class;
save(filename, 'call_class')

filename = strcat(handles.prefs.proj_dir,'Files');
for n = 1:length(handles.prefs.filenames)
    files_used{n} = handles.prefs.filenames{n};
end
save(filename, 'files_used')

handles.prefs.ClassSt = 1;
guidata(hObject, handles);

%cd(handles.prefs.func_dir)
close(handles.output)
main(handles.prefs)
%------------------------------------------------------------------------



%------------------------------------------------------------------------
%--- Call Search Section

% --- Executes on button press in Next.
function Next_Callback(hObject, eventdata, handles)
% hObject    handle to Next (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% LOAD NEXT CALL
if handles.Call ~= handles.prefs.NoOfCalls
    handles.Call = handles.Call + 1;
    guidata(hObject, handles);
else
    handles.Call = handles.prefs.NoOfCalls;
    guidata(hObject, handles);
end

handles.CallType = handles.data_class(handles.Call);
guidata(hObject, handles);

NumCallType = linspace(1,10,10);
pos = find(NumCallType ~= handles.CallType);
HandHold = [handles.Other, handles.Null, handles.A, handles.B, handles.C, handles.D, handles.E, handles.F, handles.G, handles.H];
off = HandHold(pos);
mutual_exclude(off)

if handles.CallType == 1 
    set(handles.Other,'Value',1)
elseif handles.CallType == 2
    set(handles.Null,'Value',1)
elseif handles.CallType == 3
    set(handles.A,'Value',1)
elseif handles.CallType == 4
    set(handles.B,'Value',1)
elseif handles.CallType == 5
    set(handles.C,'Value',1)
elseif handles.CallType == 6
    set(handles.D,'Value',1)
elseif handles.CallType == 7
    set(handles.E,'Value',1)
elseif handles.CallType == 8
    set(handles.F,'Value',1)
elseif handles.CallType == 9
    set(handles.G,'Value',1)
else
    set(handles.H,'Value',1)
end

refresh(hObject, handles)
%-------------------------------------

% --- Executes on button press in Previous.
function Previous_Callback(hObject, eventdata, handles)
% hObject    handle to Previous (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%LOAD PREV CALL
if handles.Call ~= 1
    handles.Call = handles.Call - 1;
    guidata(hObject, handles);
else
    handles.Call = 1;
    guidata(hObject, handles);
end

handles.CallType = handles.data_class(handles.Call);
guidata(hObject, handles);

NumCallType = linspace(1,10,10);
pos = find(NumCallType ~= handles.CallType);
HandHold = [handles.Other, handles.Null, handles.A, handles.B, handles.C, handles.D, handles.E, handles.F, handles.G, handles.H];
off = HandHold(pos);
mutual_exclude(off)

if handles.CallType == 1 
    set(handles.Other,'Value',1)
elseif handles.CallType == 2
    set(handles.Null,'Value',1)
elseif handles.CallType == 3
    set(handles.A,'Value',1)
elseif handles.CallType == 4
    set(handles.B,'Value',1)
elseif handles.CallType == 5
    set(handles.C,'Value',1)
elseif handles.CallType == 6
    set(handles.D,'Value',1)
elseif handles.CallType == 7
    set(handles.E,'Value',1)
elseif handles.CallType == 8
    set(handles.F,'Value',1)
elseif handles.CallType == 9
    set(handles.G,'Value',1)
else
    set(handles.H,'Value',1)
end

refresh(hObject, handles)
%-------------------------------------

% --- Executes during object creation, after setting all properties.
function CallNum_CreateFcn(hObject, eventdata, handles)
% hObject    handle to CallNum (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
%-------------------------------------

function CallNum_Callback(hObject, eventdata, handles)
% hObject    handle to CallNum (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of CallNum as text
%        str2double(get(hObject,'String')) returns contents of CallNum as a double

%-------------------------------------

% --- Executes on button press in Jump2Call.
function Jump2Call_Callback(hObject, eventdata, handles)
% hObject    handle to Jump2Call (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

Call_num = str2double(get(handles.CallNum,'String'));

if Call_num >= 1 & Call_num <= handles.prefs.NoOfCalls
    handles.Call = Call_num;
    guidata(hObject, handles);
elseif Call_num < 1
    handles.Call = 1;
    guidata(hObject, handles);
else 
    handles.Call = handles.prefs.NoOfCalls;
    guidata(hObject, handles);
end

handles.CallType = handles.data_class(handles.Call);
guidata(hObject, handles);

NumCallType = linspace(1,10,10);
pos = find(NumCallType ~= handles.CallType);
HandHold = [handles.Other, handles.Null, handles.A, handles.B, handles.C, handles.D, handles.E, handles.F, handles.G, handles.H];
off = HandHold(pos);
mutual_exclude(off)

if handles.CallType == 1 
    set(handles.Other,'Value',1)
elseif handles.CallType == 2
    set(handles.Null,'Value',1)
elseif handles.CallType == 3
    set(handles.A,'Value',1)
elseif handles.CallType == 4
    set(handles.B,'Value',1)
elseif handles.CallType == 5
    set(handles.C,'Value',1)
elseif handles.CallType == 6
    set(handles.D,'Value',1)
elseif handles.CallType == 7
    set(handles.E,'Value',1)
elseif handles.CallType == 8
    set(handles.F,'Value',1)
elseif handles.CallType == 9
    set(handles.G,'Value',1)
else
    set(handles.H,'Value',1)
end

refresh(hObject, handles)
%-------------------------------------
%------------------------------------------------------------------------



%------------------------------------------------------------------------
%--- Function to refresh the screen
function refresh(hObject, handles)

set(handles.CallNumWrt,'String',handles.Call)

TypeString = [{'Other'};{'Null'};{'A'};{'B'};{'C'};{'D'};{'E'};{'F'};{'G'};{'H'}];
CallTypeString = TypeString(handles.CallType);

set(handles.NumCallswrt,'String',handles.prefs.NoOfCalls)
set(handles.CallTypeWrt,'String',CallTypeString)
set(handles.RandWrt,'String',handles.prefs.filenames{handles.file_num(handles.Call)})


set(handles.SpecCall,'String',handles.Call)
set(handles.LogSpecCall,'String',handles.Call)

handles.data_class(handles.Call) = handles.CallType;
guidata(hObject, handles);


% CHANGED HERE %
% for n_f = 1:length(handles.prefs.filenames)
%     filename = strcat(handles.prefs.proj_dir,'seg_data_',strrep(handles.prefs.filenames{n_f},'.wav','.mat'));
%     load(filename);
% end
filename = strcat(handles.prefs.proj_dir,'seg_data_',strrep(handles.prefs.filenames{handles.file_num(handles.Call)},'.wav','.mat'));
load(filename);
seg_data=seg_data.reg_arr;
n_f=handles.file_num(handles.Call);
seg_data=handles.seg_data;




%data
size(seg_data)
[wave.wf,wave.fs] = wavread(strcat(handles.prefs.paths{handles.file_num(handles.Call)},handles.prefs.filenames{handles.file_num(handles.Call)}),[seg_data(handles.Call,1) seg_data(handles.Call,2)]);
[wave.spec, wave.freqint, wave.sampint] = specgram(wave.wf);
wave.spec=abs(wave.spec);

set(handles.TIFwrt,'String',seg_data(handles.Call,1)/300000)

% ADD STUFF TO DISPAY SPECTROGRAMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
colormap(hot)

axes(handles.Spectro)
imagesc([0,(seg_data(handles.Call,2)-seg_data(handles.Call,1))/wave.fs],[0,150000],wave.spec)
xlabel('Time (s)')
ylabel('Frequency (Hz)')
axis xy;

val = get(handles.ParaDisp, 'Value');
if val == 1
    hold on
    
%     filename = strcat(handles.prefs.proj_dir,'param_data_',strrep(handles.prefs.filenames{n_f},'.wav','.mat'));
%     load(filename)
    data=handles.data;
    call_hold = handles.Call;
%     data(1,jeff)
%     data(2,jeff)
%     data(1,1)
%     data(2,1)
    
    % ADD SPLITS IN
    %plot(handles.Spectro,[0 1],[50000 50000],'g-')
    time_hold1 = (seg_data(call_hold,2)-seg_data(call_hold,1))/wave.fs;
    freq_hold1 = data(1,call_hold);
    %plot(handles.Spectro,[0 minkey],[monkey monkey],'.g-');
    plot(handles.Spectro,[0 time_hold1],[freq_hold1 freq_hold1],'.g-');
    
    time_hold2 = (seg_data(call_hold,2)-seg_data(call_hold,1))/wave.fs;
    freq_hold2 = data(2,call_hold);
    plot(handles.Spectro,[0 time_hold2],[freq_hold2 freq_hold2],'.g-');
    
    time_hold3 = (seg_data(handles.Call,2)-seg_data(handles.Call,1))/wave.fs;
    freq_hold3 = data(6,call_hold);
    plot(handles.Spectro,[0 time_hold3],[freq_hold3 freq_hold3],'.b-');
    hold off
    
    %bob = handles.CLwrt
    %jeff = data(5,handles.Call)
    
    set(handles.CL,'String','Call length:')
    set(handles.abv,'String','% Above f12 threshold :')
    set(handles.CFM,'String','Curve Fit Mean :')
    %set(handles.CLwrt,'String',jeff)
    val_hold1 = data(5,call_hold);
    set(handles.CLwrt,'String',val_hold1)
    
    val_hold2 = data(12,call_hold);
    set(handles.Abv50wrt,'String',val_hold2)
    
    val_hold3 = data(11,call_hold);
    set(handles.CFMwrt,'String',val_hold3)
else
    set(handles.CL,'String','')
    set(handles.abv,'String','')
    set(handles.CFM,'String','')
    set(handles.CLwrt,'String','')
    set(handles.Abv50wrt,'String','')
    set(handles.CFMwrt,'String','') 
end

% title('Spectrogram for call number ',num2str(handles.Call))

axes(handles.LogSpectro)
imagesc([0,(seg_data(handles.Call,2)-seg_data(handles.Call,1))/wave.fs],[0,150],log(wave.spec)) 
xlabel('Time (s)')
ylabel('Frequency (kHz)')
axis xy;
% title('Log Spectrogram for call number ',num2str(handles.Call))


axes(handles.SpecAmp)
q=sum(wave.spec/length(wave.spec),2);
q1 = (max(q)-q)/max(q);
% size(q)
% linspace(1,size(wave.spec,1),size(wave.spec,1))
plot(q1,150/129*linspace(1,size(wave.spec,1),size(wave.spec,1)))
%imagesc([0,(seg_data(handles.Call,2)-seg_data(handles.Call,1))/wave.fs],[0,150],log(wave.spec)) 
xlabel('Amplitude')
%axis ij;
axis xy;
%ylabel('')


% axes(handles.LSpecAmp)
% q1=sum(log(wave.spec)/length(log(wave.spec)),2)
% plot(q1,linspace(1,size(wave.spec,1),size(wave.spec,1)))
% %imagesc([0,(seg_data(handles.Call,2)-seg_data(handles.Call,1))/wave.fs],[0,150],log(wave.spec)) 
% xlabel('Amplitude')
% %axis ij;
% %ylabel('')


%-------------------------------------
%------------------------------------------------------------------------



%------------------------------------------------------------------------
%--- Other Functions
% --- Executes during object creation, after setting all properties.
function LogSpectro_CreateFcn(hObject, eventdata, handles)
% hObject    handle to LogSpectro (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate LogSpectro
%-------------------------------------

% --- Executes during object creation, after setting all properties.
function Spectro_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Spectro (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate Spectro
%-------------------------------------

% --- Executes during object creation, after setting all properties.
function LogSpecTitle_CreateFcn(hObject, eventdata, handles)
% hObject    handle to LogSpecTitle (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
%-------------------------------------

% --- Executes during object creation, after setting all properties.
function SpecTitle_CreateFcn(hObject, eventdata, handles)
% hObject    handle to SpecTitle (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
%-------------------------------------

function FileInfo_Callback(hObject, eventdata, handles)
% hObject    handle to FileInfo (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of FileInfo as text
%        str2double(get(hObject,'String')) returns contents of FileInfo as a double
%-------------------------------------

% --- Executes during object creation, after setting all properties.
function FileInfo_CreateFcn(hObject, eventdata, handles)
% hObject    handle to FileInfo (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
%-------------------------------------
%------------------------------------------------------------------------


% --- Executes on button press in ParaDisp.
function ParaDisp_Callback(hObject, eventdata, handles)
% hObject    handle to ParaDisp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of ParaDisp
%-------------------------------------
refresh(hObject,handles)


% --- Executes on mouse press over axes background.
function LogSpectro_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to LogSpectro (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

disp('here')
