Parsing values from StimulusLibrary in a custom class

62 views
Skip to first unread message

Adam Taylor

unread,
Nov 7, 2018, 1:40:41 PM11/7/18
to WaveSurfer
I migrated this over from https://github.com/JaneliaSciComp/Wavesurfer/issues/243

Please use the forum to ask for help, unless you're 100% sure the thing you need help with is a WaveSurfer bug. Issues (at least in theory) eventually get closed, in which case any useful information in them is harder for folks to find.

Pratik Mistry asks:

At the end of each sweep, the post-doc in our lab is using a stimulus called test.
I'm trying to retrieve these values in a customized class, but I'm having a difficult time getting values, such as delay, duration, and amplitude. (Not sure what the correct syntax is for retrieving these values).

If you have a ws.WavesurferModel instance (like that provided by many of the user class methods, or from File > Export Model and Controller to Workspace) named wsModel, you can do things like this:

>> wsModel.stimulusLibraryItemProperty('ws.Stimulus', 1, 'Duration')

ans =

    '0.5'

>> wsModel.stimulusLibraryItemProperty('ws.Stimulus', 1, 'Name')

ans =

    'Pulse'

>> wsModel.stimulusLibraryItemProperty('ws.Stimulus', 1, 'Duration')

ans =

    '0.5'

>> wsModel.stimulusLibraryItemProperty('ws.Stimulus', 1, 'Delay')

ans =

    '0.25'

>> wsModel.stimulusLibraryItemProperty('ws.Stimulus', 1, 'Amplitude')

ans =

    '5'

>> 

(Here 1 is the index of the first stimulus in the library.)  Even the values that seem like they should be doubles will be strings, however, so you may need to use str2double() to convert them.  They're strings because they're not always just plain numbers: they can be expressions like '10 + 10*(i-1)' if you want some property of the stimulus to vary across sweeps.

You can get the names of all the stimulus library items of a particular class like so:

wsModel.propertyFromEachStimulusLibraryItemInClass('ws.StimulusMap', 'Name')

The number of items in the resulting cell array of strings will tell you how many stimuli currently exist.

Hope this helps,
Adam

Pratik Mistry

unread,
May 15, 2019, 3:38:36 PM5/15/19
to WaveSurfer
Hi Adam,

Following up on this, how can we change the values of a stimulus during an acquisition (mainly the amplitude)?

Best,

Pratik
Reply all
Reply to author
Forward
0 new messages