|
|
|
|
|
|
| clear all;
|
| close all;
|
| command = 'echo orp | sudo -S ifconfig en0 down';
|
| system(command);
|
|
|
| fprintf('\n\nShutting down internet to protect timing\n\n');
|
|
|
|
|
| devs = PsychHID('Devices');
|
| DAQindx = DaqDeviceIndex();
|
| err0 = DaqDConfigPort(DAQindx, 0, 0);
|
| GPindx = find(strcmp('Logitech(R) Precision(TM) Gamepad', {devs.product}));
|
|
|
| if isempty(GPindx)
|
| error('No Gamepad attached! Stick one in me so we can play. Then restart Matlab')
|
| end
|
|
|
| if isempty(DAQindx)
|
| error('No DAQ attached! Stick one in me or the EEG will be lonely. Then restart Matlab')
|
| end
|
|
|
|
|
| DaqDOut(DAQindx, 0, 69); WaitSecs(0.2);
|
| DaqDOut(DAQindx, 0, 0);
|
| fprintf('\n\n\n')
|
| TriggerYN = input('Did you see a trigger? And was it a lonely 69\n','s');
|
| if any(strcmp(TriggerYN, {'N' 'n' 'No' 'no'}))
|
| error('Ahhhhhhh!!!! No triggers. Please fix so people know when I am stimulated')
|
| end
|
|
|
|
|
| taskdir = pwd;
|
|
|
|
|
| p = pwd;
|
|
|
| subject_number = input('Enter the subject number :','s');
|
| subject_group = input('Patient, Control or Pilot ("SZ", "NC", anything else) :\n', 's');
|
|
|
| if length(subject_group) == 0
|
| subject_group = 'Pilots';
|
| end
|
| if any(strcmp(subject_group, {'SZ', 'sz', 's', 'S', 'Patient', 'patient', 'pat', 'Pat', 'scz', 'schz', 'SCZ', 'SCHZ', 'Schz', 'Scz'}))
|
| subject_group = 'Patients';
|
| elseif any(strcmp(subject_group, {'NC', 'c', 'C', 'HC', 'nc', 'hc', 'control', 'Control', 'healthy', 'healthy control', 'Healthy Control'}))
|
| subject_group = 'Normal Controls';
|
| else
|
| subject_group = 'Pilots';
|
| end
|
|
|
| run_resting = input('\nDo you need to run the resting state?\n(This is a part of the cost conflict experiment):','s');
|
| contacts = input('\nDoes the participant wear contacts?', 's');
|
|
|
| datadir = [taskdir '/Data/' subject_group '/M' subject_number '/Cost Conflict/'];
|
| mkdir(datadir);
|
|
|
|
|
|
|
|
|
|
|
| PREPRACT_RESPDEADLINE=1;
|
| RESPDEADLINE=0.85;
|
| TSTDEADLINE=3;
|
| FUDGE = 10;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| HideCursor();
|
|
|
| ListenChar(2);
|
|
|
|
|
| A=1; B=2;
|
| C=3; D=4;
|
|
|
| y=1; b=2;
|
|
|
| c=1; i=2;
|
|
|
|
|
|
|
| screens = Screen('Screens');
|
| screen = max(screens);
|
|
|
|
|
| screenRect = [];
|
|
|
| [wPtr,rect] = Screen('OpenWindow',screen, [], screenRect);
|
| black=BlackIndex(wPtr);
|
| Screen('FillRect',wPtr,black);
|
| Screen(wPtr, 'Flip');
|
|
|
|
|
| X_center = rect(3)/2;
|
| Y_center = rect(4)/2;
|
|
|
| image_width = 200;
|
| image_height = 200;
|
|
|
| pixel_buffer = 325;
|
| pixel_buffer_test = 75;
|
| pixel_buffer_up = 100;
|
|
|
| x_Right = X_center - image_width/2;
|
| X_Left = X_center + image_width/2;
|
| Y_Top = Y_center - image_height/2;
|
| left_Ybottom = Y_Top + image_height;
|
| center_rect = [x_Right, Y_Top, X_Left, left_Ybottom];
|
|
|
| x_Right = X_center - image_width - pixel_buffer;
|
| X_Left = x_Right + image_width;
|
| Y_Top = Y_center - image_height/2;
|
| left_Ybottom = Y_Top + image_height;
|
| left_rect = [x_Right, Y_Top, X_Left, left_Ybottom];
|
|
|
| x_Right = X_center + pixel_buffer;
|
| X_Left = x_Right + image_width;
|
| Y_Top = Y_center - image_height/2;
|
| left_Ybottom = Y_Top + image_height;
|
| right_rect = [x_Right, Y_Top, X_Left, left_Ybottom];
|
|
|
| x_Right = X_center - image_width - pixel_buffer_test;
|
| X_Left = x_Right + image_width;
|
| Y_Top = Y_center - image_height/2;
|
| left_Ybottom = Y_Top + image_height;
|
| left_rect_test = [x_Right, Y_Top, X_Left, left_Ybottom];
|
|
|
| x_Right = X_center + pixel_buffer_test;
|
| X_Left = x_Right + image_width;
|
| Y_Top = Y_center - image_height/2;
|
| left_Ybottom = Y_Top + image_height;
|
| right_rect_test = [x_Right, Y_Top, X_Left, left_Ybottom];
|
|
|
|
|
|
|
| left_key = KbName('d');
|
| right_key = KbName('k');
|
|
|
| left_button = 5;
|
| right_button = 6;
|
| up_button = 4;
|
| down_button = 2;
|
|
|
|
|
|
|
| if any(strcmp(run_resting, {'yes' 'y' 'Y' 'Yes' 'YE' 'ye' 'YES' 'Ye'}))
|
| save([datadir 'contacts.mat'], 'contacts')
|
| restopentext = 'Experimenter: Prepare for 2 minutes resting state EEG';
|
| reststarttext = 'Experimenter: Start EEG data saving.\nNew EEG file label = REST######\n\n###### = Participant Code\n\n\nThen press any key to continue.';
|
| restparttext = 'Participant: Please relax while focussing gently on the cross hair for two minutes\n\n\n\nExperimenter: press any key to start.';
|
| restendtext = 'Finished Resting State\nGet ready for Cost Conflict.\n\nHave fun!\n\n\nExperimenter: Press any key to go onto cost conflict';
|
|
|
| Screen('TextSize',wPtr,50);
|
| Screen('TextFont',wPtr,'Times');
|
| Screen('TextStyle',wPtr,0);
|
| Screen('TextColor',wPtr,[255 255 255]);
|
| DrawFormattedText(wPtr,restopentext,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
|
|
| DrawFormattedText(wPtr,reststarttext,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
|
|
| DrawFormattedText(wPtr,restparttext,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
|
|
| DrawFormattedText(wPtr,'+','center','center');
|
| Screen(wPtr, 'Flip');
|
| WaitSecs(2);
|
| for tl = 1:62
|
| DaqDOut(DAQindx, 0, tl); WaitSecs(1);
|
| DaqDOut(DAQindx, 0, 0); WaitSecs(1);
|
| end
|
| WaitSecs(1);
|
|
|
| DrawFormattedText(wPtr, restendtext,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
| end
|
|
|
|
|
| Instructions;
|
| session = round(rand+1);
|
| if session==1
|
| STIMS{1}=[4,8,15,17];
|
| STIMS{2}=[11,5,3,10];
|
| STIMS{3}=[7,12,13,18];
|
| STIMS{4}=[16,21,19,20];
|
| elseif session==2
|
| STIMS{1}=[14,22,23,25];
|
| STIMS{2}=[24,29,27,28];
|
| STIMS{3}=[30,6,9,26];
|
| STIMS{4}=[31,32,33,34];
|
| end
|
|
|
| starttext = 'Experimenter: Start EEG data saving.\nNew EEG file label = CC######_B1\n\n\nThen press any key to begin experiment';
|
| Screen('TextSize',wPtr,50);
|
| Screen('TextFont',wPtr,'Times');
|
| Screen('TextStyle',wPtr,0);
|
| Screen('TextColor',wPtr,[255 255 255]);
|
| DrawFormattedText(wPtr,starttext,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
|
|
| setNum = 0;
|
| sets=randperm(4);
|
| for Block=sets
|
|
|
| setNum = setNum + 1;
|
|
|
|
|
| S1=num2str(STIMS{Block}(1));
|
| S2=num2str(STIMS{Block}(2));
|
| S3=num2str(STIMS{Block}(3));
|
| S4=num2str(STIMS{Block}(4));
|
|
|
| data_block = [];
|
| TRAINING;
|
|
|
| load([datadir 'M' num2str(subject_number),'_B',num2str(Block),'_CC_train.mat']);
|
| points = sum(data_block(:,11));
|
| fprintf(['#########################################\n\n\Points for that block = '...
|
| num2str(points) '\n\n\n'...
|
| '#########################################\n\n\n']);
|
|
|
|
|
| Screen('TextSize',wPtr,50);
|
| Screen('TextFont',wPtr,'Times');
|
| Screen('TextStyle',wPtr,0);
|
| Screen('TextColor',wPtr,[255 255 255]);
|
| beginningText1 = 'Good Job. \n\n\nGet Ready For the test phase. \n\n\n\n\n Experimenter: Press [Space] to continue ';
|
| DrawFormattedText(wPtr,beginningText1,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
| beginningText1 = 'The pictures will be presented in pairs again. \n\n\nPick the picture that was MOST REWARDING during the task \n\n\n\n\n Experimenter: Press space to continue ';
|
| DrawFormattedText(wPtr,beginningText1,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
|
|
|
|
| data_test = [];
|
| TESTING;
|
|
|
| clear global B_textures;
|
| clear S1 S2 S3 S4;
|
|
|
| if any(Block == sets(1:3))
|
| Screen('TextSize',wPtr,50);
|
| Screen('TextFont',wPtr,'Times');
|
| Screen('TextStyle',wPtr,0);
|
| Screen('TextColor',wPtr,[255 255 255]);
|
| beginningText1 = 'Great! Get ready for a new training phase...\n\n\n\n\nExperimenter: Press [Space] to continue';
|
| DrawFormattedText(wPtr,beginningText1,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
| end
|
|
|
| if Block==sets(2)
|
| breaktext = 'Please have a short break while the experimenter \n starts a new EEG file \n\n\n\n New file label = CC######_B2';
|
| DrawFormattedText(wPtr, breaktext,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
| end
|
|
|
| blocknumbertext = num2str(find(Block==sets)+1);
|
| if any(Block == sets(1:3))
|
| startblocktext = ['Experimenter, press any key to start new block\n\n\n Block ' blocknumbertext ' of/4'];
|
| DrawFormattedText(wPtr, startblocktext,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
| end
|
|
|
|
|
| end
|
|
|
|
|
| wait_text = 'Done!\n\nThank you for participating!\n\n\nPlease wait for the experimenter.';
|
| Screen('TextFont',wPtr,'Times New Roman');
|
| Screen('TextStyle',wPtr,0);
|
| Screen('TextColor',wPtr,[255 255 255]);
|
| Screen('TextSize',wPtr,80);
|
| DrawFormattedText(wPtr,wait_text,'center','center');
|
| Screen(wPtr, 'Flip');
|
| KbWait([],3);
|
|
|
|
|
|
|
| sca;
|
| ShowCursor;
|
| fprintf('\nEnd of Task.\n');
|
| close all;
|
|
|
| fprintf('\n\nStarting up internet to sync data\n');
|
| command = 'echo orp | sudo -S ifconfig en0 up';
|
| system(command);
|
| WaitSecs(1);
|
| fprintf('\n\nConnecting to the mothership......\n');
|
| WaitSecs(1);
|
| fprintf('\nConnection probably established......\n');
|
| WaitSecs(2);
|
| fprintf('\nI think I just touched E.T.\n\n\n\n');
|
| WaitSecs(1);
|
| command = 'rsync -avzhe ssh /Users/orp/Documents/MATLAB/REEG2/\!Cost\ Conflict_4/data/ malbrecht@orp-12212-MAPC\:/local/Dropbox/REEG_Data/REEG2_BehaviorBySub/';
|
| system(command);
|
|
|
| fprintf('\n\n\nOoooooohhhhh YEAH!!!! Synchronicity!.......\n');
|
|
|
| ListenChar(0);
|
|
|
|
|
| load([datadir 'M' num2str(subject_number),'_B',num2str(1),'_CC_train.mat']);
|
| points = sum(data_block(:,11));
|
| load([datadir 'M' num2str(subject_number),'_B',num2str(2),'_CC_train.mat']);
|
| points = points + sum(data_block(:,11));
|
| load([datadir 'M' num2str(subject_number),'_B',num2str(3),'_CC_train.mat']);
|
| points = points + sum(data_block(:,11));
|
| load([datadir 'M' num2str(subject_number),'_B',num2str(4),'_CC_train.mat']);
|
| points = points + sum(data_block(:,11));
|
|
|
| winnings = points*5/100;
|
| if winnings < 2
|
| winnings = 2;
|
| elseif winnings > 8
|
| winnings = 8;
|
| end
|
| fprintf(['#########################################\n\n\nTotal Points = '...
|
| num2str(points) '\n\n\nParticipant won $' num2str(winnings) '\n\n\n'...
|
| '#########################################\n\n\n']);
|
|
|
|
|
|
|
|
|
|
|