Browse Source

Fixing timing bugs. -MT

master
Michael Tan 5 years ago
parent
commit
91e27999d3
  1. 174
      002 After Image GUI Project/AfIm_pupil_Exp_Rivalry.m
  2. 14
      002 After Image GUI Project/ContMatch_session_Rivalry.m
  3. BIN
      002 After Image GUI Project/TVP_GENERATOR.mlapp
  4. 2
      Experimental Conditions (zaidi paradigm)/1_CHROS_3axis.txt

174
002 After Image GUI Project/AfIm_pupil_Exp_Rivalry.m

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
function AfIm_pupil_Exp_Rivalry(subName,meanLum,Bckg_Chro,axis_chck,AdaptTime,nRep,OneHemi_chck,Simu_chck,OneEnd_chck)
Clock = 0;
Clock = 1;
%%%%%%%%%%%%%%%%
% ARDUINO and CAMERA settings
@ -47,7 +47,7 @@ lCont = Final_lCont_avg; @@ -47,7 +47,7 @@ lCont = Final_lCont_avg;
lumMod = Final_lumMod_avg;
sCont = Final_sCont_ref;
nCont = size(sCont,2);
nCont = size(sCont,2)
nBckg_Chro = size(Bckg_Chro,1);
% white = [.665 1];
@ -112,16 +112,16 @@ center = [xcent ycent]; @@ -112,16 +112,16 @@ center = [xcent ycent];
%find frames per second
ifi = Screen('GetFlipInterval', window);% Measure the vertical refresh rate of the monitor
topPriorityLevel = MaxPriority(window);% Retreive the maximum priority number
numSecs = 8; %in seconds, total presentation time
numSecs = 16; %in seconds, total presentation time
framesPerSec = round(1/ifi);
nFrames = numSecs * framesPerSec;
waitframes = 1; %number of frames to wait between refresh
% color changed .03 of full cycle per second - finished 1/2 cycle in 16 seconds, 1/32
%in Zaidi, clock face appears at 10.15 seconds, will approximate this
%number
zaidiClock = 2%10.15; %is when Zaidi started in his example.
zaidiClock = 10.15; %is when Zaidi started in his example.
clFrmStart = floor(1/ifi*zaidiClock);
clTotTime = 6%2.9*2; %how long is clock in the screen
clTotTime = 2.9*2; %how long is clock in the screen
handInt = 12*2; %how many places to stop around the clock
clFrames = floor(clTotTime/handInt/ifi); %this will move the hand 15 degrees at a time, and decides how many frames to sit at each angle
@ -132,56 +132,72 @@ else @@ -132,56 +132,72 @@ else
ISI = 20;
end
%% Stimulus Size Parameters
circleDeg = 7.2;
clockPt = 0.1;
% code assumes 1 pixel = 1 arc min
pixPerDeg = 35; %at a distance of 57 cm
circlePix = circleDeg*pixPerDeg;
clockPix = clockPt*pixPerDeg;
tstcircle = [xcent - circlePix/2 ycent - circlePix/2 xcent + 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;
clockDegs = [1:15:360];
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
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];
circleDeg = 3.6;
clockPt = 0.1;
%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))];
Screen('TextSize', window, 14);
textOne = [6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 2 3 4 5];
yPositionIsBaseline=1;
%create array of second hand positions to index
count = 1;
secHandCord(1:handInt) = (1:15:360)*(pi/180);
for iMove = 1:length(secHandCord)
secHandMove(count:count+clFrames-1) = secHandCord(iMove);
count = count+clFrames;
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);
% 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))];
Screen('TextSize', window, 14);
textOne = [12:24,1:11]; %[6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 2 3 4 5];
%yPositionIsBaseline=1;
%create array of second hand positions to index
count = 1;
secHandCord(1:handInt) = (1:15:360)*(pi/180);
for iMove = 1:length(secHandCord)
secHandMove(count:count+clFrames-1) = secHandCord(iMove);
count = count+clFrames;
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);
%%/////////////////////////////////////////////////////////////////////////
@ -328,8 +344,10 @@ WaitSecs(AdaptTime) @@ -328,8 +344,10 @@ WaitSecs(AdaptTime)
[handx(ihand), handy(ihand)] = pol2cart(th(ihand),1*rad);
end
handx = handx + xcent;
handy = handy + ycent;
handxLft = handx + lftXCircleCenter;
handyLft = handy + ycent;
handxRht = handx + rhtXCircleCenter;
handyRht = handy + ycent;
%/////////////
switch OneHemi_chck
@ -353,7 +371,7 @@ WaitSecs(AdaptTime) @@ -353,7 +371,7 @@ WaitSecs(AdaptTime)
end
%---------------------------
if ~Clock
%if ~Clock
flatSound; % so the subject prepare for the stimulus
WaitSecs(4); % a few seconds before start recording
%%%%%%%%%%%%%%%%%%%%%%%%%
@ -362,7 +380,7 @@ WaitSecs(AdaptTime) @@ -362,7 +380,7 @@ WaitSecs(AdaptTime)
%%%%%%%%%%%%%%%%%%%%
WaitSecs(4); %
end
%end
keypress = 0;
count = 0; %for clock hand
@ -403,9 +421,11 @@ WaitSecs(AdaptTime) @@ -403,9 +421,11 @@ WaitSecs(AdaptTime)
Screen('DrawText', window, TrialCountStr, 20, 20, redLut, wRGB);
for itxt = 1:24
textNum = sprintf('%i', textOne(itxt));
Screen('DrawText', window, textNum, 1.18*clockNumMat(1,itxt)+center(1,1)-7, 1.18*clockNumMat(2,itxt)+center(1,2)-7, blackLut, wRGB);
for itxt = 1:12
textNum = num2str(textOne(itxt));
Screen('DrawText', window, textNum, 1.18*clockRhtNumMat(1,itxt)+rhtXCircleCenter-7, 1.18*clockRhtNumMat(2,itxt)+center(1,2)-7, blackLut, wRGB);
textNum = num2str(textOne(itxt+12));
Screen('DrawText', window, textNum, 1.18*clockLftNumMat(1,itxt)+lftXCircleCenter-7, 1.18*clockLftNumMat(2,itxt)+center(1,2)-7, blackLut, wRGB);
end
if iFrames == clFrmStart
@ -414,7 +434,8 @@ WaitSecs(AdaptTime) @@ -414,7 +434,8 @@ WaitSecs(AdaptTime)
if iFrames > clFrmStart-1 && iFrames < clFrmStart + handInt*clFrames+5
count = count+1;
Screen('DrawLine', window, redLut, xcent, ycent, handx(count), handy(count), 2.5);
Screen('DrawLine', window, redLut, lftXCircleCenter, ycent, handxLft(count), handyLft(count), 2.5);
Screen('DrawLine', window, redLut, rhtXCircleCenter, ycent, handxRht(count), handyRht(count), 2.5);
end
end % Clock ---------------------
@ -433,22 +454,23 @@ WaitSecs(AdaptTime) @@ -433,22 +454,23 @@ WaitSecs(AdaptTime)
end
Priority(0);
WaitSecs(18); % to tell the subject to blink normally
if ~Clock
WaitSecs(18); % to tell the subject to blink normally
flatSound;
else
Speak('Report Time')
WaitSecs(5)% This is sumed to the ISI except for the last trial
while ~keypress
if CharAvail
userRes = input(' ');
keypress = 1;
end
end
FlushEvents('mouseDown','keyDown');
% else
% Speak('Report Time')
%
%
% WaitSecs(5)% This is sumed to the ISI except for the last trial
% while ~keypress
% if CharAvail
% userRes = input(' ');
% keypress = 1;
% end
% end
% FlushEvents('mouseDown','keyDown');
end
@ -458,6 +480,8 @@ WaitSecs(AdaptTime) @@ -458,6 +480,8 @@ WaitSecs(AdaptTime)
if Clock
Speak('Report Time')
% if Simu_chck
% userRes = 'simu';
%

14
002 After Image GUI Project/ContMatch_session_Rivalry.m

@ -60,12 +60,20 @@ fprintf('\nLast calibration was %s\n', describe.date); @@ -60,12 +60,20 @@ fprintf('\nLast calibration was %s\n', describe.date);
pix = pix/1001;
maxLum = 20; %cd/m^2
lumMod_initial = [.6 .7 .8 1 ];
% lumMod_initial = [.6 .7 .8 1 ];
%
% lCont_initial = [0.02 0.026 0.034 .04];
%
%
% sCont = [.35 .5 .65 .8];
lCont_initial = [0.02 0.026 0.034 .04];
lumMod_initial = [.7 .8 1 ];
lCont_initial = [0.026 0.034 .04];
sCont = [.5 .65 .8];
sCont = [.35 .5 .65 .8];
% sCont = [.5 .5 .5 .5];
nCont = length(sCont);

BIN
002 After Image GUI Project/TVP_GENERATOR.mlapp

Binary file not shown.

2
Experimental Conditions (zaidi paradigm)/1_CHROS_3axis.txt

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
Luminance , Chro_littL , Chro_littS , AdaptTime, nRep, l_axis, s_axis , lum_axis , l_s_45 , l_s_135 , lum_l_45 , lum_l_135 , lum_s_45 , lum_s_135
20, 0.665 , 1.00 , 60 , 3 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
Loading…
Cancel
Save