You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

183 lines
7.1 KiB

function Disp_Color_Rivalry(l_value,s_value,hfpRG,hfpBG,dispTime)
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 = 37.65; %at a distance of 58 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))];
% 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
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
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
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);
if dispTime<70
WaitSecs(dispTime);
else
KbStrokeWait;
end
Screen('CloseAll');
end