123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077 |
- function varargout = Stimgui(varargin)
- % STIMGUI M-file for Stimgui.fig
- % STIMGUI, by itself, creates a new STIMGUI or raises the existing
- % singleton*.
- %
- % H = STIMGUI returns the handle to a new STIMGUI or the handle to
- % the existing singleton*.
- %
- % STIMGUI('CALLBACK',hObject,eventData,handles,...) calls the local
- % function named CALLBACK in STIMGUI.M with the given input arguments.
- %
- % STIMGUI('Property','Value',...) creates a new STIMGUI or raises the
- % existing singleton*. Starting from the left, property value pairs are
- % applied to the GUI before Stimgui_OpeningFunction gets called. An
- % unrecognized property name or invalid value makes property application
- % stop. All inputs are passed to Stimgui_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 Stimgui
- % Last Modified by GUIDE v2.5 28-Mar-2013 13:51:35
- % Begin initialization code - DO NOT EDIT
- gui_Singleton = 1;
- gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @Stimgui_OpeningFcn, ...
- 'gui_OutputFcn', @Stimgui_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 Stimgui is made visible.
- function Stimgui_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 Stimgui (see VARARGIN)
- % Choose default command line output for Stimgui
- %set(hObject, 'Position', [ -100 42 63 10])
- handles.output = hObject;
- warning('off','MATLAB:dispatcher:InexactMatch')
- if -2 == cgflip
- cgloadlib
- Mon = get(0,'MonitorPosition');
- if size(Mon,1) > 1
- cgopen(3,0,0,2)
- else %if there is only one monitor!!!
- cgopen(3,0,0,0)
- end
- end
- handles.Backgroundcolor = [0 0 0];
- %Update handles structure
- guidata(hObject, handles);
-
- % UIWAIT makes Stimgui wait for user response (see UIRESUME)
- % uiwait(handles.figure1);
- % --- Outputs from this function are returned to the command line.
- function varargout = Stimgui_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;
- % --------------------------------------------------------------------
- function I_New_G_Callback(hObject, eventdata, handles)
- % hObject handle to I_New_G (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % [Selection,ok] = listdlg('ListString', {'Bezier', 'Dot', 'Movingbar', 'Figure_ground'}, ...
- % 'SelectionMode', 'single', 'Name', 'Create object');
- %
- % HF = figure('Position', [100 700 200 120], 'MenuBar', 'none', 'NumberTitle', 'off', 'name', 'Create object');
- % h1 = uicontrol(HF, 'style', 'listbox', 'string', {'Bezier', 'Dot', 'Movingbar', 'Figure_ground'}, ...
- % 'Position', [10 10 100 100]);
- %
- % h2 = uicontrol(HF, 'style', 'pushbutton', 'string', 'Ok', 'Position', [120 10 50 20], 'callback', {@CB_done, h1});
-
-
- % --------------------------------------------------------------------
- function I_Save_Callback(hObject, eventdata, handles)
- % hObject handle to I_Save (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global StimObj
-
- if isfield(StimObj, 'Pf')
- save( StimObj.Pf, 'StimObj')
- else
- [file,path] = uiputfile('StimObj.mat','Save StimObj as');
- if file ~= 0
- save([path file], 'StimObj')
- end
- end
- % --------------------------------------------------------------------
- function I_saveas_Callback(hObject, eventdata, handles)
- % hObject handle to I_saveas (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global StimObj
- [file,path] = uiputfile('*.mat','Save StimObj as');
- if file == 0
- return
- end
- save([path file], 'StimObj')
- % --------------------------------------------------------------------
- function I_Read_Callback(hObject, eventdata, handles)
- % hObject handle to I_Read (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global StimObj
- [FileName,PathName] = uigetfile('*.mat','Select a StimObj Mat-file');
- Pf = fullfile(PathName,FileName);
- if FileName == 0
- return
- end
- load( Pf)
-
- if isfield(StimObj, 'Obj')
- OBJ = StimObj.Obj;
- len = length(OBJ);
- Str_Obj = cell(len, 1);
- for i = 1:len
- Str_Obj(i) = {[num2str(OBJ(i).Id) '-' OBJ(i).Type]};
- end
- set(handles.StimObjLB, 'String', Str_Obj);
-
- end
-
- set(handles.PM_Event, 'Value', 1);
- if isfield(StimObj, 'Stm')
- Stm = StimObj.Stm;
- len = length(Stm);
- Str_Stms = cell(len, 1);
- for i = 1:len
- Str_Stms(i) = {[num2str(Stm(i).Id) '-' Stm(i).Name]};
- end
- set(handles.PM_Event, 'String', Str_Stms);
- end
- StimObj.Pf = Pf;
- guidata(hObject, handles);
-
- % --- Executes on selection change in StimObjLB.
- function StimObjLB_Callback(hObject, eventdata, handles)
- % hObject handle to StimObjLB (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 StimObjLB contents as cell array
- % contents{get(hObject,'Value')} returns selected item from StimObjLB
- % --- Executes during object creation, after setting all properties.
- function StimObjLB_CreateFcn(hObject, eventdata, handles)
- % hObject handle to StimObjLB (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
- global StimObj
- if isfield(StimObj, 'Obj')
- OBJ = StimObj.Obj;
- len = length(OBJ);
- Str_Obj = cell(len, 1);
- for i = 1:len
- Str_Obj(i) = {[num2str(OBJ(i).Id) '-' OBJ(i).Type]};
- end
- set(hObject, 'String', Str_Obj);
- else
- set(hObject, 'String', {'none'});
- end
- % --- Executes on button press in Btn_Clr.
- function Btn_Clr_Callback(hObject, eventdata, handles)
- % hObject handle to Btn_Clr (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- cgflip(0,0,0)
- cgflip(0,0,0)
- % --------------------------------------------------------------------
- function M_File_Callback(hObject, eventdata, handles)
- % hObject handle to M_File (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %//////////////GRAPHIC OBJECT CREATION/////////////////////////////
- % --------------------------------------------------------------------
- function T_Dot_Callback(hObject, eventdata, handles)
- % hObject handle to T_Dot (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- newObj.Type = 'Dot';
- newObj.Data = cgdot;
- update_objects(newObj, handles);
- % --------------------------------------------------------------------
- function T_Box_Callback(hObject, eventdata, handles)
- % hObject handle to T_Box (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- newObj.Type = 'Box';
- newObj.Data = cgbox;
- update_objects(newObj, handles);
-
- % --------------------------------------------------------------------
- function T_Bezier_Callback(hObject, eventdata, handles)
- % hObject handle to T_Bezier (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- newObj.Type = 'Bezier';
- newObj.Data = cgbezier;
- update_objects(newObj, handles);
- % --------------------------------------------------------------------
- function T_Tex_Callback(hObject, eventdata, handles)
- % hObject handle to T_Tex (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- newObj.Type = 'Texture';
- newObj.Data = cgTexture;
- update_objects(newObj, handles);
- % --------------------------------------------------------------------
- function T_Poly_Callback(hObject, eventdata, handles)
- % hObject handle to T_Poly (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- newObj.Type = 'Polyline';
- newObj.Data = cgPolyline;
- update_objects(newObj, handles);
-
-
- % --------------------------------------------------------------------
- function T_Bitload_Callback(hObject, eventdata, handles)
- % hObject handle to T_Bitload (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- [FileName, PathName] = uigetfile('*.bmp', 'Read bitmaps', 'MultiSelect', 'on');
-
- if ischar(FileName)
- newObj.Type = 'Bitmap';
- Bitmap.Filename = [PathName FileName];
- cgloadbmp(1, Bitmap.Filename )
- spr = cggetdata('SPR', 1);
- Bitmap.cx = 0;
- Bitmap.cy = 0;
- Bitmap.w = spr.Width;
- Bitmap.h = spr.Height;
- Bitmap.Tcol = [];
- Bitmap.isLoaded = false;
- Bitmap.Id = [];
- newObj.Data = Bitmap;
- update_objects(newObj, handles);
-
- elseif iscell(FileName)
- for i = 1:length(FileName)
- newObj.Type = 'Bitmap';
- Bitmap.Filename = [PathName FileName{i}];
- cgloadbmp(1, Bitmap.Filename )
- spr = cggetdata('SPR', 1);
- Bitmap.cx = 0;
- Bitmap.cy = 0;
- Bitmap.w = spr.Width;
- Bitmap.h = spr.Height;
- Bitmap.Tcol = [];
- Bitmap.isLoaded = false;
- Bitmap.Id = [];
- newObj.Data = Bitmap;
- update_objects(newObj, handles);
- end
-
- end
-
- % --------------------------------------------------------------------
- %callback f0r randomsquares pattern
- function T_RP_Callback(hObject, ~, handles)
- % hObject handle to T_RP (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- newObj.Type = 'Randompattern';
- newObj.Data = cgRandompattern;
- update_objects(newObj, handles);
- % -----------------------------------------------------------------------
- function update_objects(Obj, handles)
- global StimObj
- if isfield(StimObj, 'Obj')
- len = length(StimObj.Obj);
- else
- len = 0;
- end
-
- if len == 0
- Obj.Id = 1;
- StimObj.Obj = Obj;
- Str_Obj = {[num2str(Obj.Id) '-' Obj.Type]};
- else
- Str_Obj = get(handles.StimObjLB, 'String');
- Obj.Id = max([ StimObj.Obj(:).Id ]) + 1;
- StimObj.Obj(len+1) = Obj;
- Str_Obj(len+1) = {[num2str(Obj.Id) '-' Obj.Type]};
- end
-
- % guidata(hObject, handles);
-
-
- set(handles.StimObjLB, 'String', Str_Obj);
- % --------------------------------------------------------------------
- function Graphic_Object_Callback(hObject, eventdata, handles)
- % hObject handle to Graphic_Object (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % --------------------------------------------------------------------
- function T_Display_Callback(hObject, eventdata, handles)
- % hObject handle to T_Display (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global StimObj
- OBJ = StimObj.Obj;
-
- item = get(handles.StimObjLB,'Value');
- switch OBJ(item).Type
-
- case 'Bezier'
- cgbezier(OBJ(item).Data, 'D'); %(D)isplay
- case 'Dot'
- cgdot(OBJ(item).Data, 'D');
- case 'Box'
- cgbox(OBJ(item).Data, 'D');
- case 'Polyline'
- cgPolyline(OBJ(item).Data, 'D');
- case 'Bitmap'
- StimObj.Obj(item).Data = cgbitmap(OBJ(item).Data, 'D', OBJ(item).Id);
- %update bitmap because isloaded is true and Id is added
- %since this is a sprite
- case 'Texture'
- Tex = OBJ(item).Data;
- Id = OBJ(item).Id;
- StimObj.Obj(item).Data = cgTexture(Tex, 'D', Id);
- %also becomes a sprite
- case 'Randompattern'
- RP = OBJ(item).Data;
- %Id = OBJ(item).Id;
- cgRandompattern(RP);
- % StimObj.Obj(item).Data = RP;
- %this objects changes on each presentation
- end
-
- % --------------------------------------------------------------------
- function T_Edit_Callback(hObject, eventdata, handles)
- % hObject handle to T_Edit (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global StimObj
- OBJ = StimObj.Obj;
-
- set(handles.stimeditor, 'Visible', 'off');
- item = get(handles.StimObjLB,'Value');
-
- if strcmp(OBJ(item).Type, 'Bezier')
- Bez = OBJ(item).Data;
- StimObj.Obj(item).Data = cgbezier(Bez, 'E');
- elseif strcmp(OBJ(item).Type, 'Dot')
- Dot = OBJ(item).Data;
- StimObj.Obj(item).Data = cgdot(Dot, 'E');
-
- elseif strcmp(OBJ(item).Type, 'Box')
- Box = OBJ(item).Data;
- StimObj.Obj(item).Data = cgbox(Box, 'E');
-
- elseif strcmp(OBJ(item).Type, 'Polyline')
- Poly = OBJ(item).Data;
- StimObj.Obj(item).Data = cgPolyline(Poly, 'E');
-
- elseif strcmp(OBJ(item).Type, 'Texture')
- Tex = OBJ(item).Data;
- StimObj.Obj(item).Data = cgTexture(Tex, 'E');
-
- elseif strcmp(OBJ(item).Type, 'Bitmap')
- Bmp = OBJ(item).Data;
- Id = OBJ(item).Id;
- StimObj.Obj(item).Data = cgbitmap(Bmp, 'E', Id);
- end
-
- set(handles.stimeditor, 'Visible', 'on');
-
- % --------------------------------------------------------------------
- function T_Del_Callback(hObject, eventdata, handles)
- % hObject handle to T_Del_Stim (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global StimObj
- numObj = length(StimObj.Obj);
- item = get(handles.StimObjLB,'Value');
- Str_Obj = get(handles.StimObjLB, 'String');
-
- ID = StimObj.Obj(item).Id;
- Inuse = 0;
- if isfield(StimObj, 'Stm')
- Stms = StimObj.Stm;
- lenStm = length(Stms);
- for i = 1:lenStm
- IdA = [ Stms(i).Event{:} Stms(i).Fix Stms(i).Targ Stms(i).Talt{:} ];
- Inx = find(IdA == ID, 1);
- if ~isempty(Inx) %this Id is used in one of the stimuli
- errordlg(['Cannot delete this object, used by stimulus Id ' num2str(Stms(i).Id) ])
- Inuse = 1;
- break
- end
- end
- end
- if Inuse == 0
- StimObj.Obj(item) = [];
-
- if (numObj - 1) == 0
- Str_Obj = ' ';
- else
- Str_Obj(item) = [];
- end
- set(handles.StimObjLB, 'String', Str_Obj, 'Value', 1);
- end
- % --------------------------------------------------------------------
- function T_Copy_Callback(hObject, eventdata, handles)
- % hObject handle to T_Copy_stim (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global StimObj
- OBJ = StimObj.Obj;
- len = length(OBJ);
- item = get(handles.StimObjLB,'Value');
- Str_Obj = get(handles.StimObjLB, 'String');
- StimObj.Obj(len + 1) = OBJ(item);
- IDs = [OBJ(:).Id ];
- StimObj.Obj(len + 1).Id = max(IDs) + 1;
- newObj = StimObj.Obj(len + 1);
- Str_Obj(len+1) = {[num2str(newObj.Id) '-' newObj.Type]};
- set(handles.StimObjLB, 'String', Str_Obj);
- %///////////////////STIMULUS CREATE AND EDIT//////////////////////////////
-
- % --- Executes on selection change in PM_EVENT.
- function PM_Event_Callback(hObject, eventdata, handles)
- % hObject handle to PM_EVENT (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 PM_EVENT contents as cell array
- % contents{get(hObject,'Value')} returns selected item from PM_EVENT
- %UPDATE STIMULUS PARAMATER PANEL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- global StimObj
- Objs = StimObj.Obj; %graphic object array
- lenObj = length(Objs);
- % Str_Obj = cell(1,2);
- Ctrl_Obj = cell(1,2); %objects used to position control windows, (need a center position: cx, cy)
- IDS = [];
-
- Ind = 1;
- for i = 1:lenObj
- if isfield(Objs(i).Data, 'cx') %does this object have a center point
- Ctrl_Obj(Ind) = {[num2str(Objs(i).Id) '-' Objs(i).Type]};
- IDS(Ind) = Objs(i).Id;
- Ind = Ind + 1;
- end
- % Str_Obj(i) = {[num2str(Objs(i).Id) '-' Objs(i).Type]};
- end
- Ctrl_Obj(Ind) = {'NONE'};
-
- Stmnum = get(hObject,'Value'); %the selected stimulus
- %Str_Stm = get(hObject,'String');
- Stim = StimObj.Stm(Stmnum);
- EVENT = Stim.Event;
- %E_Fixon, E_Stimon, E_Targon, E_Targoff, PU_Fix, PU_Correct, LB_Error
- %E = edit t_box
- %PU = popup t_box
- %LB = listbox
-
-
- set(handles.E_Fixon, 'String', num2str( EVENT{1}) )
- set(handles.E_Stimon, 'String', num2str( EVENT{2}) )
- set(handles.E_Targon, 'String', num2str( EVENT{3}) )
- set(handles.E_Targoff, 'String', num2str( EVENT{4}) )
-
- if ~isempty(Stim.Fix)
- Idx = find(IDS == Stim.Fix, 1);
- set(handles.PU_Fix, 'String', Ctrl_Obj, 'value', Idx)
- else
- set(handles.PU_Fix, 'String', Ctrl_Obj, 'value', Ind)
- end
- if ~isempty(Stim.Targ)
- Idx = find(IDS == Stim.Targ, 1);
- set(handles.PU_Correct, 'String', Ctrl_Obj, 'value', Idx )
- else
- set(handles.PU_Correct, 'String', Ctrl_Obj, 'value', Ind)
- end
-
- Ids = Stim.Talt{:};
- Mx = length(Ctrl_Obj) -1;
- if ~isempty(Ids)
- Idx = [];
- for j = 1:length(Ids)
- Idx = [Idx find(IDS == Ids(j),1) ]; %#ok<AGROW>
- end
-
- set(handles.LB_Error, 'String', Ctrl_Obj, 'value', Idx, 'Max', Mx)
- else
- set(handles.LB_Error, 'String', Ctrl_Obj, 'value', Ind, 'Max', Mx)
- end
- handles.IDS = IDS; %save the Ctrl IDS in the handles stucture for updating
- guidata(hObject, handles);
-
- % --- Executes during object creation, after setting all properties.
- function PM_Event_CreateFcn(hObject, eventdata, handles)
- % hObject handle to PM_EVENT (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.
- %FILL STIMULUS POPUP LIST
- if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
- set(hObject,'BackgroundColor','white');
- end
- global StimObj
- if isfield(StimObj, 'Stm')
-
- Stms = StimObj.Stm;
- len = length(Stms);
- if len > 0
- Str_Stms = cell(len, 1);
- for i = 1:len
- Str_Stms(i) = {[num2str(Stms(i).Id) '-' Stms(i).Name]};
- end
- set(hObject, 'String', Str_Stms);
- else
- set(hObject, 'String', {'none'});
- end
- else
- set(hObject, 'String', {'none'});
- end
- function Pre_T_Callback(hObject, eventdata, handles)
- % hObject handle to Pre_T (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 Pre_T as text
- % str2double(get(hObject,'String')) returns contents of Pre_T as a double
- % --- Executes during object creation, after setting all properties.
- function Pre_T_CreateFcn(hObject, eventdata, handles)
- % hObject handle to Pre_T (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 E_Fixon.
- function E_Fixon_Callback(hObject, eventdata, handles)
- % hObject handle to E_Fixon (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 E_Fixon contents as cell array
- % contents{get(hObject,'Value')} returns selected item from E_Fixon
- global StimObj
-
- Objs = StimObj.Obj;
- Stmnum = get(handles.PM_Event,'Value');
- IdE = str2num(get(hObject,'String'));
- IDs = [ Objs(:).Id ];
- if any(setdiff(IdE, IDs))
- errordlg('Only numbers corresponding to stimulus objects (IDs)')
- else
- StimObj.Stm(Stmnum).Event(1) = { IdE };
- end
- % --- Executes during object creation, after setting all properties.
- function E_Fixon_CreateFcn(hObject, eventdata, handles)
- % hObject handle to E_Fixon (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 E_Stimon_Callback(hObject, eventdata, handles)
- % hObject handle to E_Stimon (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 E_Stimon as text
- % str2double(get(hObject,'String')) returns contents of E_Stimon as a double
- global StimObj
-
- Objs = StimObj.Obj;
- Stmnum = get(handles.PM_Event,'Value');
- IdE = str2num(get(hObject,'String'));
- IDs = [ Objs(:).Id ];
- if any(setdiff(IdE, IDs))
- errordlg('Only numbers corresponding to stimulus objects (IDs)', 'Invalid input!!!')
- else
- StimObj.Stm(Stmnum).Event(2) = { IdE };
- end
- % --- Executes during object creation, after setting all properties.
- function E_Stimon_CreateFcn(hObject, eventdata, handles)
- % hObject handle to E_Stimon (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 E_Targon_Callback(hObject, eventdata, handles)
- % hObject handle to E_Targon (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 E_Targon as text
- % str2double(get(hObject,'String')) returns contents of E_Targon as a double
- global StimObj
-
- Objs = StimObj.Obj;
- Stmnum = get(handles.PM_Event,'Value');
- IdE = str2num(get(hObject,'String'));
- IDs = [ Objs(:).Id ];
- if any(setdiff(IdE, IDs))
- errordlg('Only numbers corresponding to stimulus objects (IDs)')
- else
- StimObj.Stm(Stmnum).Event(3) = { IdE };
- end
- % --- Executes during object creation, after setting all properties.
- function E_Targon_CreateFcn(hObject, eventdata, handles)
- % hObject handle to E_Targon (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 E_Targoff_Callback(hObject, eventdata, handles)
- % hObject handle to e_Targoff (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 e_Targoff as text
- % str2double(get(hObject,'String')) returns contents of e_Targoff as a double
- global StimObj
-
- Objs = StimObj.Obj;
- Stmnum = get(handles.PM_Event,'Value');
- IdE = str2num(get(hObject,'String'));
- IDs = [ Objs(:).Id ];
- if any(setdiff(IdE, IDs))
- errordlg('Only numbers corresponding to stimulus objects (IDs)')
- else
- StimObj.Stm(Stmnum).Event(4) = { IdE };
- end
-
- % --- Executes during object creation, after setting all properties.
- function E_Targoff_CreateFcn(hObject, eventdata, handles)
- % hObject handle to e_Targoff (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 PU_Fix.
- function PU_Fix_Callback(hObject, eventdata, handles)
- % hObject handle to PU_Fix (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 PU_Fix contents as cell array
- % contents{get(hObject,'Value')} returns selected item from PU_Fix
- global StimObj
-
- Stmnum = get(handles.PM_Event,'Value');
-
- num = get(hObject,'Value');
- if ~(num > length(handles.IDS))
- StimObj.Stm(Stmnum).Fix = handles.IDS(num);
- else
- errordlg('You must select a fixation target')
- end
-
-
-
-
- % --- Executes during object creation, after setting all properties.
- function PU_Fix_CreateFcn(hObject, eventdata, handles)
- % hObject handle to PU_Fix (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 PU_Correct.
- function PU_Correct_Callback(hObject, eventdata, handles)
- % hObject handle to PU_Correct (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 PU_Correct contents as cell array
- % contents{get(hObject,'Value')} returns selected item from PU_Correct
- global StimObj
-
- Stmnum = get(handles.PM_Event,'Value');
-
- num = get(hObject,'Value');
- if ~(num > length(handles.IDS))
- StimObj.Stm(Stmnum).Targ = handles.IDS(num);
- else
- errordlg('You must select a correct target')
- end
-
- % --- Executes during object creation, after setting all properties.
- function PU_Correct_CreateFcn(hObject, eventdata, handles)
- % hObject handle to PU_Correct (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 LB_Error.
- function LB_Error_Callback(hObject, eventdata, handles)
- % hObject handle to LB_Error (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 LB_Error contents as cell array
- % contents{get(hObject,'Value')} returns selected item from LB_Error
- global StimObj
-
- Stmnum = get(handles.PM_Event,'Value');
-
- num = get(hObject,'Value');
- if any(num > length(handles.IDS))
- StimObj.Stm(Stmnum).Talt = {[]};
-
- else
- StimObj.Stm(Stmnum).Talt = { handles.IDS(num) };
- end
- % --- Executes during object creation, after setting all properties.
- function LB_Error_CreateFcn(hObject, eventdata, handles)
- % hObject handle to LB_Error (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 Stimulus_Object_Callback(hObject, eventdata, handles)
- % hObject handle to Stimulus_Object (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % --------------------------------------------------------------------
- function T_Display_stim_Callback(hObject, eventdata, handles)
- % hObject handle to T_Display_stim (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- global StimObj
-
- Objs = StimObj.Obj; %graphic object array
- % lenObj = length(Objs);
- Stmnum = get(handles.PM_Event,'Value');
- % Str_Stm = get(handles.PM_Event,'String');
- Stim = StimObj.Stm(Stmnum);
- Str_EVENT = {'Fix', 'Stim', 'Targ', 'Targoff' };
- BGcolor = handles.Backgroundcolor;
- cgflip(BGcolor(1), BGcolor(2), BGcolor(3));
- ObjIds = [ Objs(:).Id ];
- if ~isempty(Stim.Fix)
- FIn = find(ObjIds == Stim.Fix);
- Fix = [Objs(FIn).Data.cx Objs(FIn).Data.cy Objs(FIn).Data.w Objs(FIn).Data.h];
- end
-
- if ~isempty(Stim.Targ)
- TIn = find(ObjIds == Stim.Targ);
- Targ = [Objs(TIn).Data.cx Objs(TIn).Data.cy Objs(TIn).Data.w Objs(TIn).Data.h];
- end
- TA = Stim.Talt{:};
- Talt = [];
- for i = 1:length(TA)
- TIn = find(ObjIds == TA(i));
- Talt = [Talt; Objs(TIn).Data.cx Objs(TIn).Data.cy Objs(TIn).Data.w Objs(TIn).Data.h];
- end
-
- %you should identify bitmaps and textures, and load them in advance
- Ids = unique([ Stim.Event{:}]); %get all object ids in stimulus
- for i = 1:length(Ids)
- Oix = find(ObjIds == Ids(i));
- if strcmp(Objs(Oix).Type, 'Texture')
- Objs(Oix).Data = cgTexture(Objs(Oix).Data, 'L', Ids(i)); %load the texture
- elseif strcmp(Objs(Oix).Type, 'Bitmap')
- Objs(Oix).Data = cgbitmap(Objs(Oix).Data, 'L', Ids(i)); %load the bitmap
- elseif strcmp(Objs(Oix).Type, 'Bezier')
- Objs(Oix).Data = cgbezier(Objs(Oix).Data, 'S', Ids(i)); %load the bezier
- elseif strcmp(Objs(Oix).Type, 'Randompattern')
- Objs(Oix).Data = cgRandompattern(Objs(Oix).Data, 'sprite', Ids(i)); %load the Randompattern
- end
- end
-
- for i = 1:4
- STM = Stim.Event{i};
- if ~isempty(STM)
- cgplotstim(STM, Objs); %cell array -> (Id) array
-
- cgpenwid(1)
- cgpencol(1, 1, 1)
- cgfont('Arial',20)
- cgtext( Str_EVENT{i}, 200, 0)
-
- if ~isempty(Stim.Fix)
- cgellipse(Fix(1), Fix(2), Fix(3), Fix(4), [1 1 1])
- cgtext( 'Fix', Fix(1) + 100, Fix(2))
- end
- if ~isempty(Stim.Targ)
- cgellipse(Targ(1), Targ(2), Targ(3), Targ(4), [1 1 1])
- cgtext( 'C_T', Targ(1), Targ(2) + 50)
- end
- for k = 1:length(TA)
- cgellipse(Talt(k,1), Talt(k,2), Talt(k,3), Talt(k,4), [1 1 1])
- cgtext( 'I_T', Talt(k,1), Talt(k,2) + 50)
- end
-
- cgflip(BGcolor(1), BGcolor(2), BGcolor(3));
- pause( 2)
- end
- end
- % --------------------------------------------------------------------
- function T_Del_Stim_Callback(hObject, eventdata, handles)
- % hObject handle to T_Del_Stim (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %CONTEXT MENU CALLBACK TO DELETE A STIMULUS
- global StimObj
-
- Stmnum = get(handles.PM_Event,'Value');
- Str_Stm = get(handles.PM_Event,'String');
- StimObj.Stm(Stmnum) = [];
-
- Str_Stm(Stmnum) = [];
- set(handles.PM_Event, 'String', Str_Stm, 'Value', 1);
- % --------------------------------------------------------------------
- function T_Copy_stim_Callback(hObject, eventdata, handles)
- % hObject handle to T_Copy_stim (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %CONTEXT MENU CALLBACK TO COPY A STIMULUS
- global StimObj
-
- Stmnum = get(handles.PM_Event,'Value');
- Str_Stm = get(handles.PM_Event,'String');
- Stim = StimObj.Stm(Stmnum);
- IDs = [ StimObj.Stm(:).Id ];
- len = length(IDs);
- Stim.Id = max(IDs) + 1;
- StimObj.Stm(len+1) = Stim;
- Str_Stm(len+1) = {[num2str(Stim.Id) '-' Stim.Name]};
- set(handles.PM_Event, 'String', Str_Stm, 'Value', 1);
-
- % --------------------------------------------------------------------
- function Create_stimulus( hObject, eventdata, hedit, handles )
- global StimObj
- if isfield(StimObj, 'Stm')
- if ~isempty(StimObj.Stm)
- IDs = [ StimObj.Stm(:).Id ];
- len = length(IDs);
- else
- IDs = 0;
- len = 0;
- end
- else
- IDs = 0;
- len = 0;
- end
-
- Str_stim = get( hedit, 'String');
- newStim.Name = Str_stim;
- newStim.Id = max(IDs) + 1;
- newStim.Fix = [];
- newStim.Targ = [];
- newStim.Talt = {[]};
- newStim.Event = cell(5,1);
-
- StimObj.Stm(len+1) = newStim;
- Str_Stm = get(handles.PM_Event, 'String');
- Str_Stm(len+1) = {[num2str(newStim.Id) '-' newStim.Name]};
- set(handles.PM_Event, 'String', Str_Stm, 'Value', 1);
- delete(gcf)
- % --------------------------------------------------------------------
- function T_New_Callback(hObject, eventdata, handles)
- % hObject handle to T_New (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- %CONTEXT MENU CALLBACK TO CREATE A NEW STIMULUS
- POS = get(handles.figure1, 'Position');
- HF = figure('Position', [(POS(1)+40) 700 200 60], 'MenuBar', 'none', 'NumberTitle', 'off', 'name', 'Stim name');
- hedit = uicontrol(HF, 'style', 'edit', 'Position', [10 35 180 20]);
-
- uicontrol(HF, 'style', 'pushbutton', 'string', 'Ok', 'Position', [80 5 50 20], ...
- 'Callback', { @Create_stimulus, hedit, handles } );
- uicontrol(HF, 'style', 'pushbutton', 'string', 'Cancel', 'Position', [130 5 50 20],...
- 'Callback', { @delete, gcf } );
-
-
- % --------------------------------------------------------------------
- function T_BGColor_Callback(hObject, eventdata, handles)
- % hObject handle to T_BGColor (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- BGcolor = handles.Backgroundcolor;
- answ = inputdlg({'R', 'G', 'B'}, 'Enter RGB 0-1' , 1, {num2str(BGcolor(1)), num2str(BGcolor(2)), num2str(BGcolor(3)) } );
-
- if ~isempty(answ)
- handles.Backgroundcolor = [str2double(answ{1}) str2double(answ{2}) str2double(answ{3})];
- guidata(hObject, handles);
- end
-
-
-
|