From 6f43b876c4269f8df88e4104f7526ba433d5d4da Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 12 Aug 2020 20:16:30 +0200 Subject: [PATCH 1/2] remove old radial files --- Visual-loc_radial/SetParameters.m | 63 --- Visual-loc_radial/V_hMT_localizer.m | 407 ----------------- Visual-loc_radial/subfun/ExpDesign.m | 63 --- Visual-loc_radial/subfun/InitPTB.m | 77 ---- Visual-loc_radial/subfun/UserInputs.m | 23 - .../subfun/assignTargets_insideBlock.m | 47 -- Visual-loc_radial/subfun/pressSpace4me.m | 20 - .../z_old_steph/CloseSerialPort.m | 9 - .../z_old_steph/MT_TakeSerialButtonPerFrame.m | 30 -- .../z_old_steph/MT_portAndTrigger.m | 14 - .../z_old_steph/Main_MR_Serial_Port.m | 46 -- .../z_old_steph/Onsets_trial.mat | Bin 395 -> 0 bytes .../z_old_steph/OpenSerialPort.asv | 15 - .../z_old_steph/OpenSerialPort.m | 15 - .../z_old_steph/V_hMT_localizer.m | 417 ------------------ .../z_old_steph/Wait_N_SerialTrigger.m | 31 -- .../z_old_steph/assignTargets_insideBlock.m | 47 -- .../z_old_steph/experimental_design.m | 52 --- Visual-loc_radial/z_old_steph/mirror2Pixels.m | 23 - Visual-loc_radial/z_old_steph/startPTB.m | 17 - 20 files changed, 1416 deletions(-) delete mode 100644 Visual-loc_radial/SetParameters.m delete mode 100755 Visual-loc_radial/V_hMT_localizer.m delete mode 100755 Visual-loc_radial/subfun/ExpDesign.m delete mode 100644 Visual-loc_radial/subfun/InitPTB.m delete mode 100644 Visual-loc_radial/subfun/UserInputs.m delete mode 100755 Visual-loc_radial/subfun/assignTargets_insideBlock.m delete mode 100644 Visual-loc_radial/subfun/pressSpace4me.m delete mode 100755 Visual-loc_radial/z_old_steph/CloseSerialPort.m delete mode 100755 Visual-loc_radial/z_old_steph/MT_TakeSerialButtonPerFrame.m delete mode 100755 Visual-loc_radial/z_old_steph/MT_portAndTrigger.m delete mode 100755 Visual-loc_radial/z_old_steph/Main_MR_Serial_Port.m delete mode 100755 Visual-loc_radial/z_old_steph/Onsets_trial.mat delete mode 100755 Visual-loc_radial/z_old_steph/OpenSerialPort.asv delete mode 100755 Visual-loc_radial/z_old_steph/OpenSerialPort.m delete mode 100755 Visual-loc_radial/z_old_steph/V_hMT_localizer.m delete mode 100755 Visual-loc_radial/z_old_steph/Wait_N_SerialTrigger.m delete mode 100755 Visual-loc_radial/z_old_steph/assignTargets_insideBlock.m delete mode 100755 Visual-loc_radial/z_old_steph/experimental_design.m delete mode 100755 Visual-loc_radial/z_old_steph/mirror2Pixels.m delete mode 100755 Visual-loc_radial/z_old_steph/startPTB.m diff --git a/Visual-loc_radial/SetParameters.m b/Visual-loc_radial/SetParameters.m deleted file mode 100644 index b0adfc1..0000000 --- a/Visual-loc_radial/SetParameters.m +++ /dev/null @@ -1,63 +0,0 @@ -function [ExpParameters, Cfg] = SetParameters() - -ExpParameters = struct; % Initialize the parameters variables -Cfg = struct; % Initialize the general configuration variables - -%% Debug mode settings -Cfg.TestingSmallScreen = false; % To test on a part of the screen, change to 1 -Cfg.Debug = true; % To test the script out of the scanner -Cfg.stim_position = 'PC'; % 'Scanner': means that it removes the lower 1/3 of the screen (the coil hides the lower part of the screen) - -%% MRI settings -Cfg.Device = 'PC'; % 'PC': does not care about trigger - 'Scanner' -Cfg.triggerKey = 's'; %set the letter sent by the trigger to sync stimulation and volume acquisition -Cfg.numTriggers = 4; % CHECK ON THE MAIN SCRIPT, MADE AN ERROR TO PUT IT HERE BUT IT WILL BE USEFUL ANYWAY - - -%% Engine parameters -% Monitor parameters -Cfg.monitor_width = 42; % Monitor Width in cm -Cfg.screen_distance = 134; % Distance from the screen in cm - -% Monitor parameters for PTB -Cfg.Screen = max(Screen('Screens')); % Main screen -Cfg.White = [255 255 255]; -Cfg.Black = [ 0 0 0 ]; -Cfg.Grey = ceil(mean([Cfg.Black; Cfg.White])); -Cfg.Background_color = Cfg.Black; -Cfg.textColor = Cfg.White; -Cfg.TextFont = 'Courier New'; -Cfg.TextSize = 20; -Cfg.TextStyle = 1; - -%% Experiment Design -ExpParameters.possibleConditions = {'static', 'motion'}; -ExpParameters.onsetDelay = 2; %%% IN THE MAIN EXP IS 5 % Seconds before the motion stimuli are presented, the scans will be discarded until the magnetic field is homogenous -ExpParameters.blockDur = 16; % Block duration %%% [should be a multiple of osc (below)] -ExpParameters.nrCycles = ExpParameters.blockDur/2 ; % Number of cycles per block, where 1 Cycle = one inward and outward motion together -ExpParameters.nrTrials = 7; % Number of trials, where 1 trial = 1 block of all conditions (static and motion) -ExpParameters.IBI = 8; %%% BETWEEN CONDITION? % Inter-block duration in seconds (time between blocks) - -%% Visual Stimulation -ExpParameters.dot_speed = 4; % dot speed (deg/sec) -ExpParameters.ndots = 120; % number of dots -ExpParameters.min_d = 0.1; % minumum radius of annulus (degrees) -ExpParameters.max_d = 4; %Cfg.winRect(3)/(3*2) % maximum radius of annulus (degrees) -ExpParameters.dot_w = 0.1; % width of dot (deg) -ExpParameters.fix_r = 0.03; % radius of fixation point (deg) -ExpParameters.f_kill = 0.05; % fraction of dots to kill each frame (limited lifetime) -ExpParameters.differentcolors = 0; % Use a different color for each point if == 1. Use common color white if == 0. -ExpParameters.differentsizes = 0; % Use different sizes for each point if >= 1. Use one common size if == 0. -ExpParameters.waitframes = 1; % Show new dot-images at each waitframes'th monitor refresh. -ExpParameters.reallocate_staticDots = 0 ; % 0 = static dots will stay in the same position , 1 = static dots will be % reallocated in each cycle (2 seconds) -%% Task Instructions - -ExpParameters.TaskInstruction = 'Press for RED fixation circle'; - -%% Task 1 - Fixation cross -ExpParameters.Task1 = true; % true / false - -if ExpParameters.Task1 - ExpParameters.range_targets = [2 4]; % range of number of targets in each block (from 2 to 5 targets in each block) -end - diff --git a/Visual-loc_radial/V_hMT_localizer.m b/Visual-loc_radial/V_hMT_localizer.m deleted file mode 100755 index 68ad810..0000000 --- a/Visual-loc_radial/V_hMT_localizer.m +++ /dev/null @@ -1,407 +0,0 @@ -%% Visual motion hMT localizer -% -% Original Script Written by Sam Weiller to localize MT+/V5 -% Adapted by M.Rezk -% Updated by M.Barilari - -% % % To correct for the y-axis problem inside the scanner -% % % where the lower 1/3 of the screen is not appearing because of coil -% % % indicate which device the script is running on, on PC, the middle of the -% % % y axis will be the middle of the screen, on the Scanner, the middle of -% % % y-axis will be the middle of the upper 2/3 of the screen, because the -% % % lower 1/3 is not visible due to the coil in the scanner. - -% % % 7 trials : 310.8743 sec = 5.18 minutes -% % % 310.8743 = 156 TR + 4 trigger = 160 TRs - -% clear all; -% clc - -% make sure we got access to all the required functions and inputs -addpath(fullfile(pwd, 'subfun')) -addpath(fullfile(pwd, 'input')) - -% set and load all the parameters to run the experiment -[subjectName, runNumber, sessionNumber] = UserInputs; -[ExpParameters, Cfg] = SetParameters(); - - - - - -% % % fprintf('Connected Device is %s \n\n',Cfg.Device); MOVE THIS IN THE SET PAREMETERS FUNC AT THE END -% % % disp('MT Localizer') MOVE THIS IN THE SET PAREMETERS FUNC AT THE END - - - - -%% Experiment - -% Safety loop: close the screen if code crashes -try - %% Init the experiment - [Cfg] = InitPTB(Cfg); - - % Assign the blocks, conditions, and the number of targets that will be used in the motion localizer - [ExpParameters] = ExpDesign(ExpParameters); - - - % Show the instruction on the screen - if ExpParameters.Task1 - DrawFormattedText(Cfg.win, ExpParameters.TaskInstruction, ... - 'center', 'center', Cfg.textColor); - Screen('Flip', Cfg.win); - end - - % Wait for space key to be pressed - pressSpace4me - - WaitSecs(0.25); - - % % % TRIGGER - % % % if strcmp(Cfg.Device,'PC') - % % % DrawFormattedText(Cfg.win,'Waiting For Trigger',... - % % % 'center', 'center', Cfg.Black); - % % % Screen('Flip', Cfg.win); - % % % - % % % % press key - % % % KbWait(); - % % % KeyIsDown=1; - % % % while KeyIsDown>0 - % % % [KeyIsDown, ~, ~]=KbCheck; - % % % end - % % % - % % % % open Serial Port "SerPor" - COM1 (BAUD RATE: 11520) - % % % elseif strcmp(Cfg.Device,'Scanner') - % % % DrawFormattedText(Cfg.win,'Waiting For Trigger','center', 'center', Cfg.Black); - % % % Screen('Flip', Cfg.win); - % % % SerPor = MT_portAndTrigger; - % % % Screen('Flip', Cfg.win); - % % % end - - %% Experiment Start (Main Loop) - experimentStartTime = GetSecs; - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - - - - - - - - - - - - - - - - - - - - - - - %% Scanning Parameters - - % Number of frames for one block - nframes = floor(ExpParameters.blockDur/Cfg.ifi); - while mod(nframes,ExpParameters.nrCycles)~=0 % make sure the nframes are even number - nframes = nframes-1; % to be able to re-assign dots in the static condition (to perform divison calculation) - end - - - ppd = pi * (Cfg.winRect(3)-Cfg.winRect(1)) / atan(Cfg.monitor_width/Cfg.screen_distance/2) / 360; % pixels per degree - %[mirrorPixelPerDegree] = mirror2Pixels (Cfg.winRect,Cfg.screen_distance,mirror_width) ; % Calculate pixel per degree on the mirror surface - pfs = (ppd * ExpParameters.dot_speed) / (1/Cfg.ifi); % dot speed (pixels/frame) - s = ExpParameters.dot_w * ppd; % dot size (pixels) - rmax = ExpParameters.max_d *ppd; % maximum radius of annulus (1/4th of the x-axis) - rmin = ExpParameters.min_d * ppd; % minimum radius of annulus - r = rmax * sqrt(rand(ExpParameters.ndots,1)); % r - r(r0) - s=(1+rand(1, ExpParameters.ndots)*(ExpParameters.differentsizes-1))*s; - end; - - - %% Fixation Cross - cfg.fixCrossDimPix = 10; % Set the length of the lines (in Pixels) of the fixation cross - cfg.lineWidthPix = 4; % Set the line width (in Pixels) for our fixation cross - cfg.fixationCross_color = [0 0 0] ; - xCoords = [-cfg.fixCrossDimPix cfg.fixCrossDimPix 0 0]; - yCoords = [0 0 -cfg.fixCrossDimPix cfg.fixCrossDimPix]; - cfg.allCoords = [xCoords; yCoords]; - cfg.center = [Cfg.winRect(1,3), Cfg.winRect(1,4)]/2; - %% Experiment start - % The experment will wait (ExpParameters.onsetDelay) Secs before running the stimuli - Screen('DrawLines', Cfg.win, cfg.allCoords,cfg.lineWidthPix, cfg.fixationCross_color , [cfg.center(1) cfg.center(2)], 1);% draw fixation dot (flip erases it) - blank_onset=Screen('Flip', Cfg.win); - WaitSecs('UntilTime', blank_onset + ExpParameters.onsetDelay); - - targetTime = []; - responseKey = []; - responseTime = []; - - for blocks = 1:ExpParameters.nrBlocks - timeLogger.block(blocks).startTime = GetSecs - experimentStartTime; % Get the start time of the block - timeLogger.block(blocks).condition = ExpParameters.condition(blocks); % Get the condition of the block (motion or static) - timeLogger.block(blocks).names = ExpParameters.names(blocks); % Get the name of the block (l_motion or r_motion or r/l_static) - - - %% Motion blocks - if strcmp(ExpParameters.condition(blocks),'motion') % Check if this block is a motion condition - motionStartLog = GetSecs; - motionEnd = motionStartLog + ExpParameters.blockDur; % Define when the animation loop will stop - - %Define the targets for this block - targets_inside_block = assignTargets_insideBlock (nframes,ExpParameters.blockDur,Cfg.ifi,ExpParameters.targets(blocks)); - vbl = Screen('Flip', Cfg.win, 0, 1); - - % -------------- - % animation loop - % -------------- - - for i = 1:nframes - - if targets_inside_block(i)==0; % if it is not a target frame - Screen('DrawLines', Cfg.win, cfg.allCoords,cfg.lineWidthPix, cfg.fixationCross_color , [cfg.center(1) cfg.center(2)], 1); % draw white fixation cross (flip erases it) - targetTime(end+1)=0; - elseif targets_inside_block(i)==1; - Screen('DrawLines', Cfg.win, cfg.allCoords,cfg.lineWidthPix, [255 0 0] , [cfg.center(1) cfg.center(2)], 1); % draw RED fixation cross (flip erases it) [TARGET] - targetTime(end+1)=GetSecs-experimentStartTime; - end - - %% Get responseKey and responseTime - % Use KbCheck if using PC , or MT_TakeSerialButtonPerFrame if using fMRI - % Since these are frames, we need to collect the response - % button at each frame to get the response time. - if strcmp(Cfg.Device,'Scanner') - [sbutton,secs] = MT_TakeSerialButtonPerFrame(SerPor); - responseKey(end+1)= sbutton; - responseTime(end+1)= secs - experimentStartTime; - elseif strcmp(Cfg.Device,'PC') - [KeyIsDown,PressedSecs,KeyCode] = KbCheck(-1); - if KeyIsDown - responseKey(end+1)= 1 ; - responseTime(end+1)= PressedSecs - experimentStartTime; - elseif ~KeyIsDown - responseKey(end+1)= 0; - responseTime(end+1)= 0; - end - end - - if GetSecs <= motionEnd - if i>1 - - %Screen('DrawDots', w, xymatrix, s, colvect, [(Cfg.winRect(1,3)/2+(direction(blocks)*(Cfg.winRect(1,3)/4+rmax))) (Cfg.winRect(1,4)/2)],1); % change 1 to 0 to draw square dots - Screen('DrawDots', Cfg.win, xymatrix, s, colvect, [(Cfg.winRect(1,3)/2) (Cfg.winRect(1,4)/2)],1); % change 1 to 0 to draw square dots - Screen('DrawingFinished', Cfg.win); % Tell PTB that no further drawing commands will follow before Screen('Flip') - end - - mdir = ones(ExpParameters.ndots,1) * mod(ceil(i/(nframes/(ExpParameters.nrCycles*2))),2)*2-1; - dr = pfs * mdir; % change in radius per frame (pixels) - dxdy = [dr dr] .* cs; % change in x and y per frame (pixels) - - xy = xy + dxdy; % move dots - r = r + dr; % update polar coordinates too - - r_out = find(r > rmax | r < rmin | rand(ExpParameters.ndots,1) < ExpParameters.f_kill); % dots to reposition if they are outside the aperture - nout = length(r_out); - - if nout - r(r_out) = rmax * sqrt(rand(nout,1)); - r(r1 %&& rem(i,10)~=0 - - Screen('DrawDots', Cfg.win, xymatrix, s, colvect, [(Cfg.winRect(1,3)/2) (Cfg.winRect(1,4)/2)],1); % change 1 to 0 to draw square dots - Screen('DrawingFinished', Cfg.win); % Tell PTB that no further drawing commands will follow before Screen('Flip') - end - - r_out = find(r > rmax | r < rmin | rand(ExpParameters.ndots,1) < ExpParameters.f_kill/100); % dots to reposition if they are outside the aperture - nout = length(r_out); - - if nout && ~mod(i/(nframes/4),2) - r(r_out) = rmax * sqrt(rand(nout,1)); - r(r 0); % Remove zero elements from responseKey, responseTime, & targetTime - responseTime = responseTime(responseTime > 0); - targetTime = targetTime(targetTime > 0); - - - - %% Save a mat Log file - % Onsets & durations are saved in seconds. - save(['logFileFull_',sub_name,'.mat']); - save(['logFile_',sub_name,'.mat'], 'names','onsets','durations','ends','targets','responseTime','responseKey','targetTime','Experiment_duration'); - - - %% FUNCTION - % close Serial Port ---- VERY IMPORTANT NOT FORGET - if strcmp(Cfg.Device,'Scanner') - CloseSerialPort(SerPor); - end - - %% Shutdown Procedures - myTotalSecs=GetSecs; - Experiment_duration = myTotalSecs - experimentStartTime; - - -catch - % If code crashes, close the screen and display the last error - sca; - ShowCursor; -% clear Screen; - error(lasterror) % show default error -end \ No newline at end of file diff --git a/Visual-loc_radial/subfun/ExpDesign.m b/Visual-loc_radial/subfun/ExpDesign.m deleted file mode 100755 index ac5c890..0000000 --- a/Visual-loc_radial/subfun/ExpDesign.m +++ /dev/null @@ -1,63 +0,0 @@ -function [ExpParameters] = ExpDesign(ExpParameters) - -% % % [names,targets,condition] - -% This function creates the design for the visual localizer. It takes as input the number -% of trails of each condition and the range of targets desired inside the blocks. -% -% eg. experimental_design(2,[2 4]) - -% Set to 1 for a visualtion of the trials design order -displayFigs = 0; - -% Set variables here for a dummy test of this function -if nargin<1 - ExpParameters.nrTrials = 2; - ExpParameters.range_targets = [2 4]; - ExpParameters.possibleConditions = {'static', 'motion'}; -end - -% Balance trials and conditions -% the blocks are consequtive static and motion blocks (which gives better results than randomised). - -% Assign the conditions -ExpParameters.condition = repmat(ExpParameters.possibleConditions, 1, ExpParameters.nrTrials); -ExpParameters.nrBlocks= length(ExpParameters.condition); - -% Get the index of each condition -staticIndex = find(strcmp(ExpParameters.condition,'static')) ; -motionIndex = find(strcmp(ExpParameters.condition,'motion')) ; - -% Assign the targets for each condition, get random number of targets for one condition -ExpParameters.target_perCondition = randi(ExpParameters.range_targets, 1, ExpParameters.nrTrials); - -% Assign the num of targets for each condition after shuffling -ExpParameters.targets = zeros(1, ExpParameters.nrBlocks); -ExpParameters.targets(staticIndex) = Shuffle(ExpParameters.target_perCondition); -ExpParameters.targets(motionIndex) = Shuffle(ExpParameters.target_perCondition); - -% Give the blocks the names with condition -ExpParameters.names=cell(ExpParameters.nrBlocks,1); - -for block_nr = 1:ExpParameters.nrBlocks - if strcmp(ExpParameters.condition(block_nr),'static') - ExpParameters.names(block_nr) = {'static'}; - elseif strcmp(ExpParameters.condition(block_nr),'motion') - ExpParameters.names(block_nr) = {'motion'}; - end -end - -%% Visualize the design matrix - -if displayFigs - uniqueNames = unique(ExpParameters.names); - - Ind= zeros(length(ExpParameters.names),length(uniqueNames)); - for i=1:length(uniqueNames) - CondInd(:,i) = find(strcmp(ExpParameters.names,ExpParameters.names{i})) ; - Ind(CondInd(:,i),i)=1 ; - end - - imagesc(Ind) - set(gca,'XTick',1:length(unique(ExpParameters.names')),'XTickLabel',unique(ExpParameters.names')) -end diff --git a/Visual-loc_radial/subfun/InitPTB.m b/Visual-loc_radial/subfun/InitPTB.m deleted file mode 100644 index 74e175c..0000000 --- a/Visual-loc_radial/subfun/InitPTB.m +++ /dev/null @@ -1,77 +0,0 @@ -function [Cfg] = InitPTB(Cfg) - -% check for OpenGL compatibility, abort otherwise: -AssertOpenGL; - -% Make sure keyboard mapping is the same on all supported operating systems -% Apple MacOS/X, MS-Windows and GNU/Linux: -KbName('UnifyKeyNames'); - -% Hide the mouse cursor: -HideCursor; - -% Don't echo keypresses to Matlab window -ListenChar(2); - -% Do dummy calls to GetSecs, WaitSecs, KbCheck to make sure -% they are loaded and ready when we need them - without delays -% in the wrong moment: -KbCheck; -WaitSecs(0.1); -GetSecs; - -% Open a fullscreen, onscreen window with gray background. Enable 32bpc -% floating point framebuffer via imaging pipeline on it. -PsychImaging('PrepareConfiguration'); - -% Intialize PsychPortAudio -InitializePsychSound(1); - -% init PTB with different options in concordance to the Debug Parameters -if Cfg.Debug - - % set to one because we don not care about time - Screen('Preference', 'SkipSyncTests', 2); - Screen('Preference', 'Verbosity', 0); - Screen('Preferences', 'SuppressAllWarnings', 2); - - if Cfg.TestingSmallScreen - [Cfg.win, Cfg.winRect] = PsychImaging('OpenWindow', Cfg.Screen, Cfg.Background_color, [0,0, 480, 270]); - else - PsychDebugWindowConfiguration - [Cfg.win, Cfg.winRect] = PsychImaging('OpenWindow', Cfg.Screen, Cfg.Background_color); - end - -else - Screen('Preference','SkipSyncTests', 0); - [Cfg.win, Cfg.winRect] = PsychImaging('OpenWindow', Cfg.Screen, Cfg.Background_color); - -end - -% Set priority for script execution to realtime priority: -Priority(MaxPriority(Cfg.win)); - -if strcmp(Cfg.stim_position,'Scanner') - Cfg.winRect(1,4) = Cfg.winRect(1,4)*2/3; -end - -% Select specific text font, style and size: -Screen('TextFont',Cfg.win, Cfg.TextFont ); -Screen('TextSize',Cfg.win, Cfg.TextSize); -Screen('TextStyle', Cfg.win, Cfg.TextStyle); - -% Get the Center of the Screen -Cfg.center = [Cfg.winRect(3), Cfg.winRect(4)]/2; - -% Query frame duration -Cfg.ifi = Screen('GetFlipInterval', Cfg.win); -Cfg.monRefresh = 1/Cfg.ifi; - -% Enable alpha-blending, set it to a blend equation useable for linear -% superposition with alpha-weighted source. -Screen('BlendFunction', Cfg.win, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - -% Initially sync us to VBL at start of animation loop. -Cfg.vbl = Screen('Flip', Cfg.win); - -end diff --git a/Visual-loc_radial/subfun/UserInputs.m b/Visual-loc_radial/subfun/UserInputs.m deleted file mode 100644 index 5ed6968..0000000 --- a/Visual-loc_radial/subfun/UserInputs.m +++ /dev/null @@ -1,23 +0,0 @@ -function [subjectName, runNumber, sessionNumber] = UserInputs() - -% Get Subject Name, run number and session number -subjectName = input('Enter Subject Name: ','s'); -if isempty(subjectName) - subjectName = 'trial'; -end - -runNumber = input('Enter the run Number: ','s'); -if isempty(runNumber) - runNumber = 'trial'; -end - -sessionNumber = input('Enter the session Number: ','s'); -if isempty(sessionNumber) - sessionNumber = 'trial'; -end - -if exist(fullfile(pwd, '..', 'logfiles',[subjectName,'_run_',num2str(runNumber),num2str(sessionNumber),'.mat']),'file')>0 - error('This file is already present in your logfiles. Delete the old file or rename your run!!') -end - -end \ No newline at end of file diff --git a/Visual-loc_radial/subfun/assignTargets_insideBlock.m b/Visual-loc_radial/subfun/assignTargets_insideBlock.m deleted file mode 100755 index 04b6d35..0000000 --- a/Visual-loc_radial/subfun/assignTargets_insideBlock.m +++ /dev/null @@ -1,47 +0,0 @@ -function targets_inside_block = assignTargets_insideBlock (nframes,blockDur,ifi,nr_targets) -% function gives as output the targets locations inside each block -% The target locations are expressed in frame number inside the block - -% Seconds to avoid at the beginning and end of each quadrant border (See below) -secs_avoid_inQuad= 0.5; -%blockDur = 16; -%ifi=0.16 ; - -% make a zero vector with the number of the frames inside the block -targets_inside_block = zeros(1,nframes); - -% Define borders inside the block to divide it into 4 quadrants: -%the 0,25,50,75, & 100% border of the block. - -quadrant_borders= [ 0 blockDur*0.25 - blockDur*0.25 blockDur*0.5 - blockDur*0.5 blockDur*0.75 - blockDur*0.75 blockDur]; - -%nr_targets=3; -%nr_targets = randi(4,1,1) - -%If the number of targets is less than four, pick randomly n quadrants, -%where n is the number of targets in this block -if nr_targets<4 - chosen_borders=randsample(4,nr_targets); - quadrant_borders = quadrant_borders(chosen_borders,:); -end - -% for the targets (in each quadrants), pick random location for the targets -% (frames) while keeping in mind to avoid the first 0.5 secs and the last -% 0.5 secs in the quadrant, and thats to avoid very close targets in -% consequtive quadrants. -for z=1:length(quadrant_borders(:,1)) % For each chosen quadrant - borders_interval = quadrant_borders(z,:); % Get the quadrant borders - target_possible = [floor((borders_interval(1)+secs_avoid_inQuad)/ifi) ...% Then, find the possible frames where the targets can exist - floor((borders_interval(2)-secs_avoid_inQuad)/ifi)]; - - target_indices =randi([target_possible(1) target_possible(2)],1,1); % pick a random frame within the allowed border (from the previously defined possible frames) - - for i=target_indices:target_indices+2 % Assign a value of 1 to the frames where the target was randomly chosen - targets_inside_block(i)=1; % Make the assigment for 3 consequetive frames, so we can have a red dot of - end % 3 flip intervals (3x0.016= 0.048 secs) "This way, it will not be too quick" -end - -%imagesc(targets_inside_block) % To visualize the targets location inside one block diff --git a/Visual-loc_radial/subfun/pressSpace4me.m b/Visual-loc_radial/subfun/pressSpace4me.m deleted file mode 100644 index ec19884..0000000 --- a/Visual-loc_radial/subfun/pressSpace4me.m +++ /dev/null @@ -1,20 +0,0 @@ -function pressSpace4me - -fprintf('\npress space to continue\n'); - -while 1 - - WaitSecs(0.1); - - [~, keyCode, ~] = KbWait(-1); - - responseKey = KbName(find(keyCode)); - if strcmp(responseKey,'space') - fprintf('starting the experiment....\n'); - break - end - -end - -end - diff --git a/Visual-loc_radial/z_old_steph/CloseSerialPort.m b/Visual-loc_radial/z_old_steph/CloseSerialPort.m deleted file mode 100755 index dcd8775..0000000 --- a/Visual-loc_radial/z_old_steph/CloseSerialPort.m +++ /dev/null @@ -1,9 +0,0 @@ -%% Close Serial Port -function []= CloseSerialPort(SerPor) - - %fprintf (1,'%s\n', 'CloseSeriaPort'); - fprintf(1, 'STOPING SERIAL PORT COM1 (BAUD RATE: 11520) ... '); - fclose(SerPor); - fprintf('DONE\n'); - -end diff --git a/Visual-loc_radial/z_old_steph/MT_TakeSerialButtonPerFrame.m b/Visual-loc_radial/z_old_steph/MT_TakeSerialButtonPerFrame.m deleted file mode 100755 index b75e3b5..0000000 --- a/Visual-loc_radial/z_old_steph/MT_TakeSerialButtonPerFrame.m +++ /dev/null @@ -1,30 +0,0 @@ -function [sbutton,secs]= MT_TakeSerialButtonPerFrame(SerPor) -% Taken from original function TakeSerialButton -%Adapted by mohamed to check button press per Frame of dot motion -%and return as an output the button press and time of presses. -%Changed the while loop to an if condition, and gave a value of 0 to secs -%and sbutton if SerPor.BytesAvailable is not true. - %fprintf (1,'%s\n', 'TakeSerialButton') - - sbutton=0; - - if (SerPor.BytesAvailable) - if sbutton==0 - sbutton = str2num(fscanf(SerPor,'%c',1)); % read serial buffer - secs = GetSecs; % CB added this line, to take the time - if sbutton==5 % check if it is a MR trigger - sbutton = 0; % if trigger, ignored - secs = 0; - end - else - junk = fscanf(SerPor,'%c',1); - secs = 0; - sbutton = 0; - end - else - secs = 0; - sbutton = 0; - end - -end - diff --git a/Visual-loc_radial/z_old_steph/MT_portAndTrigger.m b/Visual-loc_radial/z_old_steph/MT_portAndTrigger.m deleted file mode 100755 index 4b0335c..0000000 --- a/Visual-loc_radial/z_old_steph/MT_portAndTrigger.m +++ /dev/null @@ -1,14 +0,0 @@ -function [SerPor] = MT_portAndTrigger -% Opens Serial Port and Waits for the Trigger - -SerPor = OpenSerialPort(); % open Serial Port - -% FUNCTION -% wait N MR_trigger with timeout of 10 sec. -Ntrigger = 5; % No.of trigger expected before starting - -TimeOutNtrigger_ms = 20000; % 20 sec. -- it is possible "inf" for infinite time - -Wait_N_SerialTrigger(SerPor, Ntrigger, TimeOutNtrigger_ms); - -end \ No newline at end of file diff --git a/Visual-loc_radial/z_old_steph/Main_MR_Serial_Port.m b/Visual-loc_radial/z_old_steph/Main_MR_Serial_Port.m deleted file mode 100755 index 867672f..0000000 --- a/Visual-loc_radial/z_old_steph/Main_MR_Serial_Port.m +++ /dev/null @@ -1,46 +0,0 @@ -% Main_MR_Serial_Port -% LUMINA mode: ASCII/MEDx -% LUMINA Speed: 115200 - -clear all; -close all; - -% FUNCTION -% open Serial Port "SerPor" - COM1 (BAUD RATE: 11520) -SerPor=OpenSerialPort(); % open Serial Port - - -% FUNCTION -% wait N MR_trigger with timeout of 10 sec. -Ntrigger=5; % No.of trigger expected before starting -TimeOutNtrigger_ms=20000; % 20 sec. -- it is possible "inf" for infinite time -Wait_N_SerialTrigger(SerPor, Ntrigger, TimeOutNtrigger_ms); - - -% FUNCTION -% wait one serial button with timeout of 20 sec. -% sbutton=1 if pressed the button blue -% sbutton=2 if pressed the button yellow -% sbutton=3 if pressed the button green -% sbutton=4 if pressed the button red -% sbutton=6 if not pressed any button -% RMI trigger is ignored -% ResTime is the response time in sec. - -TimeOutButton_ms=20000; % 20 sec. -% YOUR STIMULATION -% YOUR STIMULATION -% YOUR STIMULATION -[sbutton, ResTime]=WaitOneSerialButton(SerPor,TimeOutButton_ms); -%fprintf (1,'%s %d\n', 'Button = ', sbutton); -%fprintf (1,'%s %.3f\n', 'Response time = ', ResTime); - - -% FUNCTION -% close Serial Port ---- VERY IMPORTANT NOT FORGET -CloseSerialPort(SerPor); - - - - - diff --git a/Visual-loc_radial/z_old_steph/Onsets_trial.mat b/Visual-loc_radial/z_old_steph/Onsets_trial.mat deleted file mode 100755 index 35f5952438b397d50acb357a3d5c4e55a9e912ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 395 zcmeZu4DoSvQZUssQ1EpO(M`+DN!3vZ$Vn_o%P-2c0*X0%nwjV*I2WZRmZYXA#H}NExa-1OE>F^tBF;|x#HN^8Rj<&%7Tn{ zfg67V!}%Nc9JzBPN#QK}5iyTn5gT44I~(~koH~D2|KyqT%JKDuo=Ki*M$F6%$7gfO F002<`h!_9> diff --git a/Visual-loc_radial/z_old_steph/OpenSerialPort.asv b/Visual-loc_radial/z_old_steph/OpenSerialPort.asv deleted file mode 100755 index a9f9b43..0000000 --- a/Visual-loc_radial/z_old_steph/OpenSerialPort.asv +++ /dev/null @@ -1,15 +0,0 @@ -%% Open Serial Port - -function [SerPor]= OpenSerialPort() - - %fprintf (1,'%s\n', 'OpenSeriaPort'); - SerPor = serial('COM1', 'BaudRate', 115200 ); - set(SerPor,'InputBufferSize',128); - warning off all; %THIS IS NASTY!!! We do this because of timeout warning !!!!!! - fprintf(1, 'STARTING SERIAL PORT COM1 (BAUD RATE: 115200) ... '); - fopen(SerPor); - fprintf('DONE\n'); - %SerPor.Terminator = ''; - %SerPor.BytesAvailable; - -end diff --git a/Visual-loc_radial/z_old_steph/OpenSerialPort.m b/Visual-loc_radial/z_old_steph/OpenSerialPort.m deleted file mode 100755 index a9f9b43..0000000 --- a/Visual-loc_radial/z_old_steph/OpenSerialPort.m +++ /dev/null @@ -1,15 +0,0 @@ -%% Open Serial Port - -function [SerPor]= OpenSerialPort() - - %fprintf (1,'%s\n', 'OpenSeriaPort'); - SerPor = serial('COM1', 'BaudRate', 115200 ); - set(SerPor,'InputBufferSize',128); - warning off all; %THIS IS NASTY!!! We do this because of timeout warning !!!!!! - fprintf(1, 'STARTING SERIAL PORT COM1 (BAUD RATE: 115200) ... '); - fopen(SerPor); - fprintf('DONE\n'); - %SerPor.Terminator = ''; - %SerPor.BytesAvailable; - -end diff --git a/Visual-loc_radial/z_old_steph/V_hMT_localizer.m b/Visual-loc_radial/z_old_steph/V_hMT_localizer.m deleted file mode 100755 index da486ea..0000000 --- a/Visual-loc_radial/z_old_steph/V_hMT_localizer.m +++ /dev/null @@ -1,417 +0,0 @@ -%function mirror_runMTLocalizer - -% 7 trials : 310.8743 sec = 5.18 minutes -% 310.8743 = 156 TR + 4 trigger = 160 TRs -clear all; -clc - -%% To correct for the y-axis problem inside the scanner -% where the lower 1/3 of the screen is not appearing because of coil -% indicate which device the script is running on, on PC, the middle of the -% y axis will be the middle of the screen, on the Scanner, the middle of -% y-axis will be the middle of the upper 2/3 of the screen, because the -% lower 1/3 is not visible due to the coil in the scanner. - -%device = 'Scanner'; -device = 'PC'; - -fprintf('Connected Device is %s \n\n',device); - -% Original Script Written by Sam Weiller to localize MT+/V5 -% Adapted by M.Rezk -%% Start me up -% Get the subject Name -sub_name = input('Subject Name: ','s'); - if isempty(sub_name) - sub_name = 'trial'; - end - -disp('MT Localizer') - -%% Experiment Parametes -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -initial_wait = 2; % seconds to have a blank screen at the beginning, the scans will be discarded until % the magnetic field is homogenous -blockDur = 16; % Block duration [should be a multiple of osc (below)] -ibi = 8; % Inter-block duration in seconds (time between blocks) -nr_trials = 7; % Number of trials , where 1 trial = 1 block of all conditions (static and motion) -range_targets = [2 4]; % range of number of targets in each block (from 2 to 5 targets in each block) -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Number of cycles per block -nr_cycles = blockDur/2 ; % 1 Cycle = one inward and outward motion together -% function "experimental_design" while assign the blocks, conditions, and -% the number of targets that will be used in the motion localizer -[names,targets,condition] = experimental_design(nr_trials,range_targets); -numBlocks = length(names); % Create a variable with the number of blocks in the whole experiment - -%% PTB Setup -screenNumber = max(Screen('Screens')); -%screenNumber = 0; -Screen('Preference', 'SkipSyncTests', 2); -[w, winRect, xMid, yMid] = startPTB(screenNumber, 1, [128 128 128]); -HideCursor; - -%% Color indeces, and Screen parameters and inter-flip interval. -% Color indices -white = WhiteIndex(screenNumber); -black = BlackIndex(screenNumber); -grey = ceil((white+black)/2); - -% Flip interval and screen size -ifi = Screen('GetFlipInterval', w); % Get the flip interval -[tw, th] = Screen('WindowSize', w); - -%% Welcome screen -Screen('TextFont',w, 'Courier New'); -Screen('TextSize',w, 20); -Screen('TextStyle', w, 1); -DrawFormattedText(w,'Press for RED fixation circle',... - 'center', 'center', black); -Screen('Flip', w); -[KeyIsDown, pend, KeyCode]=KbCheck; -KbWait; -Screen('Flip', w); - -WaitSecs(0.25); - -%% FUNCTION - -if strcmp(device,'PC') - DrawFormattedText(w,'Waiting For Trigger',... - 'center', 'center', black); - Screen('Flip', w); - - % press key - KbWait(); - KeyIsDown=1; - while KeyIsDown>0 - [KeyIsDown, ~, ~]=KbCheck; - end - - % open Serial Port "SerPor" - COM1 (BAUD RATE: 11520) -elseif strcmp(device,'Scanner') - DrawFormattedText(w,'Waiting For Trigger','center', 'center', black); - Screen('Flip', w); - SerPor = MT_portAndTrigger; - Screen('Flip', w); -end - -%% Experiment Start (Main Loop) -experimentStartTime = GetSecs; - -%% To correct for the y-axis problem inside the scanner -if strcmp(device,'Scanner') - adjusted_yAxis = 2/3*th; % where the lower 1/3 of the screen is not appearing because of coil -elseif strcmp(device,'PC') - adjusted_yAxis = th; % y-axis is the same, no changes -end - -%% Scanning Parameters -%(very rough) setting of oscillation frequency -osc = .8; % Oscillating in seconds - -% Number of frames for one block -nframes = floor(blockDur/ifi); -while mod(nframes,nr_cycles)~=0 % make sure the nframes are even number - nframes = nframes-1; % to be able to re-assign dots in the static condition (to perform divison calculation) -end - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%mirror_width= 42; % Width (x-axis) of the mirror (in cm) -mon_width = 42; % horizontal dimension of viewable screen (cm) -v_dist = 134; % viewing distance from the mirror (cm) "in this script we use mirror" -dot_speed = 4; % dot speed (deg/sec) -ndots = 120; % number of dots -min_d = 0.1; % minumum radius of annulus (degrees) -max_d = 4; %winRect(3)/(3*2) % maximum radius of annulus (degrees) -%fix_to_rad = 10 ; % distance (in degrees) between fixation and maximum radius of annulus -dot_w = 0.1; % width of dot (deg) -fix_r = 0.03; % radius of fixation point (deg) -f_kill = 0.05; % fraction of dots to kill each frame (limited lifetime) -differentcolors = 0; % Use a different color for each point if == 1. Use common color white if == 0. -differentsizes = 0; % Use different sizes for each point if >= 1. Use one common size if == 0. -waitframes = 1; % Show new dot-images at each waitframes'th monitor refresh. -reallocate_staticDots = 0 ; % 0 = static dots will stay in the same position , 1 = static dots will be - % reallocated in each cycle (2 seconds) -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -ppd = pi * (winRect(3)-winRect(1)) / atan(mon_width/v_dist/2) / 360; % pixels per degree -%[mirrorPixelPerDegree] = mirror2Pixels (winRect,v_dist,mirror_width) ; % Calculate pixel per degree on the mirror surface -pfs = (ppd * dot_speed) / (1/ifi); % dot speed (pixels/frame) -s = dot_w * ppd; % dot size (pixels) -rmax = max_d *ppd; % maximum radius of annulus (1/4th of the x-axis) -rmin = min_d * ppd; % minimum radius of annulus -r = rmax * sqrt(rand(ndots,1)); % r -r(r0) - s=(1+rand(1, ndots)*(differentsizes-1))*s; -end; - - -%% Fixation Cross -cfg.fixCrossDimPix = 10; % Set the length of the lines (in Pixels) of the fixation cross -cfg.lineWidthPix = 4; % Set the line width (in Pixels) for our fixation cross -cfg.fixationCross_color = [0 0 0] ; -xCoords = [-cfg.fixCrossDimPix cfg.fixCrossDimPix 0 0]; -yCoords = [0 0 -cfg.fixCrossDimPix cfg.fixCrossDimPix]; -cfg.allCoords = [xCoords; yCoords]; -cfg.center = [tw, adjusted_yAxis]/2; -%% Experiment start -% The experment will wait (initial_wait) Secs before running the stimuli -Screen('DrawLines', w, cfg.allCoords,cfg.lineWidthPix, cfg.fixationCross_color , [cfg.center(1) cfg.center(2)], 1);% draw fixation dot (flip erases it) -blank_onset=Screen('Flip', w); -WaitSecs('UntilTime', blank_onset + initial_wait); - -targetTime = []; -responseKey = []; -responseTime = []; - -for blocks = 1:numBlocks - timeLogger.block(blocks).startTime = GetSecs - experimentStartTime; % Get the start time of the block - timeLogger.block(blocks).condition = condition(blocks); % Get the condition of the block (motion or static) - timeLogger.block(blocks).names = names(blocks); % Get the name of the block (l_motion or r_motion or r/l_static) - - - %% Motion blocks - if strcmp(condition(blocks),'motion') % Check if this block is a motion condition - motionStartLog = GetSecs; - motionEnd = motionStartLog + blockDur; % Define when the animation loop will stop - - %Define the targets for this block - targets_inside_block = assignTargets_insideBlock (nframes,blockDur,ifi,targets(blocks)); - vbl = Screen('Flip', w, 0, 1); - - % -------------- - % animation loop - % -------------- - - for i = 1:nframes - - if targets_inside_block(i)==0; % if it is not a target frame - Screen('DrawLines', w, cfg.allCoords,cfg.lineWidthPix, cfg.fixationCross_color , [cfg.center(1) cfg.center(2)], 1); % draw white fixation cross (flip erases it) - targetTime(end+1)=0; - elseif targets_inside_block(i)==1; - Screen('DrawLines', w, cfg.allCoords,cfg.lineWidthPix, [255 0 0] , [cfg.center(1) cfg.center(2)], 1); % draw RED fixation cross (flip erases it) [TARGET] - targetTime(end+1)=GetSecs-experimentStartTime; - end - - %% Get responseKey and responseTime - % Use KbCheck if using PC , or MT_TakeSerialButtonPerFrame if using fMRI - % Since these are frames, we need to collect the response - % button at each frame to get the response time. - if strcmp(device,'Scanner') - [sbutton,secs] = MT_TakeSerialButtonPerFrame(SerPor); - responseKey(end+1)= sbutton; - responseTime(end+1)= secs - experimentStartTime; - elseif strcmp(device,'PC') - [KeyIsDown,PressedSecs,KeyCode] = KbCheck(-1); - if KeyIsDown - responseKey(end+1)= 1 ; - responseTime(end+1)= PressedSecs - experimentStartTime; - elseif ~KeyIsDown - responseKey(end+1)= 0; - responseTime(end+1)= 0; - end - end - - if GetSecs <= motionEnd - if i>1 - - %Screen('DrawDots', w, xymatrix, s, colvect, [(tw/2+(direction(blocks)*(tw/4+rmax))) (adjusted_yAxis/2)],1); % change 1 to 0 to draw square dots - Screen('DrawDots', w, xymatrix, s, colvect, [(tw/2) (adjusted_yAxis/2)],1); % change 1 to 0 to draw square dots - Screen('DrawingFinished', w); % Tell PTB that no further drawing commands will follow before Screen('Flip') - end - - mdir = ones(ndots,1) * mod(ceil(i/(nframes/(nr_cycles*2))),2)*2-1; - dr = pfs * mdir; % change in radius per frame (pixels) - dxdy = [dr dr] .* cs; % change in x and y per frame (pixels) - - xy = xy + dxdy; % move dots - r = r + dr; % update polar coordinates too - - r_out = find(r > rmax | r < rmin | rand(ndots,1) < f_kill); % dots to reposition if they are outside the aperture - nout = length(r_out); - - if nout - r(r_out) = rmax * sqrt(rand(nout,1)); - r(r1 %&& rem(i,10)~=0 - - Screen('DrawDots', w, xymatrix, s, colvect, [(tw/2) (adjusted_yAxis/2)],1); % change 1 to 0 to draw square dots - Screen('DrawingFinished', w); % Tell PTB that no further drawing commands will follow before Screen('Flip') - end - - r_out = find(r > rmax | r < rmin | rand(ndots,1) < f_kill/100); % dots to reposition if they are outside the aperture - nout = length(r_out); - - if nout && ~mod(i/(nframes/4),2) - r(r_out) = rmax * sqrt(rand(nout,1)); - r(r 0); % Remove zero elements from responseKey, responseTime, & targetTime -responseTime = responseTime(responseTime > 0); -targetTime = targetTime(targetTime > 0); - -%% Shutdown Procedures -ShowCursor; -clear screen; -myTotalSecs=GetSecs; -Experiment_duration = myTotalSecs - experimentStartTime; - -%% Save a mat Log file -% Onsets & durations are saved in seconds. -save(['logFileFull_',sub_name,'.mat']); -save(['logFile_',sub_name,'.mat'], 'names','onsets','durations','ends','targets','responseTime','responseKey','targetTime','Experiment_duration'); - - -%% FUNCTION -% close Serial Port ---- VERY IMPORTANT NOT FORGET -if strcmp(device,'Scanner') - CloseSerialPort(SerPor); -end - diff --git a/Visual-loc_radial/z_old_steph/Wait_N_SerialTrigger.m b/Visual-loc_radial/z_old_steph/Wait_N_SerialTrigger.m deleted file mode 100755 index 706548a..0000000 --- a/Visual-loc_radial/z_old_steph/Wait_N_SerialTrigger.m +++ /dev/null @@ -1,31 +0,0 @@ -%% Wait_N_SerialTrigger - -function Wait_N_SerialTrigger(SerPor, Ntrigger, TimeOutMilliSeconds) - - % empty the buffer of the serial port - while (SerPor.BytesAvailable) - junk = fscanf(SerPor,'%c',1); - end - - fprintf (1,'%s%d%s\n', 'Wait ', Ntrigger, ' Serial Trigger'); - contflag = 0; - tStart = GetSecs; - while contflag TimeOutMilliSeconds/1000 - fprintf (1,'%s\n', 'Return for TIMEOUT!!!') - return; - end - end - end - - diff --git a/Visual-loc_radial/z_old_steph/assignTargets_insideBlock.m b/Visual-loc_radial/z_old_steph/assignTargets_insideBlock.m deleted file mode 100755 index 04b6d35..0000000 --- a/Visual-loc_radial/z_old_steph/assignTargets_insideBlock.m +++ /dev/null @@ -1,47 +0,0 @@ -function targets_inside_block = assignTargets_insideBlock (nframes,blockDur,ifi,nr_targets) -% function gives as output the targets locations inside each block -% The target locations are expressed in frame number inside the block - -% Seconds to avoid at the beginning and end of each quadrant border (See below) -secs_avoid_inQuad= 0.5; -%blockDur = 16; -%ifi=0.16 ; - -% make a zero vector with the number of the frames inside the block -targets_inside_block = zeros(1,nframes); - -% Define borders inside the block to divide it into 4 quadrants: -%the 0,25,50,75, & 100% border of the block. - -quadrant_borders= [ 0 blockDur*0.25 - blockDur*0.25 blockDur*0.5 - blockDur*0.5 blockDur*0.75 - blockDur*0.75 blockDur]; - -%nr_targets=3; -%nr_targets = randi(4,1,1) - -%If the number of targets is less than four, pick randomly n quadrants, -%where n is the number of targets in this block -if nr_targets<4 - chosen_borders=randsample(4,nr_targets); - quadrant_borders = quadrant_borders(chosen_borders,:); -end - -% for the targets (in each quadrants), pick random location for the targets -% (frames) while keeping in mind to avoid the first 0.5 secs and the last -% 0.5 secs in the quadrant, and thats to avoid very close targets in -% consequtive quadrants. -for z=1:length(quadrant_borders(:,1)) % For each chosen quadrant - borders_interval = quadrant_borders(z,:); % Get the quadrant borders - target_possible = [floor((borders_interval(1)+secs_avoid_inQuad)/ifi) ...% Then, find the possible frames where the targets can exist - floor((borders_interval(2)-secs_avoid_inQuad)/ifi)]; - - target_indices =randi([target_possible(1) target_possible(2)],1,1); % pick a random frame within the allowed border (from the previously defined possible frames) - - for i=target_indices:target_indices+2 % Assign a value of 1 to the frames where the target was randomly chosen - targets_inside_block(i)=1; % Make the assigment for 3 consequetive frames, so we can have a red dot of - end % 3 flip intervals (3x0.016= 0.048 secs) "This way, it will not be too quick" -end - -%imagesc(targets_inside_block) % To visualize the targets location inside one block diff --git a/Visual-loc_radial/z_old_steph/experimental_design.m b/Visual-loc_radial/z_old_steph/experimental_design.m deleted file mode 100755 index 292a3ec..0000000 --- a/Visual-loc_radial/z_old_steph/experimental_design.m +++ /dev/null @@ -1,52 +0,0 @@ -function [names,targets,condition] = experimental_design(nr_trials,range_targets) -% This function creates the design for the experiment. It takes as input the number -% of trails of each condition and the range of targets wanted inside the blocks. -% -%eg. experimental_design(2,[2 4]) - -% nr_trials=2; -% range_targets = [2 4]; -%% Define the experiment and balance trials, and conditions -% the blocks are consequtive static and motion blocks (Gives better results than randomised). - -%% Assign the conditions -condition= repmat({'static','motion'}, 1,nr_trials); -nr_blocks= length(condition); - -%% Get the index of each condition -staticIndex = find(strcmp(condition,'static')) ; -motionIndex = find(strcmp(condition,'motion')) ; - -%% Assign the targets for each condition - -% Get random number of targets for one condition -%target_perCondition = randi(range_targets,1,nr_trials/2); -target_perCondition = randi(range_targets,1,nr_trials); - -% Assign the num of targets for each condition after shuffling -targets=zeros(1,nr_blocks); -targets(staticIndex) = Shuffle(target_perCondition) ; -targets(motionIndex) = Shuffle(target_perCondition) ; - -%% Give the blocks the names with condition -names=cell(nr_blocks,1); - -for block_nr = 1:nr_blocks - if strcmp(condition(block_nr),'static') - names(block_nr)={'static'}; - elseif strcmp(condition(block_nr),'motion') - names(block_nr)={'motion'}; - end -end - -%% Visualize the design matrix -% uniqueNames = unique(names) ; -% -% Ind= zeros(length(names),length(uniqueNames)) ; -% for i=1:length(uniqueNames) -% CondInd(:,i) = find(strcmp(names,names{i})) ; -% Ind(CondInd(:,i),i)=1 ; -% end -% -% imagesc(Ind) -% set(gca,'XTick',1:length(unique(names')),'XTickLabel',unique(names')) diff --git a/Visual-loc_radial/z_old_steph/mirror2Pixels.m b/Visual-loc_radial/z_old_steph/mirror2Pixels.m deleted file mode 100755 index 1a07a4f..0000000 --- a/Visual-loc_radial/z_old_steph/mirror2Pixels.m +++ /dev/null @@ -1,23 +0,0 @@ -function [mirrorPixelPerDegree] = mirror2Pixels (winRect,v_dist,mirror_width) -%This function calculated the mirror pixels per degree and the speed of the -%dots in pixels. - -imageHorizDim_InsideMirror = mirror_width; - -% Get the screen resolution on the x-axis -screen_resolution= winRect(3); - -mirrorDistance = v_dist; % in cm - -% Law to covert radians to degrees -% Degrees = 180 * radians / pi - -% Law to calculate visual angles: V = 2*atan(S/2D) -% V = 2* atan(imageHorizDim_InsideMirror/(2*mirrorDistance)) - -%Calculate the visual angle of the viewed mirror. -%(the part where the monitor is visible)) -V = 2* (180 * (atan(imageHorizDim_InsideMirror/(2*mirrorDistance)) / pi)); - -% Calculate the pixels per degree on the mirror surface. -mirrorPixelPerDegree = screen_resolution / V ; diff --git a/Visual-loc_radial/z_old_steph/startPTB.m b/Visual-loc_radial/z_old_steph/startPTB.m deleted file mode 100755 index e8ab9a0..0000000 --- a/Visual-loc_radial/z_old_steph/startPTB.m +++ /dev/null @@ -1,17 +0,0 @@ -function [w, rect, xc, yc] = startPTB(screenNumber, oGl, color) -if nargin == 0 - oGl = 0; - color = [0 0 0]; -elseif nargin == 1; - color = [0 0 0]; -end; - -%[w rect] = Screen('OpenWindow', screenNumber, color,[0 0 1280 1024]); -[w, rect] = Screen('OpenWindow', screenNumber, color); -xc = rect(3)/2; -yc = rect(4)/2; - -if oGl == 1 - AssertOpenGL; - Screen('BlendFunction', w, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, [1 1 1 1]); -end; From 87e4bd4af65e2a1b9f7d11057a7f5992b8627c2c Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 13 Aug 2020 17:25:55 +0200 Subject: [PATCH 2/2] update after set up in liege --- initEnv.m | 4 ++-- lib/CPP_PTB | 2 +- setParameters.m | 43 +++++++++++++++++++++------------------- subfun/expDesign.m | 12 ++++++----- visualLocTranslational.m | 11 ++++++++-- 5 files changed, 42 insertions(+), 30 deletions(-) diff --git a/initEnv.m b/initEnv.m index c59cc15..2c26a50 100644 --- a/initEnv.m +++ b/initEnv.m @@ -15,7 +15,7 @@ function initEnv octaveVersion = '4.0.3'; - matlabVersion = '9.1.0'; + matlabVersion = '8.6.0'; if isOctave @@ -88,7 +88,7 @@ function addDependencies() pth = fileparts(mfilename('fullpath')); addpath(genpath(fullfile(pth, 'lib', 'CPP_BIDS', 'src'))); addpath(fullfile(pth, 'lib', 'CPP_PTB')); - addpath(genpath(fullfile(pth, 'lib', 'CPP_PTB', 'src'))); +% addpath(genpath(fullfile(pth, 'lib', 'CPP_PTB', 'src'))); addpath(fullfile(pth, 'subfun')); end diff --git a/lib/CPP_PTB b/lib/CPP_PTB index 8c25300..fe4f16c 160000 --- a/lib/CPP_PTB +++ b/lib/CPP_PTB @@ -1 +1 @@ -Subproject commit 8c253007d4ce30c9c1a5f97dbbe9b0a93c59d0ca +Subproject commit fe4f16c22e173709a84b6144588cbffa080e5a96 diff --git a/setParameters.m b/setParameters.m index 114e1e6..04fba09 100644 --- a/setParameters.m +++ b/setParameters.m @@ -12,16 +12,16 @@ %% Debug mode settings - cfg.debug.do = true; % To test the script out of the scanner, skip PTB sync + cfg.debug.do = false; % To test the script out of the scanner, skip PTB sync cfg.debug.smallWin = false; % To test on a part of the screen, change to 1 - cfg.debug.transpWin = true; % To test with trasparent full size screen + cfg.debug.transpWin = false; % To test with trasparent full size screen cfg.verbose = false; %% Engine parameters - cfg.testingDevice = 'pc'; - cfg.eyeTracker.do = false; + cfg.testingDevice = 'mri'; + cfg.eyeTracker.do = true; cfg.audio.do = false; cfg = setMonitor(cfg); @@ -38,7 +38,7 @@ % cfg.design.motionType = 'radial'; cfg.design.motionType = 'translation'; cfg.design.names = {'static'; 'motion'}; - cfg.design.nbRepetitions = 4; + cfg.design.nbRepetitions = 10; cfg.design.nbEventsPerBlock = 12; % DO NOT CHANGE %% Timing @@ -50,15 +50,15 @@ % block length = (cfg.eventDuration + cfg.ISI) * cfg.design.nbEventsPerBlock % Time between blocs in secs - cfg.timing.IBI = 1.8 * 3; % 8; + cfg.timing.IBI = 1.8; % Time between events in secs - cfg.timing.ISI = 0.1; + cfg.timing.ISI = 0; % Number of seconds before the motion stimuli are presented - cfg.timing.onsetDelay = .1; + cfg.timing.onsetDelay = 0; % Number of seconds after the end all the stimuli before ending the run - cfg.timing.endDelay = .1; + cfg.timing.endDelay = 3.6; - cfg.timing.eventDuration = 0.8; % second + cfg.timing.eventDuration = 0.9; % second %% Visual Stimulation @@ -67,17 +67,17 @@ % Coherence Level (0-1) cfg.dot.coherence = 1; % Number of dots per visual angle square. - cfg.dot.density = .1; + cfg.dot.density = 1; % Dot life time in seconds cfg.dot.lifeTime = 10; % proportion of dots killed per frame cfg.dot.proportionKilledPerFrame = 0; % Dot Size (dot width) in visual angles. - cfg.dot.size = 1; + cfg.dot.size = .2; cfg.dot.color = cfg.color.white; % Diameter/length of side of aperture in Visual angles - cfg.aperture.type = 'circle'; + cfg.aperture.type = 'none'; cfg.aperture.width = []; % if left empty it will take the screen height cfg.aperture.xPos = 0; @@ -92,12 +92,12 @@ cfg.fixation.type = 'cross'; cfg.fixation.colorTarget = cfg.color.red; cfg.fixation.color = cfg.color.white; - cfg.fixation.width = 1; - cfg.fixation.lineWidthPix = 2; + cfg.fixation.width = .5; + cfg.fixation.lineWidthPix = 3; cfg.fixation.xDisplacement = 0; cfg.fixation.yDisplacement = 0; - cfg.target.maxNbPerBlock = 2; + cfg.target.maxNbPerBlock = 1; cfg.target.duration = 0.05; % In secs cfg.extraColumns = {'direction', 'speed', 'target', 'event', 'block', 'keyName'}; @@ -106,7 +106,10 @@ function cfg = setKeyboards(cfg) cfg.keyboard.escapeKey = 'ESCAPE'; - cfg.keyboard.responseKey = {'space', 't'}; + cfg.keyboard.responseKey = {... + 'r', 'g', 'y', 'b', ... + 'd', 'n', 'z', 'e', ... + 't'}; %dnze rgyb cfg.keyboard.keyboard = []; cfg.keyboard.responseBox = []; @@ -119,7 +122,7 @@ function cfg = setMRI(cfg) % letter sent by the trigger to sync stimulation and volume acquisition cfg.mri.triggerKey = 't'; - cfg.mri.triggerNb = 4; + cfg.mri.triggerNb = 0; cfg.mri.repetitionTime = 1.8; @@ -143,7 +146,7 @@ cfg.screen.monitorDistance = 40; % distance from the screen in cm if strcmpi(cfg.testingDevice, 'mri') - cfg.screen.monitorWidth = 50; - cfg.screen.monitorDistance = 40; + cfg.screen.monitorWidth = 25; + cfg.screen.monitorDistance = 95; end end diff --git a/subfun/expDesign.m b/subfun/expDesign.m index f2bd16c..029ba08 100644 --- a/subfun/expDesign.m +++ b/subfun/expDesign.m @@ -58,14 +58,16 @@ % Set variables here for a dummy test of this function if nargin < 1 || isempty(cfg) % cfg.design.motionType = 'translation'; - cfg.design.motionType = 'radial'; + cfg.design.motionType = 'translation'; cfg.design.names = {'static'; 'motion'}; - cfg.design.nbRepetitions = 4; + cfg.design.nbRepetitions = 10; cfg.design.nbEventsPerBlock = 12; cfg.dot.speedPixPerFrame = 4; - cfg.target.maxNbPerBlock = 2; + cfg.target.maxNbPerBlock = 1; displayFigs = 1; end + + fprintf('\n\nCreating design.\n\n') [NB_BLOCKS, NB_REPETITIONS, NB_EVENTS_PER_BLOCK, MAX_TARGET_PER_BLOCK] = getInput(cfg); [~, STATIC_INDEX, MOTION_INDEX] = assignConditions(cfg); @@ -104,7 +106,7 @@ targetDifference = 0; - while any(targetDifference <= 2) + while abs(targetDifference) <= 2 chosenTarget = randsample(2:NB_EVENTS_PER_BLOCK - 1, tmpTarget, false); targetDifference = diff(chosenTarget); end @@ -192,7 +194,7 @@ switch cfg.design.motionType case 'translation' - MOTION_DIRECTIONS = [0 90 180 270]; + MOTION_DIRECTIONS = [0 0 180 180]; case 'radial' STATIC_DIRECTIONS = [666 -666 666 -666]; MOTION_DIRECTIONS = [666 -666 666 -666]; diff --git a/visualLocTranslational.m b/visualLocTranslational.m index 1912a73..7afccb1 100644 --- a/visualLocTranslational.m +++ b/visualLocTranslational.m @@ -33,7 +33,7 @@ %% Init the experiment [cfg] = initPTB(cfg); - cfg.dot.matrixWidth = cfg.screen.winHeight; + cfg.dot.matrixWidth = cfg.screen.winWidth; % Convert some values from degrees to pixels cfg.dot = degToPix('size', cfg.dot, cfg); @@ -107,7 +107,14 @@ thisEvent.keyName = 'n/a'; thisEvent.duration = duration; thisEvent.onset = onset - cfg.experimentStart; - + + % % this value should be in degrees / second in the log file + % % highlights that the way speed is passed around could be + % % simplified. + % % + % thisEvent.speed + % % + % Save the events txt logfile % we save event by event so we clear this variable every loop thisEvent.fileID = logFile.fileID;