Skip to content
createDotInfo_TEST_Dim3_170327.m 5.46 KiB
Newer Older
Julian Kosciessa's avatar
Julian Kosciessa committed
%_______________________________________________________________________
%
% Configuration for running dotsExperiment
%_______________________________________________________________________
%
% Output
%
% dotInfo | configuration for random dots experiment (struct)
%_______________________________________________________________________
%
function dotInfo = createDotInfo_TEST_Dim3_170327

    dotInfo.trialsPerAtt = 30; % should be around 15 minutes at current timing
    dotInfo.numOfAtt = 4; % fixed in paradigm
    dotInfo.totalTrials = dotInfo.trialsPerAtt;
    
    dotInfo.curAtt = 3;
    
    dotInfo.dirAttentionRate = .5; % ratio of directed attention vs. wholistic attention trials (same for each attribute)
    
    dotInfo.durCue = 0; % duration of cue
    dotInfo.durPres = .5; % duration of presentation
    dotInfo.durResp = 2.5; % duration of question
    
    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.percAtt1 = .65;
    dotInfo.MAT.percAtt2 =  1-dotInfo.MAT.percAtt1; % For each attribute, the relative amount of dots for each attribute option is the same.
    dotInfo.MAT.color = [255 255 255; 255 255 255]; % define dot color
    dotInfo.MAT.coherence = 0;  % define dot movement (coherence) [useless now!]
    dotInfo.MAT.direction = [180 0]; % left and right
    dotInfo.MAT.size = [5 8]; % define dot size
    dotInfo.MAT.luminance = [.8 .8]; % define dot luminance
    dotInfo.MAT.attNames = {'color'; 'direction'; 'size'; 'luminance'};
    dotInfo.MAT.attNamesDE = {'Farbe'; 'Richtung'; 'Gre'; 'Helligkeit'};

    %% 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 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
    
    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