Browse Source

Fixing timing bugs. -MT

master
Michael Tan 5 years ago
parent
commit
91e27999d3
  1. 162
      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

162
002 After Image GUI Project/AfIm_pupil_Exp_Rivalry.m

@ -1,5 +1,5 @@
function AfIm_pupil_Exp_Rivalry(subName,meanLum,Bckg_Chro,axis_chck,AdaptTime,nRep,OneHemi_chck,Simu_chck,OneEnd_chck) 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 % ARDUINO and CAMERA settings
@ -47,7 +47,7 @@ lCont = Final_lCont_avg;
lumMod = Final_lumMod_avg; lumMod = Final_lumMod_avg;
sCont = Final_sCont_ref; sCont = Final_sCont_ref;
nCont = size(sCont,2); nCont = size(sCont,2)
nBckg_Chro = size(Bckg_Chro,1); nBckg_Chro = size(Bckg_Chro,1);
% white = [.665 1]; % white = [.665 1];
@ -112,16 +112,16 @@ center = [xcent ycent];
%find frames per second %find frames per second
ifi = Screen('GetFlipInterval', window);% Measure the vertical refresh rate of the monitor ifi = Screen('GetFlipInterval', window);% Measure the vertical refresh rate of the monitor
topPriorityLevel = MaxPriority(window);% Retreive the maximum priority number 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); framesPerSec = round(1/ifi);
nFrames = numSecs * framesPerSec; nFrames = numSecs * framesPerSec;
waitframes = 1; %number of frames to wait between refresh 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 % 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 %in Zaidi, clock face appears at 10.15 seconds, will approximate this
%number %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); 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 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 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
ISI = 20; ISI = 20;
end end
%% Stimulus Size Parameters %% Stimulus Size Parameters
circleDeg = 7.2; circleDeg = 3.6;
clockPt = 0.1; clockPt = 0.1;
% code assumes 1 pixel = 1 arc min % code assumes 1 pixel = 1 arc min
pixPerDeg = 35; %at a distance of 57 cm pixPerDeg = 37.65; %at a distance of 58 cm
circlePix = circleDeg*pixPerDeg; circlePix = circleDeg*pixPerDeg;
clockPix = clockPt*pixPerDeg; clockPix = clockPt*pixPerDeg;
tstcircle = [xcent - circlePix/2 ycent - circlePix/2 xcent + circlePix/2 ycent + circlePix/2]; % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%% CIRCLE HALf LOCATIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%create circular grid for clock face and the numbers % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % circleDegGrid = 2 ; %tstcircle = [xcent - circlePix/2 ycent - circlePix/2 xcent + circlePix/2 ycent + circlePix/2];
% % % rad = circleDegGrid/2*pixPerDeg; %circlePix/2-pixPerDeg/2; rhtXCircleCenter = xWinSize/4;
rad = circleDeg/2*pixPerDeg; %circlePix/2-pixPerDeg/2; lftXCircleCenter = xWinSize-xWinSize/4;
radNum = (circleDeg/2) * pixPerDeg; tstCircleLeft = [lftXCircleCenter - circlePix/2 ycent - circlePix/2 lftXCircleCenter + circlePix/2 ycent + circlePix/2];
clockDegs = [1:15:360]; tstCircleRight = [rhtXCircleCenter - circlePix/2 ycent - circlePix/2 rhtXCircleCenter + circlePix/2 ycent + circlePix/2];
for iC = 1:length(clockDegs)
%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); [xcFace(iC), ycFace(iC)] = pol2cart(clockDegs(iC)*pi/180, rad);
[xcNumber(iC), ycNumber(iC)] = pol2cart(clockDegs(iC)*pi/180, 1*radNum); [xcNumber(iC), ycNumber(iC)] = pol2cart(clockDegs(iC)*pi/180, 1*radNum);
end end
for iC = 1:length(clockDegsLft)
rhtXCircleCenter = xWinSize/4; [xcRhtFace(iC), ycRhtFace(iC)] = pol2cart(clockDegsLft(iC)*pi/180, rad);
lftXCircleCenter = xWinSize-xWinSize/4; [xcRhtNumber(iC), ycRhtNumber(iC)] = pol2cart(clockDegsLft(iC)*pi/180, 1*radNum);
tstCircleLeft = [lftXCircleCenter - circlePix/2 ycent - circlePix/2 lftXCircleCenter + circlePix/2 ycent + circlePix/2]; end
tstCircleRight = [rhtXCircleCenter - circlePix/2 ycent - circlePix/2 rhtXCircleCenter + circlePix/2 ycent + circlePix/2]; 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);
%create matrix of dot locations end
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); %create matrix of dot locations
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]; clockPosMat = [reshape(xcFace,1, length(clockDegs)); reshape(ycFace,1, length(clockDegs))];
yPositionIsBaseline=1; %clockNumMat = [reshape(xcNumber,1, length(clockDegs)); reshape(ycNumber,1, length(clockDegs))];
%create array of second hand positions to index %clockRhtPosMat = [reshape(xcRhtFace,1, length(clockDegsRht)); reshape(ycRhtFace,1, length(clockDegsRht))];
count = 1; clockRhtNumMat = [reshape(xcRhtNumber,1, length(clockDegsRht)); reshape(ycRhtNumber,1, length(clockDegsRht))];
secHandCord(1:handInt) = (1:15:360)*(pi/180); %clockLftPosMat = [reshape(xcLftFace,1, length(clockDegsLft)); reshape(ycLftFace,1, length(clockDegsLft))];
for iMove = 1:length(secHandCord) 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); secHandMove(count:count+clFrames-1) = secHandCord(iMove);
count = count+clFrames; count = count+clFrames;
end end
secHandMove(length(secHandMove)+1:length(secHandMove)*2) = secHandMove(1:length(secHandMove)); secHandMove(length(secHandMove)+1:length(secHandMove)*2) = secHandMove(1:length(secHandMove));
% Specs for the border frame % Specs for the border frame
frameSize = 60; frameSize = 60;
frameWidth = 5; frameWidth = 5;
frameCircleLeft = [tstCircleLeft(1)-frameSize tstCircleLeft(2)-frameSize tstCircleLeft(3)+frameSize tstCircleLeft(4)+frameSize]; 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]; frameCircleRight = [tstCircleRight(1)-frameSize tstCircleRight(2)-frameSize tstCircleRight(3)+frameSize tstCircleRight(4)+frameSize];
WaitSecs(1); WaitSecs(1);
%%///////////////////////////////////////////////////////////////////////// %%/////////////////////////////////////////////////////////////////////////
@ -328,8 +344,10 @@ WaitSecs(AdaptTime)
[handx(ihand), handy(ihand)] = pol2cart(th(ihand),1*rad); [handx(ihand), handy(ihand)] = pol2cart(th(ihand),1*rad);
end end
handx = handx + xcent; handxLft = handx + lftXCircleCenter;
handy = handy + ycent; handyLft = handy + ycent;
handxRht = handx + rhtXCircleCenter;
handyRht = handy + ycent;
%///////////// %/////////////
switch OneHemi_chck switch OneHemi_chck
@ -353,7 +371,7 @@ WaitSecs(AdaptTime)
end end
%--------------------------- %---------------------------
if ~Clock %if ~Clock
flatSound; % so the subject prepare for the stimulus flatSound; % so the subject prepare for the stimulus
WaitSecs(4); % a few seconds before start recording WaitSecs(4); % a few seconds before start recording
%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%
@ -362,7 +380,7 @@ WaitSecs(AdaptTime)
%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%
WaitSecs(4); % WaitSecs(4); %
end %end
keypress = 0; keypress = 0;
count = 0; %for clock hand count = 0; %for clock hand
@ -403,9 +421,11 @@ WaitSecs(AdaptTime)
Screen('DrawText', window, TrialCountStr, 20, 20, redLut, wRGB); Screen('DrawText', window, TrialCountStr, 20, 20, redLut, wRGB);
for itxt = 1:24 for itxt = 1:12
textNum = sprintf('%i', textOne(itxt)); textNum = num2str(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); 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 end
if iFrames == clFrmStart if iFrames == clFrmStart
@ -414,7 +434,8 @@ WaitSecs(AdaptTime)
if iFrames > clFrmStart-1 && iFrames < clFrmStart + handInt*clFrames+5 if iFrames > clFrmStart-1 && iFrames < clFrmStart + handInt*clFrames+5
count = count+1; 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
end % Clock --------------------- end % Clock ---------------------
@ -434,21 +455,22 @@ WaitSecs(AdaptTime)
end end
Priority(0); Priority(0);
if ~Clock
WaitSecs(18); % to tell the subject to blink normally 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 if ~Clock
while ~keypress flatSound;
if CharAvail % else
userRes = input(' '); % Speak('Report Time')
keypress = 1; %
end %
end % WaitSecs(5)% This is sumed to the ISI except for the last trial
FlushEvents('mouseDown','keyDown'); % while ~keypress
% if CharAvail
% userRes = input(' ');
% keypress = 1;
% end
% end
% FlushEvents('mouseDown','keyDown');
end end
@ -458,6 +480,8 @@ WaitSecs(AdaptTime)
if Clock if Clock
Speak('Report Time')
% if Simu_chck % if Simu_chck
% userRes = 'simu'; % userRes = 'simu';
% %

14
002 After Image GUI Project/ContMatch_session_Rivalry.m

@ -60,12 +60,20 @@ fprintf('\nLast calibration was %s\n', describe.date);
pix = pix/1001; pix = pix/1001;
maxLum = 20; %cd/m^2 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]; % sCont = [.5 .5 .5 .5];
nCont = length(sCont); 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 @@
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