Code covered by the BSD License  

Highlights from
MIDAS 2010

image thumbnail

MIDAS 2010

by

 

Mid-Infrared Data Analysis Software 2010 A Matlab Package for 2D IR Spectroscopy Analysis

Figure1GUI_2010(varargin)
function varargout = Figure1GUI_2010(varargin)
% FIGURE1GUI_2010 M-file for Figure1GUI_2010.fig
%      FIGURE1GUI_2010, by itself, creates a new FIGURE1GUI_2010 or raises the existing
%      singleton*.
%
%      H = FIGURE1GUI_2010 returns the handle to a new FIGURE1GUI_2010 or the handle to
%      the existing singleton*.
%
%      FIGURE1GUI_2010('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in FIGURE1GUI_2010.M with the given input arguments.
%
%      FIGURE1GUI_2010('Property','Value',...) creates a new FIGURE1GUI_2010 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Figure1GUI_2010_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Figure1GUI_2010_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 Figure1GUI_2010

% Last Modified by GUIDE v2.5 12-Oct-2010 20:17:07

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Figure1GUI_2010_OpeningFcn, ...
                   'gui_OutputFcn',  @Figure1GUI_2010_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(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 Figure1GUI_2010 is made visible.
function Figure1GUI_2010_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 Figure1GUI_2010 (see VARARGIN)

% propertyeditor('on');

handles.passfile1 = varargin{1};

xlab = handles.passfile1.info.xlabel;
ylab = handles.passfile1.info.ylabel;
zlab = handles.passfile1.info.zlabel;
xuni = handles.passfile1.info.xunit;
yuni = handles.passfile1.info.yunit;
zuni = handles.passfile1.info.zunit;

startX1 = ['Start ' xlab];
endX1 = ['End ' xlab];
startY1 = ['Start ' ylab];
endY1 = ['End ' ylab];


plotTitle1 = [xlab ' vs ' zlab];
set(handles.labelTextStatic, 'String', plotTitle1);


DELTA = handles.passfile1.info.deltaX;

[mdata,ndata] = size(handles.passfile1.all);
ndata = ndata-1; %We want the size of all the data, not just a section of it
handles.passfile1.timestep = zeros(ndata,1);
for i = 1:ndata
    handles.passfile1.timestep(i,1) = DELTA*(i-1);
end

set(handles.selectYPopupmenu, 'String', num2str(handles.passfile1.variable));
set(handles.startXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
set(handles.endXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));


set(handles.scalePopupmenu, 'Value', handles.passfile1.info.scaleType);
set(handles.minSignalEdit, 'String', num2str(handles.passfile1.info.minSignal));
if handles.passfile1.info.staticComp == 1 %Remove
    set(handles.staticRadiobutton, 'Value', 1);
    set(handles.staticPopupmenu, 'Enable', 'on');
    if handles.passfile1.info.component == 2 %Steady state
        set(handles.staticPopupmenu, 'Value', 2);
    end
else
    set(handles.staticRadiobutton, 'Value', 0);
    set(handles.staticPopupmenu, 'Enable', 'off');
end

if handles.passfile1.info.preFilter == 1 %Apply pre filter
    set(handles.applyPreFilterCheckbox, 'Value', 1);
    set(handles.designPreFilterPushbutton, 'Enable', 'on');
else
    set(handles.applyPreFilterCheckbox, 'Value', 0);
    set(handles.designPreFilterPushbutton, 'Enable', 'off');
end

if handles.passfile1.info.average == 1 %Take the average
    set(handles.averageRadiobutton, 'Value', 1);
    set(handles.averagePopupmenu, 'Enable', 'on');
    set(handles.averageEdit, 'Enable', 'on');
    if handles.passfile1.info.averageType == 2 %Dynamic average
        set(handles.averagePopupmenu, 'Value', 2);
        set(handles.averageEdit, 'String', num2str(handles.passfile1.info.deltaDynAve));
        
        [handles.passfile1.data] = averageDynamic(handles.passfile1.all,handles.passfile1.info.deltaDynAve);
        DELTA = handles.passfile1.info.deltaX*handles.passfile1.info.deltaDynAve;
        [handles.passfile1] = timestep(handles.passfile1, DELTA);
        handles.passfile1.startX = 1;
        handles.passfile1.endX = length(handles.passfile1.timestep)-1;
        set(handles.startXPopupmenu, 'Value', 1);
        set(handles.startXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
        set(handles.endXPopupmenu, 'Value', size(handles.passfile1.timestep(1:end-1,1),1));
        set(handles.endXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
    else
        set(handles.averagePopupmenu, 'Value', 1);
        set(handles.averageEdit, 'String', num2str(handles.passfile1.info.deltaKerAve)); 
        
        [handles.passfile1.data] = averageDynamic(handles.passfile1.all,handles.passfile1.info.deltaDynAve);
        DELTA = handles.passfile1.info.deltaX;
        [handles.passfile1] = timestep(handles.passfile1, DELTA);
        handles.passfile1.startX = 1;
        handles.passfile1.endX = length(handles.passfile1.timestep)-1;
        set(handles.startXPopupmenu, 'Value', 1);
        set(handles.startXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
        set(handles.endXPopupmenu, 'Value', size(handles.passfile1.timestep(1:end-1,1),1));
        set(handles.endXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
    end
else
    set(handles.averageRadiobutton, 'Value', 0);
    set(handles.averagePopupmenu, 'Enable', 'off');
    set(handles.averageEdit, 'Enable', 'off');
end

if handles.passfile1.info.postFilter == 1 %Apply post filter
    set(handles.applyPostFilterCheckbox, 'Value', 1);
    set(handles.designPostFilterPushbutton, 'Enable', 'on');
else
    set(handles.applyPostFilterCheckbox, 'Value', 0);
    set(handles.designPostFilterPushbutton, 'Enable', 'off');
end

% handles.passfile1.export1 = 0;
% handles.passfile1.xTicksNum1 = 6;
% handles.passfile1.yTicksNum1 = 6;
% handles.passfile1.zTicksNum1 = 6;
% handles.passfile1.startX1 = 1;
% handles.passfile1.endX1 = length(handles.passfile1.timestep);
% handles.passfile1.startY1 = 1;
% handles.passfile1.endY1 = length(handles.passfile1.variable);
% handles.passfile1.selectY = 1;
% handles.passfile1.aveNum1 = 1;
handles.stdColourmap = [0,0,1;1,0,0;0,1,0;0,0,0;1,1,0;1,0,1;0,1,1;0.300000000000000,0.300000000000000,0.300000000000000;0.500000000000000,0,0;1,0.620000000000000,0.400000000000000;0.490000000000000,1,0.830000000000000;0.600000000000000,0.100000000000000,0.500000000000000;0,0.500000000000000,0;0,0,0.500000000000000;1,0.500000000000000,0;0,1,0.300000000000000;0.500000000000000,0,1;0,0.250000000000000,0.750000000000000;0.750000000000000,0,0.250000000000000;0.250000000000000,0.750000000000000,0;0.100000000000000,0.600000000000000,0.400000000000000;1,0.625000000000000,0;1,0.875000000000000,0;0,0.750000000000000,1;];
%[0,0,0;1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1;0.500000000000000,0.500000000000000,0.500000000000000;0.500000000000000,0,0;1,0.620000000000000,0.400000000000000;0.490000000000000,1,0.830000000000000;0,0.500000000000000,0;0,0,0.500000000000000];
%[0.125000000000000,0,0;0.250000000000000,0,1;0.375000000000000,0,0;0.500000000000000,0,1;0.625000000000000,0,0;0.750000000000000,0,1;0.875000000000000,0,0;1,0,1;0,0.125000000000000,0;0,0.250000000000000,1;1,0.375000000000000,0;0,0.500000000000000,1;1,0.625000000000000,0;0,0.750000000000000,1;1,0.875000000000000,0;0,1,0;1,0,0.125000000000000;0,1,0.250000000000000;1,0,0.375000000000000;0,1,0.500000000000000;1,0,0.625000000000000;0,1,0.750000000000000;1,0,0.875000000000000;0,1,1];
%[0,0,0.562500000000000;0,0,0.625000000000000;0,0,0.687500000000000;0,0,0.750000000000000;0,0,0.812500000000000;0,0,0.875000000000000;0,0,0.937500000000000;0,0,1;0,0.0625000000000000,1;0,0.125000000000000,1;0,0.187500000000000,1;0,0.250000000000000,1;0,0.312500000000000,1;0,0.375000000000000,1;0,0.437500000000000,1;0,0.500000000000000,1;0,0.562500000000000,1;0,0.625000000000000,1;0,0.687500000000000,1;0,0.750000000000000,1;0,0.812500000000000,1;0,0.875000000000000,1;0,0.937500000000000,1;0,1,1;0.0625000000000000,1,0.937500000000000;0.125000000000000,1,0.875000000000000;0.187500000000000,1,0.812500000000000;0.250000000000000,1,0.750000000000000;0.312500000000000,1,0.687500000000000;0.375000000000000,1,0.625000000000000;0.437500000000000,1,0.562500000000000;0.500000000000000,1,0.500000000000000;0.562500000000000,1,0.437500000000000;0.625000000000000,1,0.375000000000000;0.687500000000000,1,0.312500000000000;0.750000000000000,1,0.250000000000000;0.812500000000000,1,0.187500000000000;0.875000000000000,1,0.125000000000000;0.937500000000000,1,0.0625000000000000;1,1,0;1,0.937500000000000,0;1,0.875000000000000,0;1,0.812500000000000,0;1,0.750000000000000,0;1,0.687500000000000,0;1,0.625000000000000,0;1,0.562500000000000,0;1,0.500000000000000,0;1,0.437500000000000,0;1,0.375000000000000,0;1,0.312500000000000,0;1,0.250000000000000,0;1,0.187500000000000,0;1,0.125000000000000,0;1,0.0625000000000000,0;1,0,0;0.937500000000000,0,0;0.875000000000000,0,0;0.812500000000000,0,0;0.750000000000000,0,0;0.687500000000000,0,0;0.625000000000000,0,0;0.562500000000000,0,0;0.500000000000000,0,0;];


set(handles.tracesListbox, 'String', num2str(handles.passfile1.variable(handles.passfile1.selectY)));
handles.passfile1.tracesInFig1{1,1} = handles.passfile1.variable(handles.passfile1.selectY);

set(handles.startXPopupmenu, 'Value', handles.passfile1.startX);
set(handles.endXPopupmenu, 'Value', handles.passfile1.endX);
set(handles.selectYPopupmenu, 'Value', handles.passfile1.selectY);

handles.Fig1_handle = figure('Name', plotTitle1);
handles = FirstPlot(hObject, eventdata, handles); 

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

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Figure1GUI_2010 wait for user response (see UIRESUME)
% uiwait(handles.Figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Figure1GUI_2010_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
    
handles.output(1) = handles.Fig1_handle;
handles.output(2) = hObject;
varargout{1} = handles.output;
% propertyeditor('off');
% delete(hObject);
% close(handles.Fig1_handle);
propertyeditor('off');




function handles = FirstPlot(hObject, eventdata, handles)
% hObject    handle to plotPushbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
datacursormode off;
zoom off;
pan off;
rotate3d off;
plotedit off;

%-----REMOVE STATIC COMPONENT-----%
if (handles.passfile1.info.staticComp == 1) % Remove!
    if (handles.passfile1.info.component == 1) %Remove the Mean Spectrum
        [handles.passfile1] = removeStatic(handles.passfile1, handles.passfile1.staticMeanSpectrum);
    elseif (handles.passfile1.info.component == 2) % Remove the Steady State
        [handles.passfile1] = removeStatic(handles.passfile1, handles.passfile1.staticSteadyState);
    end
else %Do not remove static component
    handles.passfile1.data = handles.passfile1.all(:, 2:end);
end


%-----APPLY PRE FILTER-----%
if (handles.passfile1.info.preFilter == 1) %Apply pre filter
    [handles.passfile1] = applyFilter(handles.passfile1, handles.passfile1.prefilter);
end


%-----COMPUTE AVERAGE-----%
% Either use the kernel to average, or take the average across the dynamic
% variable, or neither
% if (handles.passfile1.info.average == 1) %Take the average (either kernel or over dynamic variable)
    if (handles.passfile1.info.average == 1) && (handles.passfile1.info.averageType == 1) %Kernel Average
        [handles.passfile1.data] = averageKernel(handles.passfile1.data, handles.passfile1.info.deltaKerAve);
    elseif (handles.passfile1.info.average == 1) && (handles.passfile1.info.averageType == 2) %Dynamic average
        [handles.passfile1.data] = averageDynamic_Final(handles.passfile1.data,  handles.passfile1.info.deltaDynAve);
    end
% end


%-----APPLY POST FILTER-----%
if (handles.passfile1.info.postFilter == 1) %Apply pre filter
    [handles.passfile1] = applyFilter(handles.passfile1, handles.passfile1.postfilter);
end

%-----COMPUTE TIMESTEP and CHOOSE ONLY SELECTED DATA-----%
if (handles.passfile1.info.average == 1 && ((handles.passfile1.info.averageType == 1) || (handles.passfile1.info.deltaDynAve == 1)))%Kernel Average, dimensions do not change
    %-----TIMESTEP-----%
    DELTA = handles.passfile1.info.deltaX;
    [handles.passfile1] = timestep(handles.passfile1, DELTA);
    
    positionEd = get(handles.endXPopupmenu, 'Value');
    check = handles.passfile1.endX;
%     disp(' ')
%     disp(['PopEnd = ', num2str(positionEd), ', passfile.endX = ', num2str(check)])
%     disp(['End of timestep = ', num2str(handles.passfile1.timestep(end-1,1)), ', ', num2str(handles.passfile1.timestep(end,1))])
%     disp(['Numel Edtimstep = ', num2str(numel(handles.passfile1.timestep(1:end-1,1))), ', ', num2str(numel(handles.passfile1.timestep(1:end-1,1)))])
%     disp(['Before data sz = ', num2str(size(handles.passfile1.data))])
    
    %-----SELECT DATA-----%
    handles.passfile1.data = handles.passfile1.data(handles.passfile1.startY:handles.passfile1.endY,handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.timestep = handles.passfile1.timestep(handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.selectVar = handles.passfile1.variable(handles.passfile1.startY:handles.passfile1.endY);
%     disp(['After data sz  = ', num2str(size(handles.passfile1.data))])
      
elseif (handles.passfile1.info.average == 1 && (handles.passfile1.info.averageType == 2)) %Dynamic average, dimensions are smaller along time (colunms)
    %-----TIMESTEP-----%
    DELTA = handles.passfile1.info.deltaX*handles.passfile1.info.deltaDynAve;
    [handles.passfile1] = timestep(handles.passfile1, DELTA);
    
    positionEd = get(handles.endXPopupmenu, 'Value');
    check = handles.passfile1.endX;
%     disp(' ')
%     disp(['PopEnd = ', num2str(positionEd), ', passfile.endX = ', num2str(check)])
%     disp(['End of timestep = ', num2str(handles.passfile1.timestep(end-1,1)), ', ', num2str(handles.passfile1.timestep(end,1))])
%     disp(['Numel Edtimstep = ', num2str(numel(handles.passfile1.timestep(1:end-1,1))), ', ', num2str(numel(handles.passfile1.timestep(1:end-1,1)))])
%     disp(['Before data sz = ', num2str(size(handles.passfile1.data))])
    
    %-----SELECT DATA-----%
    handles.passfile1.data = handles.passfile1.data(handles.passfile1.startY:handles.passfile1.endY,handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.timestep = handles.passfile1.timestep(handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.selectVar = handles.passfile1.variable(handles.passfile1.startY:handles.passfile1.endY);
%     disp(['After data sz  = ', num2str(size(handles.passfile1.data))])
    
else %(handles.passfile1.info.average == 0) %No average taken
    %-----TIMESTEP-----%
    DELTA = handles.passfile1.info.deltaX;
    [handles.passfile1] = timestep(handles.passfile1, DELTA);
    
    positionEd = get(handles.endXPopupmenu, 'Value');
    check = handles.passfile1.endX;
%     disp(' ')
%     disp(['PopEnd = ', num2str(positionEd), ', passfile.endX = ', num2str(check)])
%     disp(['End of timestep = ', num2str(handles.passfile1.timestep(end-1,1)), ', ', num2str(handles.passfile1.timestep(end,1))])
%     disp(['Numel Edtimstep = ', num2str(numel(handles.passfile1.timestep(1:end-1,1))), ', ', num2str(numel(handles.passfile1.timestep(1:end-1,1)))])
%     disp(['Before data sz = ', num2str(size(handles.passfile1.data))])
    
    %-----SELECT DATA-----%
    handles.passfile1.data = handles.passfile1.data(handles.passfile1.startY:handles.passfile1.endY,handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.timestep = handles.passfile1.timestep(handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.selectVar = handles.passfile1.variable(handles.passfile1.startY:handles.passfile1.endY);
%     disp(['After data sz  = ', num2str(size(handles.passfile1.data))])
end



%-----PERFORMING THE FAST FOURIER TRANSFORM AND CORRELATION--------%
[handles.passfile1]= fft2dcorr(handles.passfile1);




% %-----FOR PLOTS A AND B-----%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %-----SETTING UP THE INPUT PARAMETERS FOR PLOTTING------------------------%
% Ynumticks = handles.passfileB.yTicksNumB;
% Xnumticks = handles.passfileB.xTicksNumB;
% Znumticks = handles.passfileB.zTicksNumB;
% 
% 
% %------DEALING WITH COLORMAP----------------------------------------------%
% colormap = getColourMap(handles.passfileA.colourmapA);
% 
% 
% % %------PERFORMING PLOTS---------------------------------------------------%
% % axes(handles.plotAreaB) %Indicates which plot area to use
% if (handles.passfile1.info.plotType == 1) || (handles.passfile1.info.plotType == 2) || (handles.passfile1.info.plotType == 3) %Synchronous, asynchronous, phase plot
%     [handles.passfileA.exportA, handles.exportTitleA] = plot2d_function(handles.passfile1, Ynumticks, Znumticks, handles.passfileA.colourmapA); %colormap);
%     handles.passfile1.info.plotStatus = 1;
% else %Spectra
%     [handles.passfileA.exportA, handles.exportTitleA] = plotspectra_function(handles.passfile1, Xnumticks, Ynumticks, Znumticks, handles.passfileA.colourmapA); %colormap);
%     handles.passfile1.info.plotStatus = 1;
% end
% colorbar('EastOutside');
% handles.vA = caxis; %Colour limits
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%-----FOR PLOTS 1 AND 2-----%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-----SETTING UP THE INPUT PARAMETERS FOR PLOTTING------------------------%


selectY1 = find(handles.passfile1.variable == handles.passfile1.tracesInFig1{1,1});



%------PERFORMING PLOTS---------------------------------------------------%
figure(handles.Fig1_handle);

[handles.passfile1.export, handles.passfile1.exportTitle] = plotspectra_wavselected_compare(handles.passfile1, selectY1);

handles.exportDATA{1,1} = handles.passfile1.export;
handles.exportDATA{1,2} = handles.passfile1.tracesInFig1;

handles.myAxisHandle = get(handles.Fig1_handle, 'CurrentAxes');
handles.myTracesHandle = get(handles.myAxisHandle, 'Children');
handles.myDataTrace = get(handles.myTracesHandle);

handles.passfile1.tracesInFig1{1,2} = handles.myTracesHandle(1);
handles.axes.title = get(handles.myAxisHandle, 'Title');

handles.passfile1.tracesInFig1{1,3} = [0,0,1];
handles.passfile1.tracesInFig1{1,4} = '-';
handles.passfile1.tracesInFig1{1,5} = 1;
handles.passfile1.tracesInFig1{1,6}  = [0 0 1];
handles.passfile1.tracesInFig1{1,7}  = [0 0 1];
handles.passfile1.tracesInFig1{1,8} = 6;
handles.passfile1.tracesInFig1{1,9} = 'none';

set(findobj(gca,'Type','line','Color',[0 0 1]), 'LineWidth',1);


set(handles.myTracesHandle(1), 'DisplayName', num2str(handles.passfile1.variable(selectY1))); %Change the display name to the wavenumber
handles.passfile1.info.plotStatus = 1;
% Update handles structure

guidata(hObject, handles);





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

%MAKE UPDATES FIRST!
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);


if ~isempty(handles.passfile1.tracesInFig1) %Are there any traces
    
handles = rmfield(handles, 'exportDATA');

datacursormode off;
zoom off;
pan off;
rotate3d off;
plotedit off;

if numel(handles.passfile1.tracesInFig1{:,1}) > 0 %Are there any traces to remove or is the list empty?

%-----REMOVE STATIC COMPONENT-----%
if (handles.passfile1.info.staticComp == 1) % Remove!
    if (handles.passfile1.info.component == 1) %Remove the Mean Spectrum
        [handles.passfile1] = removeStatic(handles.passfile1, handles.passfile1.staticMeanSpectrum);
    elseif (handles.passfile1.info.component == 2) % Remove the Steady State
        [handles.passfile1] = removeStatic(handles.passfile1, handles.passfile1.staticSteadyState);
    end
else %Do not remove static component
    handles.passfile1.data = handles.passfile1.all(:, 2:end);
end


%-----APPLY PRE FILTER-----%
if (handles.passfile1.info.preFilter == 1) %Apply pre filter
    [handles.passfile1] = applyFilter(handles.passfile1, handles.passfile1.prefilter);
end


%-----COMPUTE AVERAGE-----%
% Either use the kernel to average, or take the average across the dynamic
% variable, or neither
% if (handles.passfile1.info.average == 1) %Take the average (either kernel or over dynamic variable)
    if (handles.passfile1.info.average == 1) && (handles.passfile1.info.averageType == 1) %Kernel Average
        [handles.passfile1.data] = averageKernel(handles.passfile1.data, handles.passfile1.info.deltaKerAve);
    elseif (handles.passfile1.info.average == 1) && (handles.passfile1.info.averageType == 2) %Dynamic average
        [handles.passfile1.data] = averageDynamic_Final(handles.passfile1.data,  handles.passfile1.info.deltaDynAve);
    end
% end


%-----APPLY POST FILTER-----%
if (handles.passfile1.info.postFilter == 1) %Apply pre filter
    [handles.passfile1] = applyFilter(handles.passfile1, handles.passfile1.postfilter);
end

%-----COMPUTE TIMESTEP and CHOOSE ONLY SELECTED DATA-----%
if (handles.passfile1.info.average == 1 && ((handles.passfile1.info.averageType == 1) || (handles.passfile1.info.deltaDynAve == 1)))%Kernel Average, dimensions do not change
    %-----TIMESTEP-----%
    DELTA = handles.passfile1.info.deltaX;
    [handles.passfile1] = timestep(handles.passfile1, DELTA);
    
    positionEd = get(handles.endXPopupmenu, 'Value');
    check = handles.passfile1.endX;
%     disp(' ')
%     disp(['PopEnd = ', num2str(positionEd), ', passfile.endX = ', num2str(check)])
%     disp(['End of timestep = ', num2str(handles.passfile1.timestep(end-1,1)), ', ', num2str(handles.passfile1.timestep(end,1))])
%     disp(['Numel Edtimstep = ', num2str(numel(handles.passfile1.timestep(1:end-1,1))), ', ', num2str(numel(handles.passfile1.timestep(1:end-1,1)))])
%     disp(['Before data sz = ', num2str(size(handles.passfile1.data))])
    
    %-----SELECT DATA-----%
    handles.passfile1.data = handles.passfile1.data(handles.passfile1.startY:handles.passfile1.endY,handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.timestep = handles.passfile1.timestep(handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.selectVar = handles.passfile1.variable(handles.passfile1.startY:handles.passfile1.endY);
%     disp(['After data sz  = ', num2str(size(handles.passfile1.data))])
      
elseif (handles.passfile1.info.average == 1 && (handles.passfile1.info.averageType == 2)) %Dynamic average, dimensions are smaller along time (colunms)
    %-----TIMESTEP-----%
    DELTA = handles.passfile1.info.deltaX*handles.passfile1.info.deltaDynAve;
    [handles.passfile1] = timestep(handles.passfile1, DELTA);
    
    positionEd = get(handles.endXPopupmenu, 'Value');
    check = handles.passfile1.endX;
%     disp(' ')
%     disp(['PopEnd = ', num2str(positionEd), ', passfile.endX = ', num2str(check)])
%     disp(['End of timestep = ', num2str(handles.passfile1.timestep(end-1,1)), ', ', num2str(handles.passfile1.timestep(end,1))])
%     disp(['Numel Edtimstep = ', num2str(numel(handles.passfile1.timestep(1:end-1,1))), ', ', num2str(numel(handles.passfile1.timestep(1:end-1,1)))])
%     disp(['Before data sz = ', num2str(size(handles.passfile1.data))])
    
    %-----SELECT DATA-----%
    handles.passfile1.data = handles.passfile1.data(handles.passfile1.startY:handles.passfile1.endY,handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.timestep = handles.passfile1.timestep(handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.selectVar = handles.passfile1.variable(handles.passfile1.startY:handles.passfile1.endY);
%     disp(['After data sz  = ', num2str(size(handles.passfile1.data))])
    
else %(handles.passfile1.info.average == 0) %No average taken
    %-----TIMESTEP-----%
    DELTA = handles.passfile1.info.deltaX;
    [handles.passfile1] = timestep(handles.passfile1, DELTA);
    
    positionEd = get(handles.endXPopupmenu, 'Value');
    check = handles.passfile1.endX;
%     disp(' ')
%     disp(['PopEnd = ', num2str(positionEd), ', passfile.endX = ', num2str(check)])
%     disp(['End of timestep = ', num2str(handles.passfile1.timestep(end-1,1)), ', ', num2str(handles.passfile1.timestep(end,1))])
%     disp(['Numel Edtimstep = ', num2str(numel(handles.passfile1.timestep(1:end-1,1))), ', ', num2str(numel(handles.passfile1.timestep(1:end-1,1)))])
%     disp(['Before data sz = ', num2str(size(handles.passfile1.data))])
    
    %-----SELECT DATA-----%
    handles.passfile1.data = handles.passfile1.data(handles.passfile1.startY:handles.passfile1.endY,handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.timestep = handles.passfile1.timestep(handles.passfile1.startX:handles.passfile1.endX);
    handles.passfile1.selectVar = handles.passfile1.variable(handles.passfile1.startY:handles.passfile1.endY);
%     disp(['After data sz  = ', num2str(size(handles.passfile1.data))])
end



%-----PERFORMING THE FAST FOURIER TRANSFORM AND CORRELATION--------%
[handles.passfile1]= fft2dcorr(handles.passfile1);




% %-----FOR PLOTS A AND B-----%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %-----SETTING UP THE INPUT PARAMETERS FOR PLOTTING------------------------%
% Ynumticks = handles.passfileB.yTicksNumB;
% Xnumticks = handles.passfileB.xTicksNumB;
% Znumticks = handles.passfileB.zTicksNumB;
% 
% 
% %------DEALING WITH COLORMAP----------------------------------------------%
% colormap = getColourMap(handles.passfileA.colourmapA);
% 
% 
% % %------PERFORMING PLOTS---------------------------------------------------%
% % axes(handles.plotAreaB) %Indicates which plot area to use
% if (handles.passfile1.info.plotType == 1) || (handles.passfile1.info.plotType == 2) || (handles.passfile1.info.plotType == 3) %Synchronous, asynchronous, phase plot
%     [handles.passfileA.exportA, handles.exportTitleA] = plot2d_function(handles.passfile1, Ynumticks, Znumticks, handles.passfileA.colourmapA); %colormap);
%     handles.passfile1.info.plotStatus = 1;
% else %Spectra
%     [handles.passfileA.exportA, handles.exportTitleA] = plotspectra_function(handles.passfile1, Xnumticks, Ynumticks, Znumticks, handles.passfileA.colourmapA); %colormap);
%     handles.passfile1.info.plotStatus = 1;
% end
% colorbar('EastOutside');
% handles.vA = caxis; %Colour limits
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%-----FOR PLOTS 1 AND 2-----%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%------Dealing with Multiple Traces-----%
for p = 1:size(handles.passfile1.tracesInFig1,1)
        arr(p,1) = handles.passfile1.tracesInFig1{p,1};
end

for b = 1:size(handles.passfile1.tracesInFig1,1)
selectY1 = find(handles.passfile1.variable == handles.passfile1.tracesInFig1{b,1});



%------PERFORMING PLOTS---------------------------------------------------%
figure(handles.Fig1_handle);

[handles.passfile1.export, handles.passfile1.exportTitle, currentTracesHandle] = plotspectra_wavselected_compare(handles.passfile1, selectY1);


handles.passfile1.tracesInFig1{handles.passfile1.variable(selectY1) == arr,2} = currentTracesHandle; %Record the trace handles number!!!

handles.exportDATA{b,1} = handles.passfile1.export;
handles.exportDATA{b,2} = handles.passfile1.tracesInFig1{b};

%Make sure the color is unique if it is a new trace
c =                 handles.passfile1.tracesInFig1{ ( handles.passfile1.tracesInFig1{b,1} == arr) ,3};
linestyle =       handles.passfile1.tracesInFig1{ ( handles.passfile1.tracesInFig1{b,1} == arr) ,4};
linewidth =      handles.passfile1.tracesInFig1{ ( handles.passfile1.tracesInFig1{b,1} == arr) ,5};
cmarkeredge = handles.passfile1.tracesInFig1{ ( handles.passfile1.tracesInFig1{b,1} == arr) ,6};
cmarkerface =  handles.passfile1.tracesInFig1{ ( handles.passfile1.tracesInFig1{b,1} == arr) ,7};
markersize =    handles.passfile1.tracesInFig1{ ( handles.passfile1.tracesInFig1{b,1} == arr) ,8};
markerstyle =   handles.passfile1.tracesInFig1{ ( handles.passfile1.tracesInFig1{b,1} == arr) ,9};

set(currentTracesHandle,'Color', c, 'LineWidth',linewidth, 'LineStyle', linestyle, 'MarkerEdgeColor', cmarkeredge, 'MarkerFaceColor', cmarkerface, 'Marker', markerstyle, 'MarkerSize', markersize);

set(currentTracesHandle, 'DisplayName', num2str(handles.passfile1.variable(selectY1))); %Change the display name to the wavenumber

% set(findobj(gca,'Type','line','Color',[0 0 1]),'Color', c, 'LineWidth',2)
    hold on
end
hold off

handles.passfile1.info.plotStatus = 1;
else
    figure(handles.Fig1_handle);
    cla;
    handles.passfile1.info.plotStatus = 0;
end
end



 for p = 1:size(handles.passfile1.tracesInFig1,1)
        arr(p,1) = handles.passfile1.tracesInFig1{p,1};
    end
wavListboxHandle = round(arr); %These are the traces in the tracesListbox

myFigureHandle = handles.Fig1_handle;
if ishandle(myFigureHandle) == 1

myAxisHandle = get(myFigureHandle, 'CurrentAxes');
myTracesHandle = get(myAxisHandle, 'Children');
% currentTracesHandle = myTracesHandle(1,1);
% myDataTrace = get(myTracesHandle); %Not needed here.

displayNames = round(str2double(get(myTracesHandle, 'DisplayName')));

a = zeros(size(displayNames,1),1);
for k = 1:length(displayNames)
    a(k,1) = handles.passfile1.tracesInFig1{wavListboxHandle == displayNames(k,1),1};
end

%Now do the update
% myFigureHandle = handles.Fig1_handle;
% handles = updateFigure1(myFigureHandle, handles);

tf = ismember(a, arr);


if (any(tf) == 1 && all(tf) == 1)
    set(handles.tracesListbox, 'Value', find(a(1,1) == arr));
    set(handles.tracesListbox, 'String', num2str(arr));
elseif (any(tf) == 0 && all(tf) == 0)
    set(handles.tracesListbox, 'Value', 1);
    set(handles.tracesListbox, 'String', num2str(arr));
elseif (any(tf) == 1 && all(tf) == 0)
    set(handles.tracesListbox, 'Value', size(arr,1));
    set(handles.tracesListbox, 'String', num2str(arr));
end


end

guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end



% --- Executes on button press in savePushbutton.
function savePushbutton_Callback(hObject, eventdata, handles)
% hObject    handle to savePushbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

%Stores savepath for the phase plot
[filename, pathname] = uiputfile({ '*.pdf','Portable Document Format (*.pdf)';...
        '*.bmp','Bitmap (*.bmp)'; ...
        '*.emf','Enhanced Metafile (*.emf)'; ...
        '*.eps','EPS Black and White (*.eps)'; ...
        '*.fig','MATLABA figure (*.fig)'; ... 
        '*.jpg','JPEG Image (*.jpg)'; ...
        '*.png','Portable Network Graphics (*.png)'; ...
        '*.tif','TIFF image, compressed(*.tif)'}, ...
        'Save Picture As','default');

    
    
%if user cancels save command, nothing happens
if isequal(filename,0) || isequal(pathname,0)
    return
end

saveas(handles.Fig1_handle,[pathname filename]);
else
%     disp('test')
    close(gcf) 
end



% --- Executes on selection change in tracesListbox.
function tracesListbox_Callback(hObject, eventdata, handles)
% hObject    handle to tracesListbox (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns tracesListbox contents as cell array
%        contents{get(hObject,'Value')} returns selected item from tracesListbox
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

myTrace = get(hObject,'Value');
handles.passfile1.traceSelected = myTrace;

% Update handles structure
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end


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

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


% --- Executes on button press in addPushbutton.
function addPushbutton_Callback(hObject, eventdata, handles)
% hObject    handle to addPushbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ishandle(handles.Fig1_handle) %Is the figure open?

handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

if size(handles.passfile1.tracesInFig1, 1) > 23
    %Display error message
    errordlg('Midas2010 can plot up to 24 traces at a time.','Error');
else
traceNum = handles.passfile1.variable(handles.passfile1.selectY);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%HERE!!!! Line 483~~ Incoirrect! Check if the trace is already in the list!
if size(handles.passfile1.tracesInFig1,1) ~= 0
    
for p = 1:size(handles.passfile1.tracesInFig1,1)
        arr(p,1) = handles.passfile1.tracesInFig1{p,1};
end

if isempty(find(traceNum == arr)) %Is this trace already in the list?
        
    newRandomColour = findRandomColour(handles.stdColourmap, handles.passfile1.tracesInFig1);
          
    handles.passfile1.tracesInFig1 = vertcat(handles.passfile1.tracesInFig1, {traceNum, NaN, newRandomColour, '-', 1, [0 0 1], [0 0 1], 3, 'none'});
    
    for p = 1:size(handles.passfile1.tracesInFig1,1)
        arr(p,1) = handles.passfile1.tracesInFig1{p,1};
    end
    
    set(handles.tracesListbox, 'String', num2str(arr));%, '%6.4f'));
    set(handles.tracesListbox, 'Value', size(handles.passfile1.tracesInFig1, 1)); %Select the last item on the list (the one just added)
    handles.passfile1.info.plotStatus = 0;
end
else
         
    handles.passfile1.tracesInFig1 = vertcat(handles.passfile1.tracesInFig1, {traceNum, NaN, [0 0 1], '-', 1, [0 0 1], [0 0 1], 3, 'none'});
    
    for p = 1:size(handles.passfile1.tracesInFig1,1)
        arr(p,1) = handles.passfile1.tracesInFig1{p,1};
    end
    
    set(handles.tracesListbox, 'String', num2str(arr));%, '%6.4f'));
    set(handles.tracesListbox, 'Value', size(handles.passfile1.tracesInFig1, 1)); %Select the last item on the list (the one just added)
    handles.passfile1.info.plotStatus = 0;
    
end

guidata(hObject, handles);

end
else
%     disp('test')
    close(gcf) 
end
    

% 
% handles.myAxisHandle = get(handles.Fig1_handle, 'CurrentAxes');
% handles.myTracesHandle = get(handles.myAxisHandle, 'Children');
% handles.myDataTrace = get(handles.myTracesHandle);
% 
% handles.passfile1.tracesInListbox(1,2) = handles.myTracesHandle(1);


% --- Executes on button press in removePushbutton.
function removePushbutton_Callback(hObject, eventdata, handles)
% hObject    handle to removePushbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ishandle(handles.Fig1_handle) %Is the figure open?

handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

if ~isempty(handles.passfile1.tracesInFig1) %Are there any traces to remove or is the list empty?
    
    current = get(handles.tracesListbox, 'Value');
    traceNum = handles.passfile1.tracesInFig1{get(handles.tracesListbox, 'Value'),1};
             for p = 1:size(handles.passfile1.tracesInFig1,1)
                 arr(p,1) = handles.passfile1.tracesInFig1{p,1};
             end
         
    erraseMe = find(arr == traceNum);
    
    clear arr
    
    if erraseMe == 1 %Errase the first one in the list
        handles.passfile1.tracesInFig1 = handles.passfile1.tracesInFig1(2:end, :);
        arr = [];
    elseif erraseMe == size(handles.passfile1.tracesInFig1, 1)
        handles.passfile1.tracesInFig1 = handles.passfile1.tracesInFig1(1:end-1, :);
        for p = 1:size(handles.passfile1.tracesInFig1,1)
            arr(p,1) = handles.passfile1.tracesInFig1{p,1};
        end
    else %Errase one in the middle of the list
        handles.passfile1.tracesInFig1 = vertcat(handles.passfile1.tracesInFig1(1:erraseMe-1, :),handles.passfile1.tracesInFig1(erraseMe+1:end, :));
        for p = 1:size(handles.passfile1.tracesInFig1,1)
            arr(p,1) = handles.passfile1.tracesInFig1{p,1};
        end
%         handles.passfile1.tracesInFig1 = vertcat(handles.passfile1.tracesInFig1, horzcat({},temp{m,:}));
    end
    
    
                 
             
     set(handles.tracesListbox, 'Value', 1);
     set(handles.tracesListbox, 'String', num2str(arr));
    if ~(current == 1)
        set(handles.tracesListbox, 'Value', current-1); %Move selector to the item above the one just deleted
    end
    handles.passfile1.info.plotStatus = 0;
%     set(handles.tracesListbox, 'String', num2str(handles.passfile1.tracesInListbox(:,1)));%, '%6.4f'));
end
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end






% --- Executes on selection change in selectYPopupmenu.
function selectYPopupmenu_Callback(hObject, eventdata, handles)
% hObject    handle to selectYPopupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns selectYPopupmenu contents as cell array
%        contents{get(hObject,'Value')} returns selected item from selectYPopupmenu
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

handles.passfile1.selectY = get(hObject,'Value');
% Update handles structure
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end


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

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


% --- Executes on selection change in startXPopupmenu.
function startXPopupmenu_Callback(hObject, eventdata, handles)
% hObject    handle to startXPopupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns startXPopupmenu contents as cell array
%        contents{get(hObject,'Value')} returns selected item from startXPopupmenu
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

startX1 = get(hObject,'Value');
if handles.passfile1.endX < startX1
    set(hObject, 'Value', handles.passfile1.endX);
    handles.passfile1.startX = handles.passfile1.endX;
    errordlg('Start X must be before End X.','Error');
else
    handles.passfile1.startX = startX1;
end
% Update handles structure
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end


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

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


% --- Executes on selection change in endXPopupmenu.
function endXPopupmenu_Callback(hObject, eventdata, handles)
% hObject    handle to endXPopupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns endXPopupmenu contents as cell array
%        contents{get(hObject,'Value')} returns selected item from endXPopupmenu
if ishandle(handles.Fig1_handle) %Is the figure open?

handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

endX1 = get(hObject,'Value');
if handles.passfile1.startX > endX1
    set(hObject, 'Value', handles.passfile1.startX);
    handles.passfile1.endX = handles.passfile1.startX;
    errordlg('Start X must be before End X.','Error');
else
    handles.passfile1.endX = endX1;
end
% Update handles structure
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end


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

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









% --- Executes on button press in staticRadiobutton.
function staticRadiobutton_Callback(hObject, eventdata, handles)
% hObject    handle to staticRadiobutton (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 staticRadiobutton
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

handles.passfile1.info.staticComp = get(hObject, 'Value');
if handles.passfile1.info.staticComp 
    set(handles.staticPopupmenu, 'Enable', 'on');
else
    set(handles.staticPopupmenu, 'Enable', 'off');
end
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end


% --- Executes on selection change in staticPopupmenu.
function staticPopupmenu_Callback(hObject, eventdata, handles)
% hObject    handle to staticPopupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns staticPopupmenu contents as cell array
%        contents{get(hObject,'Value')} returns selected item from staticPopupmenu
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

handles.passfile1.info.component = get(hObject, 'Value');
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end


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

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


% --- Executes on button press in applyPreFilterCheckbox.
function applyPreFilterCheckbox_Callback(hObject, eventdata, handles)
% hObject    handle to applyPreFilterCheckbox (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 applyPreFilterCheckbox
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

handles.passfile1.info.preFilter = get(hObject, 'Value');
if handles.passfile1.info.preFilter
    set(handles.designPreFilterPushbutton, 'Enable', 'on');
%     if handles.passfile1.prefilter.H == 1
        handles = designPreFilterPushbutton_Callback(hObject, eventdata, handles);
%     end
else
    set(handles.designPreFilterPushbutton, 'Enable', 'off');
    handles.passfile1.prefilter.H = 1;
end
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end



% --- Executes on button press in designPreFilterPushbutton.
function handles = designPreFilterPushbutton_Callback(hObject, eventdata, handles)
% hObject    handle to designPreFilterPushbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

[handles.passfile1.prefilter] = FilterGUI_2010(handles.passfile1.prefilter, handles.passfile1.data);

if handles.passfile1.prefilter.isViewed %User selected a filter
    handles.passfile1.info.preFilter = 1;
else
    handles.passfile1.info.preFilter = 0;
end
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end


% --- Executes on button press in averageRadiobutton.
function averageRadiobutton_Callback(hObject, eventdata, handles)
% hObject    handle to averageRadiobutton (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 averageRadiobutton
if ishandle(handles.Fig1_handle) %Is the figure open?

handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

handles.passfile1.info.average = get(hObject, 'Value');
if handles.passfile1.info.average
    set(handles.averagePopupmenu, 'Enable', 'on');
    set(handles.averageEdit, 'Enable', 'on');
    handles.passfile1.info.deltaKerAve = 1;
    handles.passfile1.info.deltaDynAve = 1;
    
    [handles.passfile1.data] = averageDynamic(handles.passfile1.all,handles.passfile1.info.deltaDynAve);
    DELTA = handles.passfile1.info.deltaX*handles.passfile1.info.deltaDynAve;
    [handles.passfile1] = timestep(handles.passfile1, DELTA);
    handles.passfile1.startX = 1;
    handles.passfile1.endX = length(handles.passfile1.timestep)-1;
    set(handles.startXPopupmenu, 'Value', 1);
    set(handles.startXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
    set(handles.endXPopupmenu, 'Value', size(handles.passfile1.timestep(1:end-1,1),1));
    set(handles.endXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
else
    set(handles.averagePopupmenu, 'Enable', 'off');
    set(handles.averageEdit, 'Enable', 'off');
    set(handles.averageEdit, 'String', 1);
    handles.passfile1.info.deltaKerAve = 1;
    handles.passfile1.info.deltaDynAve = 1;
    
    [handles.passfile1.data] = averageDynamic(handles.passfile1.all,handles.passfile1.info.deltaDynAve);
    DELTA = handles.passfile1.info.deltaX*handles.passfile1.info.deltaDynAve;
    [handles.passfile1] = timestep(handles.passfile1, DELTA);
    handles.passfile1.startX = 1;
    handles.passfile1.endX = length(handles.passfile1.timestep)-1;
    set(handles.startXPopupmenu, 'Value', 1);
    set(handles.startXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
    set(handles.endXPopupmenu, 'Value', size(handles.passfile1.timestep(1:end-1,1),1));
    set(handles.endXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
    
end
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end


function averageEdit_Callback(hObject, eventdata, handles)
% hObject    handle to averageEdit (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 averageEdit as text
%        str2double(get(hObject,'String')) returns contents of averageEdit as a double
if ishandle(handles.Fig1_handle) %Is the figure open?

handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

aveNum1 = str2double(get(hObject,'String'));
if (handles.passfile1.info.averageType == 1) %Request kernel average
    if isnan(aveNum1)
        set(hObject, 'String', 1);
        errordlg('Enter an odd value indicating the kernel size.','Error');
        handles.passfile1.info.deltaKerAve = 1;
        handles.passfile1.info.deltaDynAve = 1;
    elseif (aveNum1 <= 0 || mod(aveNum1,2) == 0);
        set(hObject, 'String', 1);
        errordlg('The kernel size must be odd and greater than zero.','Error');
        handles.passfile1.info.deltaKerAve = 1;
        handles.passfile1.info.deltaDynAve = 1;
    else
        handles.passfile1.info.deltaKerAve = aveNum1;
        handles.passfile1.info.deltaDynAve = 1;
        
        DELTA = handles.passfile1.info.deltaX;
        [handles.passfile1] = timestep(handles.passfile1, DELTA);
        handles.passfile1.startX = 1;
        handles.passfile1.endX = length(handles.passfile1.timestep)-1;
        set(handles.startXPopupmenu, 'Value', 1);
        set(handles.startXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
        set(handles.endXPopupmenu, 'Value', size(handles.passfile1.timestep(1:end-1,1),1));
        set(handles.endXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
        
    end
elseif (handles.passfile1.info.averageType == 2) %Request dynamic average
    if isnan(aveNum1)
        set(hObject, 'String', 1);
        errordlg('Enter a value indicating the number of points you would like to average over the dynamic variable. The average value must be greater than zero.','Error');
        handles.passfile1.info.deltaKerAve = 1;
        handles.passfile1.info.deltaDynAve = 1;
    elseif aveNum1 <= 0;
        set(hObject, 'String', 1);
        errordlg('Enter a value indicating the number of points you would like to average over the dynamic variable. The average value must be greater than zero.','Error');
        handles.passfile1.info.deltaKerAve = 1;
        handles.passfile1.info.deltaDynAve = 1;
    elseif aveNum1 > size(handles.passfile1.data,2)/2
        set(hObject, 'String', 1);
        errordlg('Your average value is too large for your data set. Select a smaller one.','Error');
        handles.passfile1.info.deltaKerAve = 1;
        handles.passfile1.info.deltaDynAve = 1;
    else
        handles.passfile1.info.deltaDynAve = aveNum1;
        handles.passfile1.info.deltaKerAve = 1;
        
        [handles.passfile1.data] = averageDynamic(handles.passfile1.all,  handles.passfile1.info.deltaDynAve);
        DELTA = handles.passfile1.info.deltaX*handles.passfile1.info.deltaDynAve;
        [handles.passfile1] = timestep(handles.passfile1, DELTA);
        handles.passfile1.startX = 1;
        handles.passfile1.endX = length(handles.passfile1.timestep)-1;
        set(handles.startXPopupmenu, 'Value', 1);
        set(handles.startXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
        set(handles.endXPopupmenu, 'Value', size(handles.passfile1.timestep(1:end-1,1),1));
        set(handles.endXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
        
    end
end
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end


% --- Executes during object creation, after setting all properties.
function averageEdit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to averageEdit (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in averagePopupmenu.
function averagePopupmenu_Callback(hObject, eventdata, handles)
% hObject    handle to averagePopupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns averagePopupmenu contents as cell array
%        contents{get(hObject,'Value')} returns selected item from averagePopupmenu
if ishandle(handles.Fig1_handle) %Is the figure open?

handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

handles.passfile1.info.averageType = get(hObject, 'Value');
if (handles.passfile1.info.averageType == 1) %Request kernel average
    set(handles.averageEdit, 'String', 1);
    handles.passfile1.info.deltaKerAve = 1;
    handles.passfile1.info.deltaDynAve = 1;
    
    [handles.passfile1.data] = averageDynamic(handles.passfile1.all,handles.passfile1.info.deltaDynAve);
    DELTA = handles.passfile1.info.deltaX*handles.passfile1.info.deltaDynAve;
    [handles.passfile1] = timestep(handles.passfile1, DELTA);
    handles.passfile1.startX = 1;
    handles.passfile1.endX = length(handles.passfile1.timestep)-1;
    set(handles.startXPopupmenu, 'Value', 1);
    set(handles.startXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
    set(handles.endXPopupmenu, 'Value', size(handles.passfile1.timestep(1:end-1,1),1));
    set(handles.endXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
        
else
    set(handles.averageEdit, 'String', 1);
    handles.passfile1.info.deltaKerAve = 1;
    handles.passfile1.info.deltaDynAve = 1;
    
    [handles.passfile1.data] = averageDynamic(handles.passfile1.all,handles.passfile1.info.deltaDynAve);
    DELTA = handles.passfile1.info.deltaX*handles.passfile1.info.deltaDynAve;
    [handles.passfile1] = timestep(handles.passfile1, DELTA);
    handles.passfile1.startX = 1;
    handles.passfile1.endX = length(handles.passfile1.timestep)-1;
    set(handles.startXPopupmenu, 'Value', 1);
    set(handles.startXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
    set(handles.endXPopupmenu, 'Value', size(handles.passfile1.timestep(1:end-1,1),1));
    set(handles.endXPopupmenu, 'String', num2str(handles.passfile1.timestep(1:end-1,1)));
end
guidata(hObject, handles);

else
%     disp('test')
    close(gcf) 
end


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

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


% --- Executes on button press in applyPostFilterCheckbox.
function applyPostFilterCheckbox_Callback(hObject, eventdata, handles)
% hObject    handle to applyPostFilterCheckbox (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
% applyPostFilterCheckbox
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

handles.passfile1.info.postFilter = get(hObject, 'Value');
if handles.passfile1.info.postFilter
    set(handles.designPostFilterPushbutton, 'Enable', 'on');
%     if handles.passfile1.postfilter.H == 1
        handles = designPostFilterPushbutton_Callback(hObject, eventdata, handles);
%     end
else
    set(handles.designPostFilterPushbutton, 'Enable', 'off');
    handles.passfile1.postfilter.H = 1;
end

% if handles.passfile1.filter.currPanel == 1 %Gaussian
%         set(handles.filterTypeStatic1, 'String', 'Gaussian');
%     elseif handles.passfile1.filter.currPanel == 2 %Butterworth
%         set(handles.filterTypeStatic1, 'String', 'Butterworth');
%     elseif handles.passfile1.filter.currPanel == 3 %Quadrant Gaussian
%         set(handles.filterTypeStatic1, 'String', 'Quadrant Gaussian');
%     elseif handles.passfile1.filter.currPanel == 4 %Diamond Butterworth
%         set(handles.filterTypeStatic1, 'String', 'Diamond Butterworth');
%     else %none, If user pressed Cancel on Make Filter Button
%         set(handles.filterTypeStatic1, 'String', '(norewtne)');
%     end
guidata(hObject, handles);

else
%     disp('test')
    close(gcf) 
end



% --- Executes on button press in designPostFilterPushbutton.
function handles = designPostFilterPushbutton_Callback(hObject, eventdata, handles)
% hObject    handle to designPostFilterPushbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

[handles.passfile1.postfilter] = FilterGUI_2010(handles.passfile1.postfilter, handles.passfile1.data);

if handles.passfile1.postfilter.isViewed %User selected a filter
    handles.passfile1.info.postFilter = 1;
else
    handles.passfile1.info.postFilter = 0;
end
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end








% --- Executes on selection change in scalePopupmenu.
function scalePopupmenu_Callback(hObject, eventdata, handles)
% hObject    handle to scalePopupmenu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns scalePopupmenu contents as cell array
%        contents{get(hObject,'Value')} returns selected item from scalePopupmenu
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

handles.passfile1.info.scaleType = get(hObject, 'Value');
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end



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

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


function minSignalEdit_Callback(hObject, eventdata, handles)
% hObject    handle to minSignalEdit (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 minSignalEdit as text
%        str2double(get(hObject,'String')) returns contents of minSignalEdit as a double
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

minSignal1 = str2double(get(hObject,'String'));
if isnan(minSignal1) %Error if user does not enter a number
    set(hObject, 'String', 0.0001);
    errordlg('Minimum Signal must be a number.','Error');
    handles.passfile1.info.minSignal = 0.0001;
else
    handles.passfile1.info.minSignal = minSignal1;
end
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end

% --- Executes during object creation, after setting all properties.
function minSignalEdit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to minSignalEdit (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function xTicksEdit_Callback(hObject, eventdata, handles)
% hObject    handle to xTicksEdit (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 xTicksEdit as text
%        str2double(get(hObject,'String')) returns contents of xTicksEdit as a double
if ishandle(handles.Fig1_handle) %Is the figure open?
handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles);

xTicksNum1 = floor(str2double(get(hObject,'String')));
set(hObject, 'String', xTicksNum1); %Show the floored value
if (isnan(xTicksNum1) || xTicksNum1 < 3) %Error if user does not enter a number
    set(hObject, 'String', 6);
    errordlg('Number of X axis ticks must be an integer larger than 2.','Error');
    handles.passfile1.xTicksNum = 6;
else
    handles.passfile1.xTicksNum = xTicksNum1;
end
% Update handles structure
guidata(hObject, handles);
else
%     disp('test')
    close(gcf) 
end


% --- Executes during object creation, after setting all properties.
function xTicksEdit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to xTicksEdit (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



% --- Executes when user attempts to close Figure1.
function Figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to Figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: delete(hObject) closes the figure
propertyeditor('off');
% close(handles.Fig1_handle);
delete(hObject); %deletes this GUI but not the figure with the traces on it



% --- Executes on key press with focus on Figure1 and none of its controls.
function Figure1_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to Figure1 (see GCBO)
% eventdata  structure with the following fields (see FIGURE)
%	Key: name of the key that was pressed, in lower case
%	Character: character interpretation of the key(s) that was pressed
%	Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles    structure with handles and user data (see GUIDATA)
% propertyeditor('off');


% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function handles = Figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to Figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%The plan: Get a list of the gca children (the traces) and compare this
%list to those in the tracesListbox. If there are less traces than those
%listed in the tracesListbox, then the user removed a trace manually. We
%have to find this trace and also delete it from the tracesListbox,
%traceColours, ect.
if ishandle(handles.Fig1_handle) %Is the figure open?

if handles.passfile1.info.plotStatus == 1 %Is the user in the process of adding or removing a trace?

    for p = 1:size(handles.passfile1.tracesInFig1,1)
        arr(p,1) = handles.passfile1.tracesInFig1{p,1};
    end
wavListboxHandle = round(arr); %These are the traces in the tracesListbox

myFigureHandle = handles.Fig1_handle;
if ishandle(myFigureHandle) == 1

myAxisHandle = get(myFigureHandle, 'CurrentAxes');
myTracesHandle = get(myAxisHandle, 'Children');
% currentTracesHandle = myTracesHandle(1,1);
% myDataTrace = get(myTracesHandle); %Not needed here.

displayNames = round(str2double(get(myTracesHandle, 'DisplayName')));

a = zeros(size(displayNames,1),1);
for k = 1:length(displayNames)
    a(k,1) = handles.passfile1.tracesInFig1{wavListboxHandle == displayNames(k,1),1};
end

%Now do the update
myFigureHandle = handles.Fig1_handle;
handles = updateFigure1(myFigureHandle, handles);

tf = ismember(a, arr);


if (any(tf) == 1 && all(tf) == 1)
    set(handles.tracesListbox, 'Value', find(a(1,1) == arr));
    set(handles.tracesListbox, 'String', num2str(arr));
elseif (any(tf) == 0 && all(tf) == 0)
    set(handles.tracesListbox, 'Value', 1);
    set(handles.tracesListbox, 'String', num2str(arr));
elseif (any(tf) == 1 && all(tf) == 0)
    set(handles.tracesListbox, 'Value', size(arr,1));
    set(handles.tracesListbox, 'String', num2str(arr));
end

% % tf = ismember(a, handles.passfile1.tracesInListbox(:,1));
% handles.passfile1.traceColours = handles.passfile1.traceColours(tf, :);
% handles.passfile1.traceLineStyles = handles.passfile1.traceLineStyles(tf, :);
% handles.passfile1.traceLineWidths = handles.passfile1.traceLineWidths(tf, :);
% handles.passfile1.markerEdgeColours  = handles.passfile1.markerEdgeColours(tf, :);
% handles.passfile1.markerFaceColours  = handles.passfile1.markerFaceColours(tf, :);
% handles.passfile1.markerSizes = handles.passfile1.markerSizes(tf, :);
% handles.passfile1.markerStyles = handles.passfile1.markerStyles(tf, :);




% else
%     close(gcf) 
%     plotTitle1 = [handles.passfile1.info.xlabel ' vs ' handles.passfile1.info.zlabel];
%     handles.Fig1_handle = figure('Name', plotTitle1);
%     handles = FirstPlot(hObject, eventdata, handles); 
end
handles.passfile1.info.plotStatus = 0;
guidata(hObject, handles);
end

else
%     disp('test')
    close(gcf) 
end



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

% --------------------------------------------------------------------
function ExportXLS_Callback(hObject, eventdata, handles)
% hObject    handle to ExportXLS (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ishandle(handles.Fig1_handle) %Is the figure open?
exportFigure12_XLS(handles.passfile1, handles.exportDATA, handles.passfile1.exportTitle);
else
%     disp('test')
    close(gcf) 
end

% --------------------------------------------------------------------
function ExportTXT_Callback(hObject, eventdata, handles)
% hObject    handle to ExportTXT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ishandle(handles.Fig1_handle) %Is the figure open?
exportFigure12_TXT(handles.passfile1, handles.exportDATA, handles.passfile1.exportTitle);
else
%     disp('test')
    close(gcf) 
end

Contact us