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

% Last Modified by GUIDE v2.5 16-Jun-2020 10:21:25

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @fret_rescaling_reslicing_colormap_ui_OpeningFcn, ...
                   'gui_OutputFcn',  @fret_rescaling_reslicing_colormap_ui_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 fret_rescaling_reslicing_colormap_ui is made visible.
function fret_rescaling_reslicing_colormap_ui_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 fret_rescaling_reslicing_colormap_ui (see VARARGIN)
clc
% Choose default command line output for fret_rescaling_reslicing_colormap_ui
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = fret_rescaling_reslicing_colormap_ui_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
 algo = get(handles.algo,'SelectedObject'); % algo
 algo_str = get(algo,'String'); %algo_str
 varargout{1} = get(algo,'String'); %algo_str
 varargout{2} = str2double(get(handles.Scl,'String')); %scale
 varargout{3} = str2double(get(handles.Thres,'String')); %threshold
 varargout{4} = str2double(get(handles.iter,'String')); %iterations
 varargout{5} = str2double(get(handles.step,'String')); %steps
 varargout{6} = str2double(get(handles.reduc,'String')); %reduction
 varargout{7} = str2double(get(handles.xfreq,'String')); %xfreq
 varargout{8} = str2double(get(handles.yfreq,'String')); %yfreq
 varargout{9} = str2double(get(handles.zfreq,'String')); %zfreq

% The figure can be deleted now
delete(handles.figure1);

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


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% algo = get(handles.algo,'SelectedObject'); % algo
% algo_str = get(algo,'String'); %algo_str
% varargout{1} = str2double(get(handles.Scl,'String')); %scale
% varargout{2} = str2double(get(handles.Thres,'String')); %threshold
% varargout{3} = str2double(get(handles.iter,'String')); %iterations
% varargout{4} = str2double(get(handles.step,'String')); %steps
% varargout{5} = str2double(get(handles.reduc,'String')); %reduction
% varargout{6} = str2double(get(handles.xfreq,'String')); %xfreq
% varargout{7} = str2double(get(handles.yfreq,'String')); %yfreq
% varargout{8} = str2double(get(handles.zfreq,'String')); %zfreq

  close all

% FRET_Rescaling_Reslicing_Colormap_MainFile(algo_str,scale,threshold,iterations,step,reduc,xfreq,yfreq,zfreq)

function Scl_Callback(hObject, eventdata, handles)
% hObject    handle to Scl (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 Scl as text
%        str2double(get(hObject,'String')) returns contents of Scl as a double


% --- Executes during object creation, after setting all properties.
function Scl_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Scl (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 Thres_Callback(hObject, eventdata, handles)
% hObject    handle to Thres (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 Thres as text
%        str2double(get(hObject,'String')) returns contents of Thres as a double


% --- Executes during object creation, after setting all properties.
function Thres_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Thres (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 selected object is changed in algo.
function algo_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in algo 
% eventdata  structure with the following fields (see UIBUTTONGROUP)
%	EventName: string 'SelectionChanged' (read only)
%	OldValue: handle of the previously selected object or empty if none was selected
%	NewValue: handle of the currently selected object
% handles    structure with handles and user data (see GUIDATA)
algo = get(handles.algo,'SelectedObject');
algo_str = get(algo,'String');

switch algo_str
    case 'Gaussian'
        set(handles.iter,'Enable','off')
        set(handles.step,'Enable','off')
        set(handles.reduc,'Enable','off')
    case 'AnisoDiff_2D'
        set(handles.iter,'Enable','on')
        set(handles.step,'Enable','on')
        set(handles.reduc,'Enable','on')
    case 'AnisoDiff_3D'
        set(handles.iter,'Enable','on')
        set(handles.step,'Enable','on')
        set(handles.reduc,'Enable','on')
    case 'fast_AnisoDiff_3D'
        set(handles.iter,'Enable','on')
        set(handles.step,'Enable','on')
        set(handles.reduc,'Enable','on')
end

function iter_Callback(hObject, eventdata, handles)
% hObject    handle to iter (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 iter as text
%        str2double(get(hObject,'String')) returns contents of iter as a double




% --- Executes during object creation, after setting all properties.
function iter_CreateFcn(hObject, eventdata, handles)
% hObject    handle to iter (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 step_Callback(hObject, eventdata, handles)
% hObject    handle to step (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 step as text
%        str2double(get(hObject,'String')) returns contents of step as a double


% --- Executes during object creation, after setting all properties.
function step_CreateFcn(hObject, eventdata, handles)
% hObject    handle to step (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 reduc_Callback(hObject, eventdata, handles)
% hObject    handle to reduc (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 reduc as text
%        str2double(get(hObject,'String')) returns contents of reduc as a double


% --- Executes during object creation, after setting all properties.
function reduc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to reduc (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 xfreq_Callback(hObject, eventdata, handles)
% hObject    handle to xfreq (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 xfreq as text
%        str2double(get(hObject,'String')) returns contents of xfreq as a double


% --- Executes during object creation, after setting all properties.
function xfreq_CreateFcn(hObject, eventdata, handles)
% hObject    handle to xfreq (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 yfreq_Callback(hObject, eventdata, handles)
% hObject    handle to yfreq (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 yfreq as text
%        str2double(get(hObject,'String')) returns contents of yfreq as a double


% --- Executes during object creation, after setting all properties.
function yfreq_CreateFcn(hObject, eventdata, handles)
% hObject    handle to yfreq (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 zfreq_Callback(hObject, eventdata, handles)
% hObject    handle to zfreq (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 zfreq as text
%        str2double(get(hObject,'String')) returns contents of zfreq as a double


% --- Executes during object creation, after setting all properties.
function zfreq_CreateFcn(hObject, eventdata, handles)
% hObject    handle to zfreq (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)

if isequal(get(hObject, 'waitstatus'), 'waiting')
% The GUI is still in UIWAIT, us UIRESUME
uiresume(hObject);
else
% The GUI is no longer waiting, just close it
delete(hObject);
end


% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox1 (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 checkbox1
