Hello all,
I have the following question. I am creating trials where participants listen to a series of 50 ms tones in a classic oddball paradigm, with 114 total tones in a trial. For those unfamiliar with oddball paradigms, the large majority of these tones will be the same tone, called the 'standards.' A minority of these tones will be 'deviant' tones, which the participant will be asked to respond to. I want these deviant tones to occur randomly, but they cannot occur consecutively. So if the fourth tone is a deviant, the fifth (or the third tone) cannot be deviants.
If it helps, i have included some code that randomly selects which tones will be deviants, but I don't know how to make sure that no deviants occur consecutively. Randperm doesn't seem to have this capability
num_deviants=29; %arbitrary number, each trial will have a different number of deviants
%% 3. Initialize static variable (stay the same across trials)
num_stim_total=114; %total number of tones
stim_times=[0,50]; %this matrix will have start and stop times for the stimuli, in columns 1 and 2 respectively
%% 4. Create interstimulus intervals and stimulus onset/offset times
ISI_generator=randi([700 1000],1,113); %creates 113 random samplings from 700 to 1000
for i=1:113 stim_times(i+1,1)=stim_times(i,2)+ISI_generator(i); %adds ISI to the end time of the last stimulus to create start time of next stim
stim_times(i+1,2)=stim_times(i+1,1)+50; %adds 50ms to stim start time to signify the stimulus stop time
end%% 5. Randomly decides deviants vs standards
deviant_decider=randperm(num_stim_total,num_deviants)'; %randomly decides which start times will become deviant sounds (designated by a '1')
stim_times(deviant_decider,3)= 1;standard_array=1:114; %create an array of 1 to 114
standard_decider=setdiff(standard_array,deviant_decider'); %returns all the numbers 1-114 that aren't in deviant_decider, and makes them standards
Best Answer