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

% Last Modified by GUIDE v2.5 27-Mar-2019 15:27:45

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @VelPosMain_OpeningFcn, ...
                   'gui_OutputFcn',  @VelPosMain_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
end % VelPosMain

% --- Executes just before VelPosMain is made visible.
function VelPosMain_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 VelPosMain (see VARARGIN)

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

%initiation parameters
set(handles.edit_RegionStats,'String','No file loaded');
set(handles.edit_exportmat,'String','No file loaded');
set(handles.edit_R,'String','No file loaded');
set(handles.list_cells, 'String', 'No cells loaded');
set(handles.list_regNames, 'String', 'No cells loaded');
set(handles.list_CorrCoef, 'String', 'No cells loaded');
handles.selectedCell=1;
handles.edit_regnbr=1;
handles.batch=0;
handles.edit_RegValue=0;
handles.check_selectionvalue=0;
handles.check_enablePos=0;
set(handles.edit_latRight, 'String', '999');
handles.edit_latRight=999;
set(handles.edit_latLeft, 'String', '-999');
handles.edit_latLeft=-999;
set(handles.edit_rostral, 'String', '999');
handles.edit_rostral=999;
set(handles.edit_caudal, 'String', '-999');
handles.edit_caudal=-999;
set(handles.edit_dorsal, 'String', '999');
handles.edit_dorsal=999;
set(handles.edit_ventral, 'String', '-999');
handles.edit_ventral=-999;
handles.check_enableReg=0;
handles.edit_incV2=0;
handles.edit_incR2=1;
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes VelPosMain wait for user response (see UIRESUME)
% uiwait(handles.MainGUI);
end %opening fcn

% --- Outputs from this function are returned to the command line.
function varargout = VelPosMain_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;
end % Outputfcn


% --- Executes on button press in push_BatchMode.
function push_BatchMode_Callback(hObject, eventdata, handles)
% hObject    handle to push_BatchMode (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
  
%load data
[FilenameRegionStats, FilepathRegionStats, filesuccess] = uigetfile('*.mat', 'Please select your RegionStats files','MultiSelect', 'on');
if isempty(FilenameRegionStats)  || filesuccess==0
   errordlg('Please select a file');
   return;
end
set(handles.edit_RegionStats, 'String', 'Folder batch');

[FilenameR, FilepathR, filesuccess] = uigetfile('*.mat', 'Please select your R files','MultiSelect', 'on');
if isempty(FilenameR)  || filesuccess==0
   errordlg('Please select a file');
   return;
end
set(handles.edit_R, 'String', 'Folder batch');


[FilenameExportmat, FilepathExportmat, filesuccess] = uigetfile('*.mat', 'Please select your exportmat files','MultiSelect', 'on');
if isempty(FilenameExportmat)  || filesuccess==0
   errordlg('Please select a file');
   return;
end
set(handles.edit_exportmat, 'String', 'Folder batch');

handles.FilepathExportmat=FilepathExportmat;
handles.FilepathR=FilepathR;
handles.FilepathRegionStats=FilepathRegionStats;
handles.FolderBatchMode=1;
guidata(hObject, handles);

%sort data 
sorted_FilenameExportmat=FilenameExportmat';
[sorted_FilenameR]=SortLoadedData2(FilenameR, sorted_FilenameExportmat);
[sorted_FilenameRegionStats]=SortLoadedData2(FilenameRegionStats, sorted_FilenameExportmat);

handles.FilenameR_sorted=sorted_FilenameR;
handles.FilenameRegionStats_sorted=sorted_FilenameRegionStats;
handles.FilenameExportmat_sorted=sorted_FilenameExportmat;
guidata(hObject, handles);
end %push batchmode


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

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


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

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


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

%prepare data 
if handles.FolderBatchMode==1; %full autobatch for folder and all cells !    
    for u=1:size(handles.FilenameR_sorted,1)
        load(fullfile(handles.FilepathR,handles.FilenameR_sorted{u,1}));
        load(fullfile(handles.FilepathRegionStats,handles.FilenameRegionStats_sorted{u,1}));
        load(fullfile(handles.FilepathExportmat,handles.FilenameExportmat_sorted{u,1}));
                
        handles.R=R;
        handles.RegionStats=RegionStats;
        handles.RegressorNames=RegressorNames;
        handles.Exportmat=exportmat;

        handles.FilenameRegionStats=char(handles.FilenameRegionStats_sorted{u,1}); 
        handles.FilenameR=char(handles.FilenameR_sorted{u,1});
        handles.FilenameExportmat=char(handles.FilenameExportmat_sorted{u,1});
        
        handles.selectedCell=1; %just for the following part to update MainGUI
        guidata(hObject, handles);
        %list cellnumbers with ROI selection regressors and regressor names
        set(handles.list_cells, 'String', 1:size(handles.RegionStats,1));
        set(handles.list_regNames, 'String', handles.RegressorNames);
        set(handles.list_CorrCoef, 'String', handles.RegionStats(handles.selectedCell).corrVec);
        handles.tau=handles.RegionStats(handles.selectedCell).tau;
        handles.frametime=handles.RegionStats(handles.selectedCell).frametime; 

        set(handles.edit_RegionStats, 'String', char(handles.FilenameRegionStats_sorted{u,1}));
        set(handles.edit_R, 'String', char(handles.FilenameR_sorted{u,1}));
        set(handles.edit_exportmat, 'String', char(handles.FilenameExportmat_sorted{u,1}));
        guidata(hObject, handles);
        
        out=handles;

        
        Filename=handles.FilenameR(1:12);
        handles.Filename=Filename;
        guidata(hObject, handles);
        handlesToCellList=handles;
        handles.check_selectionvalue=get(handles.check_selection,'Value');
        
        %check if neurons is correlated at least 0.4 to ensure they have
        %some position and or velocity component
        updatedCellList=updateCellList_for3Regressors(handles.RegionStats, handles.check_selectionvalue,...
        handles.edit_regnbr, handles.edit_RegValue, handlesToCellList);
        
        %update GUI with neurons which passes correlation selection
        handles.updatedCellList=updatedCellList;
        set(handles.list_cells,'Value', 1);
        set(handles.list_cells,'String', updatedCellList)
        handles.contents = cellstr(get(handles.list_cells,'String'));
        guidata(hObject, handles);
        clear handlesToCellList
        
        for k=1:size(handles.contents,1)
            %create mesh 
            handles.selectedCell=str2double(cell2mat(handles.contents(k)));
            guidata(hObject, handles);
            Out=handles;
            Go(Out)
        end

    disp('running.....')    
    end %FolderLoaded

msgbox('Batch mode finished','Success')

end %folderbatchmode end

disp('Finished')
end % go end


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

% Hints: contents = cellstr(get(hObject,'String')) returns list_cells contents as cell array
%        contents{get(hObject,'Value')} returns selected item from list_cells
templist=cellstr(get(hObject,'String'));
tempindex=get(hObject,'Value');
handles.selectedCell=str2double(cell2mat(templist(tempindex)));
set(handles.list_CorrCoef, 'String', handles.RegionStats(handles.selectedCell).corrVec);
handles.tau=handles.RegionStats(handles.selectedCell).tau;
handles.frametime=handles.RegionStats(handles.selectedCell).frametime;
handles.contents = cellstr(get(handles.list_cells,'String'));
guidata(hObject, handles);
clear templist tempindex
end %list_cells_callback end

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


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

% Hints: contents = cellstr(get(hObject,'String')) returns list_regNames contents as cell array
%        contents{get(hObject,'Value')} returns selected item from list_regNames
end %list_regNames callback end

% --- Executes during object creation, after setting all properties.
function list_regNames_CreateFcn(hObject, eventdata, handles)
% hObject    handle to list_regNames (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
end %list regNames create end

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

% Hints: contents = cellstr(get(hObject,'String')) returns list_CorrCoef contents as cell array
%        contents{get(hObject,'Value')} returns selected item from list_CorrCoef
end %list corrcoef callback end

% --- Executes during object creation, after setting all properties.
function list_CorrCoef_CreateFcn(hObject, eventdata, handles)
% hObject    handle to list_CorrCoef (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
end %list corrcoef create end


function edit_regnbr_Callback(hObject, eventdata, handles)
% hObject    handle to edit_regnbr (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.edit_regnbr=str2double(get(hObject,'String'));
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of edit_regnbr as text
%        str2double(get(hObject,'String')) returns contents of edit_regnbr as a double
end %rednbr end

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


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

updatedCellList=updateCellList_for3Regressors(handles.RegionStats, handles.check_selectionvalue,...
    handles.edit_regnbr, handles.edit_RegValue, handlesToCellList);

handles.updatedCellList=updatedCellList;
set(handles.list_cells,'Value', 1);
set(handles.list_cells,'String', updatedCellList)
handles.contents = cellstr(get(handles.list_cells,'String'));
guidata(hObject, handles);
clear handlesToCellList
end %update end



% --- Executes on button press in check_selection.
function check_selection_Callback(hObject, eventdata, handles)
% hObject    handle to check_selection (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.check_selectionvalue=get(hObject,'Value');
guidata(hObject, handles);
% Hint: get(hObject,'Value') returns toggle state of check_selection
end %selection end


function saccThres_Callback(hObject, eventdata, handles)
% hObject    handle to saccThres (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 saccThres as text
%        str2double(get(hObject,'String')) returns contents of saccThres as a double
handles.saccThres=str2double(get(hObject,'String'));
guidata(hObject, handles);
end %saccThres

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



function PAS_Callback(hObject, eventdata, handles)
% hObject    handle to PAS (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 PAS as text
%        str2double(get(hObject,'String')) returns contents of PAS as a double
handles.PAS=str2double(get(hObject,'String'));
guidata(hObject, handles);
end %

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

% --- Executes on button press in saccDetect.
function saccDetect_Callback(hObject, eventdata, handles)
% hObject    handle to saccDetect (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 saccDetect
handles.saccDetect=get(hObject,'Value');
guidata(hObject, handles);
end %


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

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


function edit_latRight_Callback(hObject, eventdata, handles)
% hObject    handle to edit_latRight (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.edit_latRight=str2double(get(hObject,'String'));
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of edit_latRight as text
%        str2double(get(hObject,'String')) returns contents of edit_latRight as a double
end %

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


function edit_rostral_Callback(hObject, eventdata, handles)
% hObject    handle to edit_rostral (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.edit_rostral=str2double(get(hObject,'String'));
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of edit_rostral as text
%        str2double(get(hObject,'String')) returns contents of edit_rostral as a double
end %

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


function edit_caudal_Callback(hObject, eventdata, handles)
% hObject    handle to edit_caudal (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.edit_caudal=str2double(get(hObject,'String'));
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of edit_caudal as text
%        str2double(get(hObject,'String')) returns contents of edit_caudal as a double
end %

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


function edit_latLeft_Callback(hObject, eventdata, handles)
% hObject    handle to edit_latLeft (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.edit_latLeft=str2double(get(hObject,'String'));
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of edit_latLeft as text
%        str2double(get(hObject,'String')) returns contents of edit_latLeft as a double
end %

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


function edit_ventral_Callback(hObject, eventdata, handles)
% hObject    handle to edit_ventral (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.edit_ventral=str2double(get(hObject,'String'));
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of edit_ventral as text
%        str2double(get(hObject,'String')) returns contents of edit_ventral as a double
end %

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


function edit_dorsal_Callback(hObject, eventdata, handles)
% hObject    handle to edit_dorsal (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.edit_dorsal=str2double(get(hObject,'String'));
guidata(hObject, handles);
% Hints: get(hObject,'String') returns contents of edit_dorsal as text
%        str2double(get(hObject,'String')) returns contents of edit_dorsal as a double
end %

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

% --- Executes on button press in check_enablePos.
function check_enablePos_Callback(hObject, eventdata, handles)
% hObject    handle to check_enablePos (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.check_enablePos=get(hObject,'Value');
guidata(hObject, handles);
% Hint: get(hObject,'Value') returns toggle state of check_enablePos
end %

% --- Executes on button press in check_enableReg.
function check_enableReg_Callback(hObject, eventdata, handles)
% hObject    handle to check_enableReg (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.check_enableReg=get(hObject,'Value');
guidata(hObject, handles);
% Hint: get(hObject,'Value') returns toggle state of check_enableReg
end %
