Skip to content
createDotInfo_TEST_Dim4_170626.m 6.3 KiB
Newer Older
Julian Kosciessa's avatar
Julian Kosciessa committed
%_______________________________________________________________________
%
% Configuration for running dotsExperiment
% Note that this is the configuration script for a single attribute during
% the training/psychophysics phase of the experiment.
% JQK July 2017 (kosciessa@mpib-berlin.mpg.de)
%_______________________________________________________________________
%
% Output
%
% dotInfo | configuration for random dots experiment (struct)
%
% Input
%
% PM - palmenides structure for adaptive psychophysics
%_______________________________________________________________________
%
function dotInfo = createDotInfo_TEST_Dim4_170626(PM)
    
    dotInfo.trialsPerAtt = PM.numTrials;                                    % amount of trials is fixed by Palmenides
    dotInfo.numOfAtt = 1;                                                   % only one attribute during this test
    dotInfo.totalTrials = dotInfo.trialsPerAtt;
    dotInfo.curAtt = 4;
    dotInfo.dirAttentionRate = .5;                                          % actually not the case here, as no cue is presented, hence: 0
    
    dotInfo.durCue = 0;     % duration of cue
    dotInfo.durPres = .5;   % duration of presentation
    dotInfo.durResp = 2.5;  % duration of question
    dotInfo.durConf = 0;    % duration of confidence
    
    dotInfo.dirSet          = [180, 0]; % dots in left or right direction
    dotInfo.numDotField     = 1; % show a single dot patches on screen
    dotInfo.apXYD           = [0 0 130]; % coordinates and diameter of aperture
    dotInfo.speed           = [50]; % speed of dot motion
    dotInfo.trialtype       = [2 1 1]; % reaction time, not relevant, keyboard
    dotInfo.dotSize         = 3; % dot size in pixels
    dotInfo.maxDotTime      = 2; % maximum duration of moving dots
    dotInfo.fixXY           = [0 0]; % fixation coordinates
    dotInfo.fixDiam         = 2; % fixation diameter
    dotInfo.fixColor        = [255 0 0]; % red fixation dot
    dotInfo.fixMinTime      = 0.75; % minimum fixation
    dotInfo.fixMaxTime      = 1.25; % maximum fixation
    dotInfo.maxDotsPerFrame = 300; % depends on graphics card
    dotInfo.fixTime         = 2; % JQK: fixed onset fixation time

    % update frequency of on-screen content
    
    %dotInfo.Hz_BG   = 10; % background dots
    dotInfo.Hz_RDM  = 60; % kinematogram
    
    % multi-attribute task
    
    dotInfo.MAT.color = [255 255 255; 255 255 255];                         % define dot color
    dotInfo.MAT.coherence = 0;
    dotInfo.MAT.direction = [180 0];                                        % left and right (only modulated feature here)
    dotInfo.MAT.size = [8 8];                                               % define dot size
    dotInfo.MAT.luminance = [.3 .8];                                        % define dot luminance
    dotInfo.MAT.attNames = {'color'; 'direction'; 'size'; 'luminance'};
    dotInfo.MAT.attNamesDE = {'Farbe'; 'Richtung'; 'Gre'; 'Helligkeit'};
    
    dotInfo.MAT.percAtt1H = PM.xCurrent;
    dotInfo.MAT.percAtt1L = 1-dotInfo.MAT.percAtt1H;
    dotInfo.MAT.percAtt2H = .65;
    dotInfo.MAT.percAtt2L = 1-dotInfo.MAT.percAtt2H;
    dotInfo.MAT.percAtt3H = .65;
    dotInfo.MAT.percAtt3L = 1-dotInfo.MAT.percAtt3H;
    dotInfo.MAT.percAtt4H = .65;
    dotInfo.MAT.percAtt4L = 1-dotInfo.MAT.percAtt4H;
    
    %% Keyboard responses
    % Use OS X keyboard naming scheme across all plattforms
    % Otherwise LeftControl/RightControl are not recognized
    KbName('UnifyKeyNames');

    if ismac % Mac keyboard
    dotInfo.keyLeft = KbName('LeftGUI'); % left cmd when dots moving to left
    dotInfo.keyRight = KbName('RightGUI'); % right cmd when dots moving to right
    else % PC keyboard
    dotInfo.keyLeft = KbName('LeftControl'); % left ctrl when dots moving to left
    dotInfo.keyRight = KbName('RightControl'); % right ctrl when dots moving to right
    end

    dotInfo.keyModifier = KbName('LeftAlt'); % to prevent accidental input
    dotInfo.keyEscape = KbName('Escape'); % exit experiment
    dotInfo.keyReturn = KbName('Return'); % continue experiment

    %% randomize stimuli and non-target duration
    
    % set & retain random seed

    rseed = sum(100*clock);
    rng(rseed,'twister');
    [dotInfo.rngSetting] = rng;

    dotInfo.targetAtt = repmat(dotInfo.curAtt,1,dotInfo.trialsPerAtt);
    
    %% randomize directed attention trials & higher probability choice (within attribute)
    
    dotInfo.DirAttn = NaN(size(dotInfo.targetAtt));
    dotInfo.HighProbAtt = NaN(size(dotInfo.targetAtt));
    numSelAttn = ceil(dotInfo.dirAttentionRate*dotInfo.trialsPerAtt);
    for indAtt = 1:4
        tmp_trials = find(dotInfo.targetAtt == indAtt);
        if ~isempty(tmp_trials)
            tmp_rand = randperm(numel(tmp_trials));
            tmp_choice1 = tmp_trials(tmp_rand(1:numSelAttn));
            tmp_choice2 = tmp_trials(tmp_rand(numSelAttn+1:end));
            dotInfo.DirAttn(tmp_choice1) = 1;
            dotInfo.DirAttn(tmp_choice2) = 2;
            dotInfo.HighProbAtt(tmp_choice1(1:numel(tmp_choice1)/2)) = 1; % First half is designated highProb = 1;
            dotInfo.HighProbAtt(tmp_choice1(numel(tmp_choice1)/2:end)) = 2; % Second half is deignated highProb = 2;
            dotInfo.HighProbAtt(tmp_choice2(1:numel(tmp_choice2)/2)) = 1;
            dotInfo.HighProbAtt(tmp_choice2(numel(tmp_choice2)/2:end)) = 2;
        end
    end
        
    % Note that within attribute high probability choice and directed attention are orthogonal.
    % They both depend on the same randomization step.
    
    % The high probability choices only refer to the target attribute. The
    % high probability options for the other attributes are randomly drawn
    % below.
    
    % Note that there is no check that the conjunction of different
    % attributes appears equally often. 
    
    %% get random choices on each trial
    
    % This is not meaningful here, as each of the conjunction features are
    % set to an equal value.
    
    dotInfo.HighProbChoice = NaN(4,size(dotInfo.targetAtt,2));
    
    for indTrial = 1:dotInfo.totalTrials
        for indAtt = dotInfo.curAtt
            if dotInfo.targetAtt(indTrial) == indAtt
                dotInfo.HighProbChoice(indAtt,indTrial) = dotInfo.HighProbAtt(1,indTrial);
            else 
                tmp_rand = randperm(2);
                dotInfo.HighProbChoice(indAtt,indTrial) = tmp_rand(1);
            end
        end
    end
    
end