@ -7,36 +7,24 @@ assignin('base','Stop_Press',0)% this works for the STOP experiment button
@@ -7,36 +7,24 @@ assignin('base','Stop_Press',0)% this works for the STOP experiment button
% across operating systems, and switch color range to normalized 0 - 1 range:
PsychDefaultSetup ( 2 ) ;
saveFile = sprintf ( ' %s_afterimage' , subName )
aa = cd ( ' /Users/clemente/Desktop/AfterImage Programs/A Outputs' ) ;
[ curDir , ~ , ~ ] = fileparts ( matlab . desktop . editor . getActiveFilename ) ;
saveFile = sprintf ( ' %s/../A Outputs/%s_afterimage' , curDir , subName ) ;
fp = fopen ( saveFile , ' at' ) ;
%% Color information, load hfp data and color calibration
aa = cd ( ' /Users/clemente/Desktop/AfterImage Programs/A Outputs' ) ;
hfpFile = sprintf ( ' %sHFP' , subName ) ;
load ( hfpFile , ' -mat' )
hfpFile = sprintf ( ' %s/../A Outputs/%sHFP' , curDir , subName ) ;
load ( hfpFile , ' -mat' ) ;
hfpRG = rg_avg ;
hfpBG = bg_avg ;
% cd(a); % return to program folder.
Calib_Dire = cd ( ' /Users/clemente/Desktop/AfterImage Programs/002 After Image GUI Project' ) ;
load colorCalFile1 . mat
load ( ' colorCalFile1.mat' ) ;
fprintf ( ' \nLast calibration was %s\n' , describe . date )
pix = pix / 1001 ;
cd ( aa ) ; % output folder
aa = cd ( ' /Users/clemente/Desktop/AfterImage Programs/A Outputs' ) ;
% aa = cd('D:\Dropbox\Luminotecnia\2017\Chicago Lab files\2 Experiments\Color AfterImage_Exp_Room_150\2nd\1 Programs\A Outputs')
% maxLum = 20; %cd/m^2
contFile = sprintf ( ' %s_ContMatch' , subName ) ;
cd
load ( contFile , ' -mat' )
contFile = sprintf ( ' %s/../A Outputs/%s_ContMatch' , curDir , subName ) ;
load ( contFile , ' -mat' ) ;
% % % % lCont = fliplr(Final_lCont_avg);% sort the matrix in descendent order
% % % % lumMod = fliplr(Final_lumMod_avg);
@ -76,16 +64,16 @@ redLut = [.8 0 0];
@@ -76,16 +64,16 @@ redLut = [.8 0 0];
%% Save Session Information
theDate = datestr ( now ( ) , ' mm/dd/yyyy HH:MM:SS' )
theDate = datestr ( now ( ) , ' mm/dd/yyyy HH:MM:SS' ) ;
% a = '/Users/clemente/Dropbox/Luminotecnia/2018/Experiments/Color Background Afterimage/1 Programs/4 ColBackg AI' ;% folder where the program is.
infoFile = sprintf ( ' %s_SessionsInfo' , subName )
infoFile = sprintf ( ' %s/../A Outputs/%s _SessionsInfo' , curDir , subName ) ;
aa = cd ( ' /Users/clemente/Desktop/AfterImage Programs/A Outputs' ) ; ; % folder where the program is.
%aa = cd(' /Users/clemente/Desktop/AfterImage Programs/A Outputs'); % folder where the program is.
checkfile = exist ( infoFile , ' file' )
fo = fopen ( infoFile , ' at' )
checkfile = exist ( infoFile , ' file' ) ;
fo = fopen ( infoFile , ' at' ) ;
if checkfile == 0 % if file doesn't exist, then print the following header:
fprintf ( fo , ' Subject\t Date\t Time\t Lum\t nBckg_Chro\t nCont\t nRep\t l_\t s_\t lum_\t ls45\t ls135\t luml45\t luml135\t lums45\t luml135\n' )
fprintf ( fo , ' Subject\t Date\t Time\t Lum\t nBckg_Chro\t nCont\t nRep\t l_\t s_\t lum_\t ls45\t ls135\t luml45\t luml135\t lums45\t luml135\n' ) ;
end
% fo = fopen(infoFile, 'at')
@ -97,7 +85,7 @@ fprintf(fo, '%s\t%s\t %1.2f\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n',.
@@ -97,7 +85,7 @@ fprintf(fo, '%s\t%s\t %1.2f\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n',.
% % % % % % curr_cond(3),curr_cond(4) ,curr_cond(5),curr_cond(6),...
% % % % % % curr_cond(7),curr_cond(8),curr_cond(9));
fclose ( fo )
fclose ( fo ) ;
%% set up psych toolbox
%set up 10 bit color
@ -183,15 +171,15 @@ end
@@ -183,15 +171,15 @@ 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 ) ) ] ;
%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 ) ) ] ;
%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 ;
%yPositionIsBaseline=1 ;
%create array of second hand positions to index
count = 1 ;
secHandCord ( 1 : handInt ) = ( 1 : 15 : 360 ) * ( pi / 180 ) ;
@ -210,8 +198,8 @@ WaitSecs(1);
@@ -210,8 +198,8 @@ WaitSecs(1);
%%/////////////////////////////////////////////////////////////////////////
clear iCond
curr_axis = find ( axis_chck )
TrialCount = 1 ;
curr_axis = find ( axis_chck ) ;
fprintf ( ' Current Axis: %d\n' , curr_axis ) ;
%run experiment
TrialCount = 1 ;
@ -278,7 +266,8 @@ WaitSecs(AdaptTime)
@@ -278,7 +266,8 @@ WaitSecs(AdaptTime)
rnd_idx = randperm ( length ( curr_axis ) ) ;
curr_axis = curr_axis ( rnd_idx )
curr_axis = curr_axis ( rnd_idx ) ;
fprintf ( ' Current Axis: %d\n' , curr_axis ) ;
% cond = randperm(9);
for iCond = 1 : length ( curr_axis )
%create table of color changes
@ -353,7 +342,7 @@ WaitSecs(AdaptTime)
@@ -353,7 +342,7 @@ WaitSecs(AdaptTime)
handyRht = handy + ycent ;
WaitSecs ( 5 ) ; %a short adaptation before the next trial
keypress = 0 ;
%keypress = 0 ;
count = 0 ; %for clock hand
TrialCountStr = num2str ( TrialCount ) ;
Priority ( topPriorityLevel ) ;
@ -363,8 +352,8 @@ WaitSecs(AdaptTime)
@@ -363,8 +352,8 @@ WaitSecs(AdaptTime)
for iFrames = 1 : nFrames
Screen ( ' FillArc' , window , rampLeft ( iFrames , : ) , tstCircleLeft , 0 , 180 ) ;
Screen ( ' FillArc' , window , rampRight ( iFrames , : ) , tstCircleRight , 180 , 180 ) ;
Screen ( ' DrawDots' , window , clockLft PosMat , clockPix , blackLut , [ lftXCircleCenter , center ( 2 ) ] , 2 ) ;
Screen ( ' DrawDots' , window , clockRht PosMat , clockPix , blackLut , [ rhtXCircleCenter , center ( 2 ) ] , 2 ) ;
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 ( ' DrawText' , window , TrialCountStr , 20 , 20 , redLut , wRGB ) ;
@ -394,7 +383,7 @@ WaitSecs(AdaptTime)
@@ -394,7 +383,7 @@ WaitSecs(AdaptTime)
% % imwrite(imageArray, 'test.jpg')
% % %------------------
vbl = Screen ( ' Flip' , window , secs0 + ( waitframes - 0.5 ) * ifi ) ;
Screen ( ' Flip' , window , secs0 + ( waitframes - 0.5 ) * ifi ) ;
Screen ( ' DrawingFinished' , window ) ; % tell psychtoolbox drawing is finished, should help timing
@ -424,19 +413,19 @@ Digit = [];
@@ -424,19 +413,19 @@ Digit = [];
Nums = { ' 0' , ' 1' , ' 2' , ' 3' , ' 4' , ' 5' , ' 6' , ' 7' , ' 8' , ' 9' } ;
Screen ( ' TextSize' , window , 30 ) ;
commandwindow ;
while keyIsDown == 0 | ( strcmp ( ' ENTER' , kbName ) == 0 ) % & strcmp('2',kbName)==0)
while keyIsDown == 0 | | ( strcmp ( ' ENTER' , kbName ) == 0 ) % & strcmp('2',kbName)==0)
keyIsDown = 0 ;
[ keyIsDown , secs , keyCode ] = KbCheck ;
%keyIsDown=0 ;
[ keyIsDown , ~ , keyCode ] = KbCheck ;
if keyIsDown == 1 %
kbName = KbName ( keyCode ) ;
end
if Digit & any ( strcmp ( Nums ( : ) , kbName ) ) ;
idx = find ( strcmp ( Nums ( : ) , kbName ) ) ;
NumPressed = Nums { idx } ;
if Digit & & any ( strcmp ( Nums ( : ) , kbName ) )
%idx=find(strcmp(Nums(:),kbName)) ;
NumPressed = Nums { strcmp ( Nums ( : ) , kbName ) } ;
kbName = strcat ( firstDigit , NumPressed ) ;
userRes = kbName ;
@ -447,8 +436,8 @@ if Digit & any(strcmp(Nums(:),kbName));
@@ -447,8 +436,8 @@ if Digit & any(strcmp(Nums(:),kbName));
Digit = 0 ;
WaitSecs ( . 4 ) ;
elseif any ( strcmp ( Nums ( : ) , kbName ) )
idx = find ( strcmp ( Nums ( : ) , kbName ) ) ;
NumPressed = Nums { idx } ;
%idx=find(strcmp(Nums(:),kbName)) ;
%NumPressed = Nums{idx} ;
userRes = kbName ;
%-si es numero -- llevarlo a la pantalla
DrawFormattedText ( window , kbName , 400 , 512 , redLut ) ;
@ -463,8 +452,8 @@ elseif any(strcmp(Nums(:),kbName))
@@ -463,8 +452,8 @@ elseif any(strcmp(Nums(:),kbName))
end
if strcmp ( ' DELETE' , kbName ) == 1 %-si es el backspace --limpiar numero
kbName = [ ] % ;
userRes = kbName
kbName = [ ] ;
userRes = kbName ;
firstDigit = [ ] ;
Digit = 0 ;
DrawFormattedText ( window , kbName , 400 , 512 , redLut ) ;
@ -480,7 +469,7 @@ end %end while
@@ -480,7 +469,7 @@ end %end while
end
% userRes = num2str(2);
AfterResp = ' OK'
%AfterResp = 'OK';
@ -492,14 +481,11 @@ Screen('TextSize', window, 14);
@@ -492,14 +481,11 @@ Screen('TextSize', window, 14);
% SAVE %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
aa = cd ( ' /Users/clemente/Desktop/AfterImage Programs/A Outputs' ) ;
% aa = cd('D:\Dropbox\Luminotecnia\2017\Chicago Lab files\2 Experiments\Color AfterImage_Exp_Room_150\2nd\1 Programs\A Outputs')
cd
WaitSecs ( . 2 )
time = clock ;
fprintf ( fp , ' %s\t%i/%i/%i %i:%i:%i \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 , time ( 2 ) , time ( 3 ) , time ( 1 ) , time ( 4 ) , time ( 5 ) , round ( time ( 6 ) ) , hfpRG , hfpBG , Bckg_Chro ( iChro , 1 ) , Bckg_Chro ( iChro , 2 ) , cont ( iCont ) , curr_axis ( iCond ) , Card_Dir , randStrt + 5 , userRes ) ;
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 ) ;
% a = cd('/Users/clemente/Dropbox/Luminotecnia/2018/Experiments/Color Background Afterimage/1 Programs/4 ColBackg AI'); %
% a = cd('D:\Dropbox\Luminotecnia\2017\Chicago Lab files\2 Experiments\Color AfterImage_Exp_Room_150\2nd\1 Programs\4 AfterImage'); %
@ -514,13 +500,14 @@ WaitSecs(.2)
@@ -514,13 +500,14 @@ WaitSecs(.2)
Screen ( ' Flip' , window ) ;
clear secHandCord colLut
TrialCount = TrialCount + 1
TrialCount = TrialCount + 1 ;
fprintf ( ' Trial Count: %d\n' , TrialCount ) ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% WANT TO STOP? %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% pause(3)
yesno = evalin ( ' base' , ' Stop_Press' )
yesno = evalin ( ' base' , ' Stop_Press' ) ;
if yesno == 1