function stimulus = Spatial_Contrast_Adaptation_Stimulus(seed, numframes,switchframe, Nrepeats, meanIntensity) % % %%% Spatial_Contrast_Adaptation_Stimulus %%% % % % This function generate the stimulus that was used to study spatial contrast % adaptation accompanying dataset of Khani and Gollisch (2017). The dataset is available at: % https://gin.g-node.org/gollischlab/Khani_and_Gollisch_2017_RGC_spiketrains_for_spatial_contrast_adaptation % % % ===============================Inputs==================================== % % seed : starting seed for generating random number sequences. % numframes : number of displayed stimulus frames. % switchframe : time point of contrast change from high to low and vice versa. % Nrepeats : number of stimulus trials. % meanIntensity : mean intensity during the experiment (between 0-1, usually 0.5). % %================================Output==================================== % % stimulus : high and low contrast stimulus sequences for locations X and Y. % first get the sequence of random numbers screenstimulus = ran1(seed,2*numframes); % 2 times number of frame for locations X and Y % convert the values to binary. % values > meanintensity are set to 1 (100% contrast). % values < meanintensity are set to -1 (-100% contrast). screenstimulus = 2*single(screenstimulus>meanIntensity)-1; % reshape to separate the values for locations X and Y. screenstimulus = reshape(screenstimulus,2,[]); % get screen stimulus per trial stim_locX = reshape(screenstimulus(1,:),switchframe,Nrepeats)'; stim_locY = reshape(screenstimulus(2,:),switchframe,Nrepeats)'; % location Y is the second seed series % separate high and low contrast for locations X and Y stimulus.locX_high = stim_locX(2:2:end,:); % location X, high contrast stimulus.locX_low = stim_locX(1:2:end,:); % location X, low contrast stimulus.locY_high = stim_locY(2:2:end,:); % location Y, high contrast stimulus.locY_low = stim_locY(1:2:end,:); % location Y, low contrast % match the stimuli sizes s = min([size(stimulus.locX_high,1),size(stimulus.locX_low,1),size(stimulus.locY_high,1),size(stimulus.locY_low,1)]); stimulus.locX_high = stimulus.locX_high(1:s,:); stimulus.locX_low = stimulus.locX_low(1:s,:); stimulus.locY_high = stimulus.locY_high(1:s,:); stimulus.locY_low = stimulus.locY_low(1:s,:); end