Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hand_rotation3
- global imcell anscell num_of_rounds flag max_time plus_time file_name_prefix flag2 ii
- %% setting definitions
- % the number of photos that are shown
- num_of_rounds=20;
- % the location of the hand images in the computer
- working_dir_data='C:\Users\Alex\Dropbox\base line assessments\eTests\HandRotation\';
- % maximum time of response before the image disapear
- max_time=3;
- % time of delay between images (the time '+' is shown on the screen)
- plus_time=2;
- % location to save the data on an excel file
- file_name_prefix = 'D:\project_haifa\HAND_ROTATION';
- %% the functions
- file_list=dir([working_dir_data,'*.jpg']);
- imcell = cell(2,numel(file_list));
- for jj=1:length(file_list)
- file_name=[working_dir_data (file_list(jj).name)];
- imcell{1,jj} = imread(file_name);
- imcell{2,jj} = file_list.name;
- end
- anscell= cell(num_of_rounds,5);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- fh=figure('NumberTitle','off',...
- 'Name','alex1','color','k',...
- 'Menubar','none',...
- 'Position',[100 100 1400 800],...
- 'KeyPressFcn',@youPress);
- a1=uicontrol('Style','text','BackgroundColor','k','ForegroundColor','w',...
- 'String','HAND ROTATION TASK-',...
- 'FontSize',22,...
- 'FontWeight','bold','HorizontalAlignment','center',...
- 'Units','normalized','Position',[.25 .8 .3 .1]);
- a2=uicontrol('Style','text','BackgroundColor','k','ForegroundColor','w',...
- 'String','enter your ID number in the box and press continue',...
- 'FontWeight','bold','FontSize',14,...
- 'Units','normalized','Position',[.1 .6 .2 .1]);
- a3=uicontrol('Style','pushbutton','BackgroundColor','r',...
- 'String','CONTINUE','FontSize',14,...
- 'FontWeight','bold','Enable','on',...
- 'Units','normalized','Position',[.4 .6 .1 .1],'Callback',@ID_enter_callback);
- a4=uicontrol('Style','edit','BackgroundColor','g',...
- 'String','',...
- 'FontWeight','bold','FontSize',14,...
- 'Units','normalized','Position',[.5 .6 .2 .1]);
- a5=uicontrol('Style','text','BackgroundColor','k','ForegroundColor','w',...
- 'String',{'In the following task, a "+" will be presented at the center of the screen,';'';'and then picture of a hand will appear.';'';'Your task is to decide whether the picture is of right hand or left hand.';'';'If the picture is of a right hand, press the "I" key.';'';'If the picture is of a left hand, press the "E" key.';'';'Try to classify the pictures as quickly and accurately as you can.';'';'Get ready for the task by placing your fingers on the "E" and "I" keys.';'';'When you are ready to begin, press the CONTINUE.'},...
- 'FontWeight','bold','FontSize',14,'Visible','off','HorizontalAlignment','left',...
- 'Units','normalized','Position',[.1 .3 .7 .6]);
- a6=uicontrol('Style','pushbutton','BackgroundColor','r',...
- 'String','CONTINUE','FontSize',14,...
- 'FontWeight','bold','Enable','on','Visible','off',...
- 'Units','normalized','Position',[.5 .1 .1 .1],'Callback',@PROCEED_callback);
- a7=uicontrol('Style','text','BackgroundColor','k','ForegroundColor','w',...
- 'String','+',...
- 'FontWeight','bold','FontSize',24,'Visible','off','HorizontalAlignment','center',...
- 'Units','normalized','Position',[.35 .25 .3 .4]);
- a8=uicontrol('Style','text','BackgroundColor','k','ForegroundColor','w',...
- 'String','You finished the task',...
- 'FontWeight','bold','FontSize',24,'Visible','off','HorizontalAlignment','center',...
- 'Units','normalized','Position',[.4 .3 .3 .4]);
- a9=uicontrol('Style','pushbutton','BackgroundColor','r',...
- 'String','EXIT','FontSize',14,...
- 'FontWeight','bold','Enable','on','Visible','off',...
- 'Units','normalized','Position',[.5 .2 .1 .1],'Callback',@EXIT_callback);
- uicontrol(a4)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function ID_enter_callback(~,~)
- a= str2double(get(a4,'string'));
- for zz=1:num_of_rounds
- anscell{zz,1}=a;
- end
- set(a4,'Visible','off');
- set(a2,'Visible','off');
- set(a3,'Visible','off');
- set(a5,'Visible','on');
- set(a6,'Visible','on');
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function PROCEED_callback(~,~)
- import java.awt.Robot;
- import java.awt.event.*;
- mouse = Robot;
- set(a1,'Visible','off');
- set(a5,'Visible','off');
- set(a6,'Visible','off');
- set(a7,'Visible','on');
- pause(0.2);
- set(0, 'PointerLocation', [600 600]);
- pause(0.2);
- mouse.mousePress(InputEvent.BUTTON1_MASK);
- mouse.mouseRelease(InputEvent.BUTTON1_MASK);
- flag=0;
- flag2=1;
- ii=1;
- while ii<num_of_rounds
- if flag2
- pause(plus_time);
- b=unidrnd(size(imcell,2));
- anscell{ii,2}=imcell{2,b};
- set(a7,'Visible','off');
- axes('Position',[.35 .3 .3 .3]);
- image(imcell{1,b});
- START_TIMER;
- tic;
- end
- end
- set(a7,'Visible','off');
- set(a8,'Visible','on');
- set(a9,'Visible','on');
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- t = timer('StartDelay',max_time,'TasksToExecute',1,...
- 'StartFcn',@timer_started,'TimerFcn',@timer_run,'StopFcn',@timer_stoped);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function youPress(~,eventdata)
- if eventdata.Key== 'i' && ~flag2
- flag=1;
- c = toc;
- anscell{ii,2}=c;
- anscell{ii,3}='i';
- set(a7,'Visible','on');
- stop(t)
- elseif eventdata.Key== 'e' && ~flag2
- flag=1;
- c = toc;
- anscell{ii,2}=c;
- anscell{ii,3}='e';
- set(a7,'Visible','on');
- stop(t)
- end
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function timer_started(~,~)
- flag2=0;
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function timer_run(~,~)
- if ~flag
- anscell{ii,2}=2;
- anscell{ii,3}=' ';
- end
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function timer_stoped(~,~)
- if ~flag
- anscell{ii,2}=2;
- anscell{ii,3}=' ';
- set(a7,'Visible','on');
- end
- ii=ii+1;
- flag2=1;
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function EXIT_callback(~,~)
- file_name = strcat(file_name_prefix, '.xls');
- name={'Patient ID', 'pic name ', 'toc ','key press','result'};
- xlswrite( file_name,name,num2str(anscell{1,1}),'a1');
- % for i=1:5
- % for j=1:num_of_rounds
- xlswrite( file_name,anscell,num2str(anscell{1,1}),'a2');
- % end
- % end
- close(fh);
- delete(fh);
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- function START_TIMER
- start(t);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement