function varargout = mappgindlg(varargin)
% MAPPGINDLG M-file for mappgindlg.fig
% MAPPGINDLG, by itself, creates a new MAPPGINDLG or raises the existing
% singleton*.
%
% H = MAPPGINDLG returns the handle to a new MAPPGINDLG or the handle to
% the existing singleton*.
%
% MAPPGINDLG('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAPPGINDLG.M with the given input arguments.
%
% MAPPGINDLG('Property','Value',...) creates a new MAPPGINDLG or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before mappgindlg_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to mappgindlg_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help mappgindlg
% Last Modified by GUIDE v2.5 15-Dec-2007 13:41:50
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mappgindlg_OpeningFcn, ...
'gui_OutputFcn', @mappgindlg_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 mappgindlg is made visible.
function mappgindlg_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 mappgindlg (see VARARGIN)
data = varargin{1};
s = size(data);
l = s(2)-1;
handles.output = [1:s(2)];
handles.channels = l;
% Update handles structure
guidata(hObject, handles);
text = [];
for i=1:l
tmp = sprintf('Channel %d',i);
text=[text;tmp];
end
set(handles.popupmenu1,'String',text);
set(handles.popupmenu1,'Value',min([1,l]));
set(handles.popupmenu2,'String',text);
set(handles.popupmenu2,'Value',min([2,l]));
set(handles.popupmenu3,'String',text);
set(handles.popupmenu3,'Value',min([3,l]));
set(handles.popupmenu4,'String',text);
set(handles.popupmenu4,'Value',min([4,l]));
if exist('mapping.config')
mapping=load('mapping.config','-mat');
if(mapping.channels== l)
set(handles.popupmenu1,'Value',mapping.A);
set(handles.popupmenu2,'Value',mapping.B);
set(handles.popupmenu3,'Value',mapping.C);
set(handles.popupmenu4,'Value',mapping.D);
end
end
% UIWAIT makes mappgindlg wait for user response (see UIRESUME)
% uiwait(handles.figure1);
uiwait(hObject);
% --- Outputs from this function are returned to the command line.
function varargout = mappgindlg_OutputFcn(hObject, eventdata, handles)
varargout{1} = [];
if(isfield(handles,'output'))
varargout{1} = handles.output;
close();
end
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (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 popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (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 popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (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 popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (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 popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu3 (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 popupmenu3 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu3
% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu3 (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 popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu4 (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 popupmenu4 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu4
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu4 (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 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)
a = 1+get(handles.popupmenu1,'Value');
b = 1+get(handles.popupmenu2,'Value');
c = 1+get(handles.popupmenu3,'Value');
d = 1+get(handles.popupmenu4,'Value');
%o = handles.output;
%handles.output = [o(:,1),o(:,a),o(:,b),o(:,c),o(:,d)];
%handels.param.mapping = [1,a,b,c,d];
handles.output = [1,a,b,c,d];
% save config
mapping.channels = handles.channels;
mapping.A = get(handles.popupmenu1,'Value');
mapping.B = get(handles.popupmenu2,'Value');
mapping.C = get(handles.popupmenu3,'Value');
mapping.D = get(handles.popupmenu4,'Value');
save('mapping.config','-struct','mapping','-mat');
guidata(hObject, handles);
uiresume(handles.figure1);