diff --git a/.DS_Store b/.DS_Store index 3caebda..c2ce3bd 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/002 After Image GUI Project/AfIm_Exp_Rivalry.m b/002 After Image GUI Project/AfIm_Exp_Rivalry.m index 78f7f51..65f2a43 100755 --- a/002 After Image GUI Project/AfIm_Exp_Rivalry.m +++ b/002 After Image GUI Project/AfIm_Exp_Rivalry.m @@ -190,6 +190,11 @@ try end secHandMove(length(secHandMove)+1:length(secHandMove)*2) = secHandMove(1:length(secHandMove)); + % Specs for the border frame + frameSize = 60; + frameWidth = 5; + frameCircleLeft = [tstCircleLeft(1)-frameSize tstCircleLeft(2)-frameSize tstCircleLeft(3)+frameSize tstCircleLeft(4)+frameSize]; + frameCircleRight = [tstCircleRight(1)-frameSize tstCircleRight(2)-frameSize tstCircleRight(3)+frameSize tstCircleRight(4)+frameSize]; WaitSecs(1); @@ -380,6 +385,17 @@ try Screen('DrawText', window, textNum, 1.18*clockLftNumMat(1,itxt)+lftXCircleCenter-7, 1.18*clockLftNumMat(2,itxt)+center(1,2)-7, blackLut, wRGB); end + Screen('FrameOval', window, 0 ,frameCircleLeft, frameWidth, frameWidth); + Screen('FrameOval', window, 0 ,frameCircleRight, frameWidth, frameWidth); + Screen('DrawLine', window, 0, lftXCircleCenter+circlePix/2+frameSize, center(2),... + lftXCircleCenter+circlePix/2+frameSize-20, center(2), frameWidth); + Screen('DrawLine', window, 0, lftXCircleCenter, center(2)+circlePix/2+frameSize,... + lftXCircleCenter, center(2)+circlePix/2+frameSize-20, frameWidth); + Screen('DrawLine', window, 0, rhtXCircleCenter-circlePix/2-frameSize, center(2),... + rhtXCircleCenter-circlePix/2-frameSize+20, center(2), frameWidth); + Screen('DrawLine', window, 0, rhtXCircleCenter, center(2)-circlePix/2-frameSize,... + rhtXCircleCenter, center(2)-circlePix/2-frameSize+20, frameWidth); + if iFrames == clFrmStart beep; end @@ -559,7 +575,6 @@ catch ME warndlg('The program failed to run. Try again.') sca rethrow(ME); - end end diff --git a/002 After Image GUI Project/Disp_Color_Rivalry.m b/002 After Image GUI Project/Disp_Color_Rivalry.m index b4ff0b9..444b102 100644 --- a/002 After Image GUI Project/Disp_Color_Rivalry.m +++ b/002 After Image GUI Project/Disp_Color_Rivalry.m @@ -115,6 +115,12 @@ clockRhtNumMat = [reshape(xcRhtNumber,1, length(clockDegsRht)); reshape(ycRhtNum %clockLftPosMat = [reshape(xcLftFace,1, length(clockDegsLft)); reshape(ycLftFace,1, length(clockDegsLft))]; clockLftNumMat = [reshape(xcLftNumber,1, length(clockDegsLft)); reshape(ycLftNumber,1, length(clockDegsLft))]; +% Specs for the border frame +frameSize = 60; +frameWidth = 5; +frameCircleLeft = [tstCircleLeft(1)-frameSize tstCircleLeft(2)-frameSize tstCircleLeft(3)+frameSize tstCircleLeft(4)+frameSize]; +frameCircleRight = [tstCircleRight(1)-frameSize tstCircleRight(2)-frameSize tstCircleRight(3)+frameSize tstCircleRight(4)+frameSize]; + %% Screen('FillRect', window, [0 0 0], windowRect);% dark screen @@ -147,6 +153,17 @@ Screen('DrawDots', window, clockPosMat,clockPix, blackLut, [rhtXCircleCenter,cen 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 +Screen('FrameOval', window, 0 ,frameCircleLeft, frameWidth, frameWidth); +Screen('FrameOval', window, 0 ,frameCircleRight, frameWidth, frameWidth); +Screen('DrawLine', window, 0, lftXCircleCenter+circlePix/2+frameSize, center(2),... + lftXCircleCenter+circlePix/2+frameSize-20, center(2), frameWidth); +Screen('DrawLine', window, 0, lftXCircleCenter, center(2)+circlePix/2+frameSize,... + lftXCircleCenter, center(2)+circlePix/2+frameSize-20, frameWidth); +Screen('DrawLine', window, 0, rhtXCircleCenter-circlePix/2-frameSize, center(2),... + rhtXCircleCenter-circlePix/2-frameSize+20, center(2), frameWidth); +Screen('DrawLine', window, 0, rhtXCircleCenter, center(2)-circlePix/2-frameSize,... + rhtXCircleCenter, center(2)-circlePix/2-frameSize+20, frameWidth); + textOne = [12:24,1:11]; scl = 1.35; for itxt = 1:12 @@ -156,12 +173,12 @@ for itxt = 1: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(); +%WaitSecs(10) +%KbWait(); % % end -% KbStrokeWait; +KbStrokeWait; Screen('CloseAll'); end \ No newline at end of file diff --git a/002 After Image GUI Project/HFP_session_Rivalry.m b/002 After Image GUI Project/HFP_session_Rivalry.m new file mode 100644 index 0000000..f005339 --- /dev/null +++ b/002 After Image GUI Project/HFP_session_Rivalry.m @@ -0,0 +1,365 @@ + +function HFP_session(subName,curr_cond, calibDir, shouldCancel) + +% HFP Code for Elliott Lab +% Written by SLE 3/24/17 +% Modified by CPF + +a = cd; % folder where the program is. + + +hfpDate = date; +saveFile = sprintf('%sHFP',subName); +numRep = 3; %number of repetitions + +%Calib_Dire = cd('/Users/clemente/Desktop/AfterImage Programs/002 After Image GUI Project'); +%load in monitor calibration information & color set parameters +load([calibDir,'colorCalFile1.mat']); +fprintf('\nLast calibration was %s\n', describe.date); +pixDec = pix/length(pix); %converts 1001 numbers to decimals +lum = 5; %in cd/m^2 + +rgbMat(:,4) = pix; +rgbMat(:,1) = redProp(:)*maxPhosXYZ(1,2); +rgbMat(:,2) = grnProp(:)*maxPhosXYZ(2,2); +rgbMat(:,3) = blueProp(:)*maxPhosXYZ(3,2); + +for i=1:3 + settings(i) = pix(dsearchn(rgbMat(:,i), lum)); +end +%gives an index into the phosphor table to find a value btw 0-1 +%correponding to that luminance +initial_RED = settings(1) +initial_GREEN = settings(2) +initial_BLUE = settings(3) +%stepSize is based on the total number of unique luminance values in the rgbMat so we don't get stuck pushing the button to move the luminance of 1 phosphor +stepSize = 4; + +%% Load previous HFP values +%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 = []; + +end + +%% Set up toolbox variables +% switch color range to normalized 0 - 1 range: +% PsychDefaultSetup(2); +expScreen = 1; +[window, windowRect] = PsychImaging('OpenWindow', expScreen, [0 0 0], [], [], []); +% Screen('OpenWindow',0, [0 0 0]); %makes main screen dark +%PsychImaging('OpenWindow', expScreen, wRGB); +[xcent,ycent] = RectCenter(windowRect); +center = [xcent ycent]; +[xWinSize,~] = Screen('WindowSize',window); + +%% TIMING +%find frames per second +ifi = Screen('GetFlipInterval', window);% Measure the vertical refresh rate of the monitor +topPriorityLevel = MaxPriority(window);% Retreive the maximum priority number +framesPerSec = round(1/ifi); +hfpFreq = 15; +waitframes = floor(framesPerSec/hfpFreq); %number of frames to wait between refresh +%freqRefresh = ifi*framesPerSec/hfpFreq; + +%% Stimulus Size Parameters +circleDeg = 3.6; %was 1.5 in Sarah Program +pixPerDeg =35;% was 60 in Sarah Program +circlePix = circleDeg*pixPerDeg; +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]; + +tstcircle = [xcent - circlePix/2 ycent - circlePix/2 xcent + circlePix/2 ycent + circlePix/2]; + +%cd(a); % return to folder where the program is +%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]; + 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 + [ 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 + 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); + Screen('FillOval', window, colClut_one, tstCircleLeft); + Screen('FillOval', window, colClut_one, tstCircleRight); + vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi); + %Screen('FillOval', window, colClut_two, tstcircle); + Screen('FillOval', window, colClut_two, tstCircleLeft); + Screen('FillOval', window, colClut_two, tstCircleRight); + 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); +sca +fprintf('\n\n') + +% rg_avg = median(rg(1,2:3)); +% bg_avg = median(bg(1,2:3)); +% 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]; + +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)); +else + rg_avg = []; + bg_avg = []; + rb_avg = []; +end + +% Save to mat file +%aa = cd('/Users/clemente/Desktop/AfterImage Programs/A Outputs'); +saveCmd = ['save ' saveFile ' hfpDate rg_avg bg_avg rb_avg Prev_rg Prev_bg Prev_br Prev_brcheck']; +eval(saveCmd) + +end \ No newline at end of file diff --git a/002 After Image GUI Project/TVP_GENERATOR.mlapp b/002 After Image GUI Project/TVP_GENERATOR.mlapp index 3a7d14e..a0da218 100644 Binary files a/002 After Image GUI Project/TVP_GENERATOR.mlapp and b/002 After Image GUI Project/TVP_GENERATOR.mlapp differ