Closed dshimaoka closed 2 years ago
Properties of cic are special (in the sense that they are not updated at the start of the trial ) and can therefore not be set in a design. This is to avoid all kinds of issues with Internal /bookkeeping parameters of CIC being changed on a per-trial basis.
The work around is similar to #2., but you have to add a new property to a different (i.e. NOT cic) plugin first. For instance, if f is your fixation plugin called 'fix' (but any plugin will do) f= addProperty(f,'interTrialInterval') f.interTrialInterval = plugins.jitter... % Set this property to jitter c.iti = @.***';
Please try this out and, once it works, you could add it to the demos as jitteredItiDemo.m ?
Bart
From: Daisuke Shimaoka @.> Sent: Tuesday, August 30, 2022 8:31 AM To: klabhub/neurostim @.> Cc: Subscribed @.***> Subject: [klabhub/neurostim] Jitter plugin for c.ITI (Issue #204)
I want inter-trial interval to be chosen uniquely for each trial (, however many trials my factors dictate), one of the essential requirements of sensory experiments. Currently, a script with the following line assigns an ITI at the start of an experiment, and does not update each trial. c.iti = plugins.jitter(c,{(minimum ITI),(maximal ITI)});
Neither of the following possible workarounds turned out to work currently:
Although a jitter to .on may achieve the desired outcome, it requires modification of the all the subsequent events. Is there any possibility to enable c.iti = plugins.jitter(c,{(minimum ITI),(maximal ITI)});, or implement some handy functions?
- Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fklabhub%2Fneurostim%2Fissues%2F204&data=05%7C01%7Cbart%40rutgers.edu%7Ce250fa6ca4ea4bb155ac08da8a513405%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637974378643272224%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=BZXLtq9jMNoZDiR88yaAxaiz3MrAOo5rzbCl4l3lqOg%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAC3MRU3HKRHQVCYDR6DX6SLV3WTATANCNFSM6AAAAAAQACJLYY&data=05%7C01%7Cbart%40rutgers.edu%7Ce250fa6ca4ea4bb155ac08da8a513405%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637974378643272224%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=F75jHLy1lD6VPZ9w73TOEX7BnQ2wWFkIZUXqRL6PuXc%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>
Thanks, it works. I tried making a demo - it's a barebone for now. Please amend if a particular formatting is necessary as a demo code.
function jitteredITIDemo(minJitter, maxJitter, varargin) % Demo to show variable inter-trial interval. % % cf. https://github.com/klabhub/neurostim/issues/204 % % DS - Aug 2022.
import neurostim.*
if nargin < 2 maxJitter = 1000; end if nargin < 1 minJitter = 500; end
%% Setup the controller c= myRig(varargin{:});
%c.trialDuration = inf; c.screen.color.background = [ 0.5 0.5 0.5]; c.subjectNr= 0;
%% Add a Gabor; % We'll simulate an experiment in which % the grating's location (left or right) is to be detected % and use this to estimate the contrast threshold g=stimuli.gabor(c,'grating'); g.color = [0.5 0.5 0.5]; g.contrast = 1; g.X = 0; g.Y = 0; g.sigma = 3; g.phaseSpeed = 0; g.orientation = 0; g.mask = 'CIRCLE'; g.frequency = 3; g.on = 0; g.duration = 200;
g.addProperty('jitteredITI',[]); g.jitteredITI = plugins.jitter(c,{minJitter, maxJitter}); c.iti = '@grating.jitteredITI';
d = neurostim.design('myDesign');
% specify a block of trials myBlock = block('myBlock',d); myBlock.nrRepeats = 100;
% now run the experiment... c.run(myBlock); % run the paradigm
%% Do some analysis on the data import neurostim.utils.*;
histogram(get(c.prms.iti,'atTrialTime',inf),10); xlabel('ITI [s]'); ylabel('#trials'); end
Nice, some comments at the top of the file and inline to explain the key parts (e..g, adding the property to a regular plugin, not CIC) would be helpful, but other than that I think this could be of real help to a future user. Please add and PR.
I want inter-trial interval to be chosen uniquely for each trial (, however many trials my factors dictate), one of the essential requirements of sensory experiments. Currently, a script with the following line assigns an ITI at the start of an experiment, and does not update each trial.
c.iti = plugins.jitter(c,{(minimum ITI),(maximal ITI)});
Neither of the following possible workarounds turned out to work currently:
Although a jitter to
.on
may achieve the desired outcome, it requires modification of the all the subsequent events. Is there any possibility to enablec.iti = plugins.jitter(c,{(minimum ITI),(maximal ITI)});
, or implement some handy functions?