Download scripts/VV_Main.m from jalauer/Brown2020: direct link, hf CLI and curl.
- Browser
- Download file 6.31 kB
-
https://huggingface.co/datasets/jalauer/Brown2020/resolve/main/scripts/VV_Main.m
- Command line
-
hf download hf://datasets/jalauer/Brown2020/scripts/VV_Main.m
-
curl -L -o VV_Main.m https://huggingface.co/datasets/jalauer/Brown2020/resolve/main/scripts/VV_Main.m
6.31 kB
| %% Choice Bias AKA Value of Volition Task - 4 stims ---------------- JOYSTICK + EEG | |
| % Adapted from Jeff Cockburn's script by JFC 02/18/2015 | |
| % clear screen | |
| clc; | |
| % clear memory | |
| clear all; | |
| close all; | |
| %%%%%%%%%%%%%%%%%% | |
| % struct holding info need to present and track data | |
| disp_struct = struct(); | |
| % struct to hold experiment parameters | |
| task_struct = struct(); | |
| % will store all subject trials | |
| allTrainTrials = []; | |
| allTestTrials = []; | |
| % start time for the experiment | |
| task_struct.startTime = GetSecs(); | |
| % set the randome seed | |
| RandStream.setGlobalStream(RandStream('mt19937ar','seed',sum(100*clock))); | |
| % track the start time for the experiment | |
| experiemtn_start = GetSecs(); | |
| % get the subject number for data storage | |
| subject_number = input('Enter the subject number :\n','s'); | |
| session = input('Is this the first or second visit? (enter 1 or 2):\n','s'); session=str2num(session); | |
| % Pick 1 or 2 screens (if 1, put 0, if 2, put 1) | |
| SCREENS=2; | |
| % build the file name | |
| file_name = [num2str(subject_number) '_S' num2str(session) '_' datestr(now, 'mm-dd-yyyy_HH-MM-SS')]; | |
| % *********% *********% *********% *********% *********% *********% ********* | |
| % Initialize joystick | |
| addpath(genpath('C:\Users\GA217B\Desktop\PDDys Suite\JoyMEX')); | |
| JoyMEX('init',0); | |
| % ********* Call JoyTest to get these trigger numbers for each device | |
| LEFTKEY=5; | |
| RIGHTKEY=6; | |
| % Initialize EEG triggers | |
| ioObject = io64; | |
| LTP1address = hex2dec('C050'); | |
| status = io64(ioObject); | |
| % *********% *********% *********% *********% *********% *********% ********* | |
| % hide the cursor | |
| HideCursor(); | |
| % skip the screen test for now | |
| Screen('Preference', 'SkipSyncTests', 1); | |
| % disable user responses from being displayed | |
| ListenChar(2); | |
| % ensure similar keyboard capture across platforms | |
| KbName('UnifyKeyNames'); | |
| % initialize | |
| [disp_struct, task_struct] = taskInit(disp_struct, task_struct, SCREENS, session, LEFTKEY, RIGHTKEY); | |
| %%%%%%%%%%%%%%%%%%%%%%%%% | |
| % INSTRUCT | |
| train_Inst1(disp_struct); | |
| train_Inst2(disp_struct); | |
| % | |
| instruct_slide = Screen('MakeTexture', disp_struct.wPtr, imread(['../images/Slide1.jpg'])); | |
| Screen('DrawTexture', disp_struct.wPtr, instruct_slide); | |
| Screen(disp_struct.wPtr, 'Flip');KbWait([],3); %Waits for keyboard(any) press | |
| % | |
| train_Inst3(disp_struct); | |
| % | |
| instruct_slide = Screen('MakeTexture', disp_struct.wPtr, imread(['../images/Slide2.jpg'])); | |
| Screen('DrawTexture', disp_struct.wPtr, instruct_slide); | |
| Screen(disp_struct.wPtr, 'Flip');KbWait([],3); %Waits for keyboard(any) press | |
| instruct_slide = Screen('MakeTexture', disp_struct.wPtr, imread(['../images/Slide3.jpg'])); | |
| Screen('DrawTexture', disp_struct.wPtr, instruct_slide); | |
| Screen(disp_struct.wPtr, 'Flip');KbWait([],3); %Waits for keyboard(any) press | |
| % | |
| train_Inst4(disp_struct); | |
| % | |
| instruct_slide = Screen('MakeTexture', disp_struct.wPtr, imread(['../images/Slide4.jpg'])); | |
| Screen('DrawTexture', disp_struct.wPtr, instruct_slide); | |
| Screen(disp_struct.wPtr, 'Flip');KbWait([],3); %Waits for keyboard(any) press | |
| % | |
| train_Inst5(disp_struct); | |
| runPractice(disp_struct, task_struct, ioObject, LTP1address); | |
| train_Inst_Xtra(disp_struct); | |
| train_Inst_Xtra2(disp_struct); | |
| train_Inst6(disp_struct); | |
| %%%%%%%%%%%%%%%%%%% | |
| % TRAIN | |
| trainDone = false; | |
| trainBlock = 0; | |
| while ~trainDone | |
| trainBlock = trainBlock + 1; | |
| % build the training trials | |
| trainTrials = buildTrainTrials(disp_struct, task_struct); | |
| trainTrials(:, task_struct.cBlock) = trainBlock; | |
| trainTrials(:, task_struct.cTrialType) = task_struct.TRAIN; | |
| % loop through each trial | |
| tI = 1; | |
| while tI <= size(trainTrials,1) | |
| trainTrials(tI,:) = runTrainTrial(disp_struct, task_struct, trainTrials(tI,:), ioObject, LTP1address); | |
| % was this a free-choice trial? | |
| if trainTrials(tI, task_struct.cTrialCond) == task_struct.FC | |
| % find it's no-choice pair, and set the resp/feedback | |
| ncI = find( trainTrials(:, task_struct.cTrialID) == trainTrials(tI, task_struct.cTrialID) & trainTrials(:, task_struct.cTrialCond) == task_struct.NC ); | |
| trainTrials(ncI, task_struct.cRespAct) = trainTrials(tI, task_struct.cRespAct) + task_struct.ncAdjust; | |
| trainTrials(ncI, task_struct.cRespRew) = trainTrials(tI, task_struct.cRespRew); | |
| end | |
| % move trial if FC or match under RT limit - otherwise repeat | |
| if trainTrials(tI, task_struct.cRespAct) ~= disp_struct.RESP_SLOW && (trainTrials(tI, task_struct.cTrialCond) == task_struct.FC || trainTrials(tI, task_struct.cMatch)) | |
| tI = tI + 1; | |
| end | |
| end | |
| % store all training from the current block | |
| allTrainTrials = [allTrainTrials; trainTrials]; | |
| % check to see if we've exceeded the max # of blocks | |
| if trainBlock >= task_struct.maxTrain | |
| trainDone = true; | |
| elseif trainBlock >= task_struct.minTrain | |
| % check performance for each stim pair | |
| perfAB = mean(trainTrials(trainTrials(:, task_struct.cS1) == task_struct.sCodes.Afc, task_struct.cRespAct) == task_struct.sCodes.Afc); | |
| perfCD = mean(trainTrials(trainTrials(:, task_struct.cS1) == task_struct.sCodes.Cfc, task_struct.cRespAct) == task_struct.sCodes.Cfc); | |
| % did they meet performance threshold on all stim pairs | |
| trainDone = perfAB >= task_struct.minPerf(1) && perfCD >= task_struct.minPerf(2); | |
| end | |
| % take a break | |
| if ~trainDone | |
| trainBreak(disp_struct); | |
| end | |
| end % while still training | |
| %%%%%%%%%%%%%%%%%%% | |
| % TEST | |
| test_Inst1(disp_struct); | |
| testTrials = buildTestTrials(disp_struct, task_struct); | |
| tI = 1; | |
| % run through all the test trials | |
| while tI <= size(testTrials,1) | |
| testTrials(tI,:) = runTestTrial(disp_struct, task_struct, testTrials(tI,:), ioObject, LTP1address); | |
| % move to the next trial if valid response | |
| if testTrials(tI, task_struct.cRespAct) ~= disp_struct.RESP_SLOW | |
| tI = tI + 1; | |
| end | |
| end % while not done test trials | |
| % store all test trials | |
| allTestTrials = testTrials; | |
| % final note to the subject | |
| taskDone(disp_struct); | |
| % store task data | |
| task_struct.endTime = GetSecs(); | |
| task_struct.expTime = task_struct.endTime - task_struct.startTime; | |
| task_struct.trainTrials = allTrainTrials; | |
| task_struct.testTrials = allTestTrials; | |
| % save to file | |
| save( fullfile('..', 'Data', file_name), 'task_struct', 'disp_struct'); | |
| % clean up | |
| sca; | |
| ListenChar(); | |
| ShowCursor(); | |