diff --git a/002 After Image GUI Project/.gitignore b/002 After Image GUI Project/.gitignore index 0ebd99a..6c5e2f5 100644 --- a/002 After Image GUI Project/.gitignore +++ b/002 After Image GUI Project/.gitignore @@ -1 +1,2 @@ /Program\ Compiled/ +*~ diff --git a/002 After Image GUI Project/AfIm_Exp_Rivalry.m b/002 After Image GUI Project/AfIm_Exp_Rivalry.m index b8cc589..78f7f51 100755 --- a/002 After Image GUI Project/AfIm_Exp_Rivalry.m +++ b/002 After Image GUI Project/AfIm_Exp_Rivalry.m @@ -1,4 +1,4 @@ -function AfIm_Exp_Rivalry(subName,meanLum,Bckg_Chro,axis_chck,AdaptTime,nRep,Simu_chck) +function AfIm_Exp_Rivalry(subName,meanLum,Bckg_Chro,axis_chck,AdaptTime,nRep,Simu_chck,shouldCancel) try assignin('base','Stop_Press',0)% this works for the STOP experiment button @@ -209,7 +209,9 @@ try for iChro = 1:size(Bckg_Chro,1) - + if shouldCancel + return; + end wLMS(1,1) = Bckg_Chro(iChro,1)*meanLum; wLMS(1,2) = (1-Bckg_Chro(iChro,1))*meanLum; @@ -224,6 +226,10 @@ try Speak(' Press any key when you are ready'); KbStrokeWait; + if shouldCancel + return; + end + Screen('FillRect', window, wRGB); Screen('Flip',window) @@ -231,9 +237,14 @@ try WaitSecs(AdaptTime) for iRep = 1:nRep - + if shouldCancel + return; + end cont = randperm(nCont); %randomize contrast conditions for iCont = 1:nCont + if shouldCancel + return; + end FlushEvents('mouseDown','keyDown'); %create colors with depending on contrast @@ -351,6 +362,9 @@ try %ListenChar(2) secs0 = Screen('Flip', window); for iFrames = 1:nFrames + if shouldCancel + return; + end Screen('FillArc', window, rampLeft(iFrames,:), tstCircleLeft, 0, 180); Screen('FillArc', window, rampRight(iFrames,:), tstCircleRight, 180, 180); Screen('DrawDots', window, clockPosMat,clockPix, blackLut, [lftXCircleCenter,center(2)], 2); @@ -405,8 +419,13 @@ try if Simu_chck userRes = 'simu'; - + if shouldCancel + return; + end else + if shouldCancel + return; + end keyIsDown=0; kbName=[]; Digit = 0; @@ -415,7 +434,9 @@ try Screen('TextSize', window, 30); commandwindow; while keyIsDown==0 || (strcmp('ENTER',kbName)==0)% & strcmp('2',kbName)==0) - + if shouldCancel + return; + end %keyIsDown=0; [keyIsDown, ~, keyCode] = KbCheck; @@ -484,6 +505,10 @@ try WaitSecs(.2) + if shouldCancel + return; + end + theDate = datestr(now(),'mm/dd/yyyy HH:MM:SS'); fprintf(fp, '%s\t%s\t%1.3f\t%1.3f\t%1.3f\t%1.3f\t%i\t%i\t%i\t%i\t%s\tExperiment\n',... subName, theDate, hfpRG, hfpBG, Bckg_Chro(iChro,1), Bckg_Chro(iChro,2), cont(iCont), curr_axis(iCond), Card_Dir, randStrt+5, userRes); @@ -515,6 +540,9 @@ try return end + if shouldCancel + return; + end end %ICond end %iCont @@ -529,6 +557,7 @@ try % % % % piVSsecs(:,2) = [0:numSecs/(nFrames-1):numSecs]; catch ME warndlg('The program failed to run. Try again.') + sca rethrow(ME); end diff --git a/002 After Image GUI Project/Disp_Color_Rivalry.m~ b/002 After Image GUI Project/Disp_Color_Rivalry.m~ deleted file mode 100644 index 0541cd2..0000000 --- a/002 After Image GUI Project/Disp_Color_Rivalry.m~ +++ /dev/null @@ -1,167 +0,0 @@ -function Disp_Color_Rivalry(l_value,s_value,hfpRG,hfpBG) - -commandwindow; % open this, and the cursor will appear in the command window - - -% %% Choose program -% EEW_StdObsANDSubj = 0; -% EEW_Subj = 1; - -%% - -% Check that Psychtoolbox is properly installed, and switch color range to normalized 0 - 1 range: -PsychDefaultSetup(2); - -%% Start Experiment - -%a = cd; -theDate = fix(clock); -% subName = 'DC'%input(sprintf('\nEnter Subject Initials: ')) - -duration= 5; % sec -% %% Color information, load hfp data and color calibration -% -% aa = cd('/Users/clemente/Dropbox/Luminotecnia/2017/Chicago Lab files/2 Experiments/Color AfterImage_Exp_Room_150/2nd/1 Programs/A Outputs'); -% hfpFile = sprintf('%sHFP', subName); -% load(hfpFile, '-mat') -% hfpRG = rg_avg; -% hfpBG = bg_avg; - -% hfpRG = .89; -% hfpBG = .97 ; - -%% -%cd(a); % return to folder where the program is -Calib_Dire = cd('/Users/mike/Documents/AfterimageOutputs'); -load colorCalFile1.mat -fprintf('\nLast calibrationS was %s\n', describe.date); -pix = pix/1001; -maxLum = 20; %cd/m^2 - -l_s_pair = [l_value s_value]; -blackLut = [0 0 0]; -redLut = [.8 0 0]; - - - - -%% set up psych toolbox -%set up 10 bit color -PsychImaging('PrepareConfiguration'); -%PsychImaging('AddTask', 'General', 'EnableNative10BitFrameBuffer',1); %the 0 is turn off dithering? -expScreen = 1; -%create white LUT -wLMS(1,1) = .665*maxLum;%l_s_pair(1,1)*maxLum; -wLMS(1,2) = (1-.665)*maxLum;%(1-l_s_pair(1,1))*maxLum; -wLMS(1,3) = 1*maxLum;%l_s_pair(1,2)*maxLum; -wXYZ(1,:) = LMS_to_XYZ(wLMS(1,:)); -wRGB(1,:) = XYZ_to_RGB(wXYZ(1,:), maxPhosXYZ); -wRGB(1,1) = pix(dsearchn(redProp(:), wRGB(1,1)))%*hfpRG; -wRGB(1,2) = pix(dsearchn(grnProp(:), wRGB(1,2))); -wRGB(1,3) = pix(dsearchn(blueProp(:), wRGB(1,3)))%*hfpBG; - -[window, windowRect] = PsychImaging('OpenWindow', expScreen, [0 0 0]); %EEW for standard observer - -[xWinSize,~] = Screen('WindowSize',window); - -[xcent,ycent] = RectCenter(windowRect); - center = [xcent ycent]; - -%% Stimulus Size Parameters -circleDeg = 3.6; -clockPt = 0.1; - -% code assumes 1 pixel = 1 arc min -pixPerDeg = 36; %at a distance of 57 cm -circlePix = circleDeg*pixPerDeg -clockPix = clockPt*pixPerDeg; - -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% %%%%%%%%%%%%%%%%%%%%%%%%%%% CIRCLE HALf LOCATIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%% -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%tstcircle = [xcent - circlePix/2 ycent - circlePix/2 xcent + circlePix/2 ycent + circlePix/2]; -rhtXCircleCenter = xWinSize/4; -lftXCircleCenter = xWinSize-xWinSize/4; -tstCircleLeft = [lftXCircleCenter - circlePix/2 ycent - circlePix/2 lftXCircleCenter + circlePix/2 ycent + circlePix/2]; -tstCircleRight = [rhtXCircleCenter - circlePix/2 ycent - circlePix/2 rhtXCircleCenter + circlePix/2 ycent + circlePix/2]; - -%create circular grid for clock face and the numbers -% % % circleDegGrid = 2 ; -% % % rad = circleDegGrid/2*pixPerDeg; %circlePix/2-pixPerDeg/2; -rad = circleDeg/2*pixPerDeg; %circlePix/2-pixPerDeg/2; -radNum = (circleDeg/2) * pixPerDeg; -degreeNumbers = linspace(0,360,25); -clockDegs = degreeNumbers(1:end-1); %[1:15:360]; -clockDegsLft = [90:15:269]; -clockDegsRht = [270:15:359,0:15:89]; -for iC = 1:length(clockDegs) - [xcFace(iC), ycFace(iC)] = pol2cart(clockDegs(iC)*pi/180, rad); - [xcNumber(iC), ycNumber(iC)] = pol2cart(clockDegs(iC)*pi/180, 1*radNum); -end -for iC = 1:length(clockDegsLft) - [xcRhtFace(iC), ycRhtFace(iC)] = pol2cart(clockDegsLft(iC)*pi/180, rad); - [xcRhtNumber(iC), ycRhtNumber(iC)] = pol2cart(clockDegsLft(iC)*pi/180, 1*radNum); -end -for iC = 1:length(clockDegsRht) - [xcLftFace(iC), ycLftFace(iC)] = pol2cart(clockDegsRht(iC)*pi/180, rad); - [xcLftNumber(iC), ycLftNumber(iC)] = pol2cart(clockDegsRht(iC)*pi/180, 1*radNum); -end - -%create matrix of dot locations -clockPosMat = [reshape(xcFace,1, length(clockDegs)); reshape(ycFace,1, length(clockDegs))]; -%clockNumMat = [reshape(xcNumber,1, length(clockDegs)); reshape(ycNumber,1, length(clockDegs))]; -%clockRhtPosMat = [reshape(xcRhtFace,1, length(clockDegsRht)); reshape(ycRhtFace,1, length(clockDegsRht))]; -clockRhtNumMat = [reshape(xcRhtNumber,1, length(clockDegsRht)); reshape(ycRhtNumber,1, length(clockDegsRht))]; -%clockLftPosMat = [reshape(xcLftFace,1, length(clockDegsLft)); reshape(ycLftFace,1, length(clockDegsLft))]; -clockLftNumMat = [reshape(xcLftNumber,1, length(clockDegsLft)); reshape(ycLftNumber,1, length(clockDegsLft))]; - -%% - -Screen('FillRect', window, [0 0 0], windowRect);% dark screen -Screen('Flip', window); -WaitSecs(1) - -Screen('FillRect', window, wRGB.*2); - -Screen('Flip',window) - -% % if EEW_StdObsANDSubj -% Screen('FillOval', window, wRGB, centeredRect, maxDiameter); % Draw the rect to the screen -% Screen('Flip', window); -% WaitSecs(duration) -% -% % end - -% if EEW_Subj -wRGB(1,1) = wRGB(1,1)*hfpRG; -wRGB(1,2) = wRGB(1,2); -wRGB(1,3) = wRGB(1,3)*hfpBG; -% -%Screen('FillOval', window, wRGB, centeredRect, maxDiameter); % Draw the rect to the screen -% Screen('FillOval', window, wRGB, centeredRect1, maxDiameter); % Draw the rect to the screen -% Screen('FillOval', window, wRGB, centeredRect2, maxDiameter); % Draw the rect to the screen -Screen('FillArc', window, wRGB, tstCircleLeft, 0, 180); -Screen('FillArc', window, wRGB.*1.5 , tstCircleRight, 180, 180); -Screen('DrawDots', window, clockPosMat,clockPix, blackLut, [lftXCircleCenter,center(2)], 2); -Screen('DrawDots', window, clockPosMat,clockPix, blackLut, [rhtXCircleCenter,center(2)], 2); -Screen('DrawDots', window, [0 0],clockPix, 0, [lftXCircleCenter,center(2)], 2); % black dot for fixation -Screen('DrawDots', window, [0 0],clockPix, 0, [rhtXCircleCenter,center(2)], 2); % black dot for fixation - -textOne = [12:24,1:11]; -scl = 1.35; -for itxt = 1:12 - textNum = num2str(textOne(itxt)); - Screen('DrawText', window, textNum, scl*clockRhtNumMat(1,itxt)+rhtXCircleCenter-7, scl*clockRhtNumMat(2,itxt)+center(1,2)-14, blackLut, wRGB); - textNum = num2str(textOne(itxt+12)); - Screen('DrawText', window, textNum, .9*scl*clockLftNumMat(1,itxt)+lftXCircleCenter-7, .9*scl*clockLftNumMat(2,itxt)+center(1,2)-14, blackLut, wRGB); -end -Screen('Flip', window); -% WaitSecs(duration) -KbWait(); -% -% end - -% KbStrokeWait; -Screen('CloseAll') - -end \ No newline at end of file diff --git a/002 After Image GUI Project/HFP_session.m b/002 After Image GUI Project/HFP_session.m index 244a66a..d6b183c 100644 --- a/002 After Image GUI Project/HFP_session.m +++ b/002 After Image GUI Project/HFP_session.m @@ -1,10 +1,10 @@ -function HFP_session(subName,curr_cond, calibDir) +function HFP_session(subName,curr_cond, calibDir, shouldCancel) % HFP Code for Elliott Lab % Written by SLE 3/24/17 -% Modified by CPF - +% Modified by CPF + a = cd; % folder where the program is. @@ -39,21 +39,21 @@ stepSize = 4; %aa = cd('/Users/clemente/Desktop/AfterImage Programs/A Outputs'); name = sprintf('%sHFP.mat', subName); if exist(name, 'file') == 2 - -load(name) - -% bg = []; -% rg = []; -% br = []; -% br_check = []; - -else - -Prev_bg = []; bg = []; -Prev_rg = []; rg = []; -Prev_br = []; br = []; -Prev_brcheck = []; br_check = []; - + + load(name) + + % bg = []; + % rg = []; + % br = []; + % br_check = []; + +else + + Prev_bg = []; bg = []; + Prev_rg = []; rg = []; + Prev_br = []; br = []; + Prev_brcheck = []; br_check = []; + end %% Set up toolbox variables @@ -85,191 +85,243 @@ tstcircle = [xcent - circlePix/2 ycent - circlePix/2 xcent + circlePix/2 ycent + %run experiment Priority(topPriorityLevel); % for iRepeat = 1:numRep - stim_order = [1 1 1 2 2 2 3 3 3];%randperm(3); - keypress = 0; - %Speak('Setting %i', iRepeat) - commandwindow; - for j = 1:9 - vbl = Screen('Flip', window); - - switch stim_order(j) - case 1 %RG - current_RED = initial_RED; - colClut_one = [pixDec(current_RED) 0 0]; - colClut_two = [0 pixDec(initial_GREEN) 0]; - case 2 %BG - current_BLUE = initial_BLUE; - colClut_one = [0 0 pixDec(current_BLUE)]; - colClut_two = [0 pixDec(initial_GREEN) 0]; - case 3 %RB - current_RED = initial_RED; - colClut_one = [0 0 pixDec(initial_BLUE)]; - colClut_two = [pixDec(current_RED) 0 0]; +stim_order = [1 1 1 2 2 2 3 3 3];%randperm(3); +keypress = 0; +%Speak('Setting %i', iRepeat) +commandwindow; +for j = 1:9 + vbl = Screen('Flip', window); + + switch stim_order(j) + case 1 %RG + current_RED = initial_RED; + colClut_one = [pixDec(current_RED) 0 0]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 2 %BG + current_BLUE = initial_BLUE; + colClut_one = [0 0 pixDec(current_BLUE)]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 3 %RB + current_RED = initial_RED; + colClut_one = [0 0 pixDec(initial_BLUE)]; + colClut_two = [pixDec(current_RED) 0 0]; + end + + %ListenChar(2); + % % % % BeginMatch = 0; + % Speak('press start to begin') + % % % % while ~BeginMatch %wait for initial key press + % % % % if(CharAvail) % check for keypress, record if key=4 + % % % % [char] = GetChar; + % % % % if char =='8' + % % % % BeginMatch = 1; + % % % % end + % % % % FlushEvents('keyDown'); + % % % % end + % % % % end + + FlushEvents('keyDown'); + %Speak('Next Session') + DoneMatch = 0; + count = 0; %count the number of frames + while ~DoneMatch %look for key presses and put up stimulus + if shouldCancel + fprintf('Cancel 1\n\n'); + return; end - - %ListenChar(2); -% % % % BeginMatch = 0; -% Speak('press start to begin') -% % % % while ~BeginMatch %wait for initial key press -% % % % if(CharAvail) % check for keypress, record if key=4 -% % % % [char] = GetChar; -% % % % if char =='8' -% % % % BeginMatch = 1; -% % % % end -% % % % FlushEvents('keyDown'); -% % % % end -% % % % end - - FlushEvents('keyDown'); - %Speak('Next Session') - DoneMatch = 0; - count = 0; %count the number of frames - while ~DoneMatch %look for key presses and put up stimulus - [ keyIsDown, timeSecs, keyCode ] = KbCheck; - if(CharAvail) % check for keypress, record if key=1 or 2 or 3 - [char] = GetChar; - switch char - case '8' - DoneMatch = 1; - switch stim_order(j) - case 1 %RG - rg(j) = rgbMat(current_RED,1)/rgbMat(initial_GREEN,2) - case 2 %BG - bg(j-3) = rgbMat(current_BLUE,3)/rgbMat(initial_GREEN,2) - case 3 %BR - br(j-6) = rgbMat(initial_BLUE,3)/rgbMat(current_RED,1) - end - case '6' - switch stim_order(j) - case 1 %RG - current_RED = current_RED + stepSize - if current_RED > 1001 - beep%Speak('setting limit'); - current_RED = 1001; - end - colClut_one = [pixDec(current_RED) 0 0]; - colClut_two = [0 pixDec(initial_GREEN) 0]; - case 2 %BG - current_BLUE = current_BLUE + stepSize - if current_BLUE > 1001 - beep%Speak('setting limit'); - current_BLUE = 1001; - end - colClut_one = [0 0 pixDec(current_BLUE)]; - colClut_two = [0 pixDec(initial_GREEN) 0]; - case 3 %BR - current_RED = current_RED + stepSize - if current_RED > 1001 - beep%Speak('setting limit'); - current_RED = 1001; - end - colClut_one = [0 0 pixDec(initial_BLUE)]; - colClut_two = [pixDec(current_RED) 0 0]; - end - - case '9' - switch stim_order(j) - case 1 %RG - current_RED = current_RED + stepSize/4 - if current_RED > 1001 - beep%Speak('setting limit'); - current_RED = 1001; - end - colClut_one = [pixDec(current_RED) 0 0]; - colClut_two = [0 pixDec(initial_GREEN) 0]; - case 2 %BG - current_BLUE = current_BLUE + stepSize/4 - if current_BLUE > 1001 - beep%Speak('setting limit'); - current_BLUE = 1001; - end - colClut_one = [0 0 pixDec(current_BLUE)]; - colClut_two = [0 pixDec(initial_GREEN) 0]; - case 3 %BR - current_RED = current_RED + stepSize/4 - if current_RED > 1001 - beep%Speak('setting limit'); - current_RED = 1001; - end - colClut_one = [0 0 pixDec(initial_BLUE)]; - colClut_two = [pixDec(current_RED) 0 0]; - end - case '4' - switch stim_order(j) - case 1 %RG - current_RED = current_RED - stepSize - if current_RED <= 1 - beep%speak('setting limit'); - current_RED = 1; -% else - end - colClut_one = [pixDec(current_RED) 0 0]; - colClut_two = [0 pixDec(initial_GREEN) 0]; - case 2 %BG - current_BLUE = current_BLUE - stepSize - if current_BLUE <= 1 - beep%speak('setting limit') - current_BLUE = 1; -% else - end - colClut_one = [0 0 pixDec(current_BLUE)]; - colClut_two = [0 pixDec(initial_GREEN) 0]; - case 3 %BR - current_RED = current_RED - stepSize - if current_RED <= 1 - beep%speak('setting limit') - current_RED = 1; -% else - end - colClut_one = [0 0 pixDec(initial_BLUE)]; - colClut_two = [pixDec(current_RED) 0 0]; - end - case '7' - switch stim_order(j) - case 1 %RG - current_RED = current_RED - stepSize/4 - if current_RED <= 1 - beep%speak('setting limit'); - current_RED = 1; -% else - end - colClut_one = [pixDec(current_RED) 0 0]; - colClut_two = [0 pixDec(initial_GREEN) 0]; - case 2 %BG - current_BLUE = current_BLUE - stepSize/4 - if current_BLUE <= 1 - beep%speak('setting limit') - current_BLUE = 1; -% else - end - colClut_one = [0 0 pixDec(current_BLUE)]; - colClut_two = [0 pixDec(initial_GREEN) 0]; - case 3 %BR - current_RED = current_RED - stepSize/4 - if current_RED <= 1 - beep%speak('setting limit') - current_RED = 1; -% else - end - colClut_one = [0 0 pixDec(initial_BLUE)]; - colClut_two = [pixDec(current_RED) 0 0]; - end - end - FlushEvents('keyDown'); + [ keyIsDown, timeSecs, keyCode ] = KbCheck; + if(CharAvail) % check for keypress, record if key=1 or 2 or 3 + [char] = GetChar; + switch char + case '8' + DoneMatch = 1; + switch stim_order(j) + case 1 %RG + rg(j) = rgbMat(current_RED,1)/rgbMat(initial_GREEN,2) + case 2 %BG + bg(j-3) = rgbMat(current_BLUE,3)/rgbMat(initial_GREEN,2) + case 3 %BR + br(j-6) = rgbMat(initial_BLUE,3)/rgbMat(current_RED,1) + end + case '6' + switch stim_order(j) + case 1 %RG + current_RED = current_RED + stepSize; + if current_RED > 1001 + beep%Speak('setting limit'); + current_RED = 1001; + end + colClut_one = [pixDec(current_RED) 0 0]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 2 %BG + current_BLUE = current_BLUE + stepSize; + if current_BLUE > 1001 + beep%Speak('setting limit'); + current_BLUE = 1001; + end + colClut_one = [0 0 pixDec(current_BLUE)]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 3 %BR + current_RED = current_RED + stepSize; + if current_RED > 1001 + beep%Speak('setting limit'); + current_RED = 1001; + end + colClut_one = [0 0 pixDec(initial_BLUE)]; + colClut_two = [pixDec(current_RED) 0 0]; + end + + case '9' + switch stim_order(j) + case 1 %RG + current_RED = current_RED + stepSize/4; + if current_RED > 1001 + beep%Speak('setting limit'); + current_RED = 1001; + end + colClut_one = [pixDec(current_RED) 0 0]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 2 %BG + current_BLUE = current_BLUE + stepSize/4; + if current_BLUE > 1001 + beep%Speak('setting limit'); + current_BLUE = 1001; + end + colClut_one = [0 0 pixDec(current_BLUE)]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 3 %BR + current_RED = current_RED + stepSize/4; + if current_RED > 1001 + beep%Speak('setting limit'); + current_RED = 1001; + end + colClut_one = [0 0 pixDec(initial_BLUE)]; + colClut_two = [pixDec(current_RED) 0 0]; + end + case '4' + switch stim_order(j) + case 1 %RG + current_RED = current_RED - stepSize; + if current_RED <= 1 + beep%speak('setting limit'); + current_RED = 1; + % else + end + colClut_one = [pixDec(current_RED) 0 0]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 2 %BG + current_BLUE = current_BLUE - stepSize; + if current_BLUE <= 1 + beep%speak('setting limit') + current_BLUE = 1; + % else + end + colClut_one = [0 0 pixDec(current_BLUE)]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 3 %BR + current_RED = current_RED - stepSize; + if current_RED <= 1 + beep%speak('setting limit') + current_RED = 1; + % else + end + colClut_one = [0 0 pixDec(initial_BLUE)]; + colClut_two = [pixDec(current_RED) 0 0]; + end + case '7' + switch stim_order(j) + case 1 %RG + current_RED = current_RED - stepSize/4; + if current_RED <= 1 + beep%speak('setting limit'); + current_RED = 1; + % else + end + colClut_one = [pixDec(current_RED) 0 0]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 2 %BG + current_BLUE = current_BLUE - stepSize/4; + if current_BLUE <= 1 + beep%speak('setting limit') + current_BLUE = 1; + % else + end + colClut_one = [0 0 pixDec(current_BLUE)]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 3 %BR + current_RED = current_RED - stepSize/4; + if current_RED <= 1 + beep%speak('setting limit') + current_RED = 1; + % else + end + colClut_one = [0 0 pixDec(initial_BLUE)]; + colClut_two = [pixDec(current_RED) 0 0]; + end + case '2' + switch stim_order(j) + case 1 %RG + current_RED = initial_RED; + if current_RED <= 1 + beep%speak('setting limit'); + current_RED = 1; + % else + end + colClut_one = [pixDec(current_RED) 0 0]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 2 %BG + current_BLUE = initial_BLUE; + if current_BLUE <= 1 + beep%speak('setting limit') + current_BLUE = 1; + % else + end + colClut_one = [0 0 pixDec(current_BLUE)]; + colClut_two = [0 pixDec(initial_GREEN) 0]; + case 3 %BR + current_RED = initial_RED; + if current_RED <= 1 + beep%speak('setting limit') + current_RED = 1; + % else + end + colClut_one = [0 0 pixDec(initial_BLUE)]; + colClut_two = [pixDec(current_RED) 0 0]; + end end - Screen('FillOval', window, colClut_one, tstcircle); - vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi); - Screen('FillOval', window, colClut_two, tstcircle); - vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi); - end %while done - Screen('FillOval', window, [0 0 0], windowRect); - Screen('Flip', window); - pause(1); - end %for j - - for irep = 1:3 - br_check(irep) = bg(irep)/rg(irep); + FlushEvents('keyDown'); + if stim_order(j)==1 || stim_order(j)==3 + fprintf('Red: %d\n',current_RED); + else + fprintf('Blue: %d\n', current_BLUE); + end + end + if shouldCancel==1 + fprintf('Cancel 2\n\n'); + return; + end + Screen('FillOval', window, colClut_one, tstcircle); + vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi); + Screen('FillOval', window, colClut_two, tstcircle); + vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi); + end %while done + if shouldCancel + fprintf('Cancel 3\n\n'); + return; end + Screen('FillOval', window, [0 0 0], windowRect); + Screen('Flip', window); + pause(1); +end %for j + +if shouldCancel + fprintf('Cancel 4\n\n'); + return; +end + +for irep = 1:3 + br_check(irep) = bg(irep)/rg(irep); +end % end %i Priority(0) %ListenChar(0); @@ -281,18 +333,18 @@ fprintf('\n\n') % rb_avg = median(br(1,2:3)); Prev_bg = [Prev_bg ; bg]; -Prev_rg = [Prev_rg ; rg]; -Prev_br = [Prev_br ; br]; -Prev_brcheck = [Prev_brcheck ; br_check]; +Prev_rg = [Prev_rg ; rg]; +Prev_br = [Prev_br ; br]; +Prev_brcheck = [Prev_brcheck ; br_check]; if ge(size(Prev_bg,1),3); -rg_avg = median(reshape(Prev_rg(end-2:end,2:3),6,1)); -bg_avg = median(reshape(Prev_bg(end-2:end,2:3),6,1)); -rb_avg = median(reshape(Prev_br(end-2:end,2:3),6,1)); + rg_avg = median(reshape(Prev_rg(end-2:end,2:3),6,1)); + bg_avg = median(reshape(Prev_bg(end-2:end,2:3),6,1)); + rb_avg = median(reshape(Prev_br(end-2:end,2:3),6,1)); else -rg_avg = []; -bg_avg = []; -rb_avg = []; + rg_avg = []; + bg_avg = []; + rb_avg = []; end % Save to mat file diff --git a/002 After Image GUI Project/TVP_GENERATOR.mlapp b/002 After Image GUI Project/TVP_GENERATOR.mlapp index 595a857..3a7d14e 100644 Binary files a/002 After Image GUI Project/TVP_GENERATOR.mlapp and b/002 After Image GUI Project/TVP_GENERATOR.mlapp differ