Skip to content

Gizmos and Parameters

getGizmoNames

cGizmos = getGizmoNames(bApiOnly)

Returns a cell array of all gizmos in the running experiment. This can be used with getParameterNames and get and set parameter methods to change parameters during runtime.

Inputs Type Values
bApiOnly boolean (optional) only return gizmos that have API parameters
Returns
cGizmos cell strings of all gizmo names in current experiment

Example

Retrieve the gizmo names in current experiment.

gizmo_names = syn.getGizmoNames();

if numel(gizmo_names) < 1
    error('no gizmos found')
end

% return only the gizmos that have API parameters
gizmo_names = syn.getGizmoNames(1);
gizmo_names = syn.getGizmoNames()

if len(gizmo_names) < 1:
    raise Exception('no gizmos found')

# return only the gizmos that have API parameters
gizmo_names = syn.getGizmoNames(1)

getGizmoParent

sGizmoParent = getGizmoParent(sGizmoName)

Return the name of the parent processor for a particular gizmo. Useful if you have multiple processors and want to know the sampling rate a particular gizmo is running at.

Inputs Type Values
sGizmoName string gizmo to find the parent of
Returns
sGizmoParent string name of parent gizmo

Example

Get the gizmo's sampling rate by querying the parent processor.

parent = syn.getGizmoParent('aStim1');

rates = syn.getSamplingRates();

gizmoRate = rates.(parent);
parent = syn.getGizmoParent('aStim1')

rates = syn.getSamplingRates()

gizmoRate = rates[parent]

getGizmoInfo

tGizmoInfo = getGizmoInfo(sGizmoName)

Returns a struct containing the gizmo type, category, description, and icon (string of base64-encoded text representing the icon).

Inputs Type Values
sGizmoName string gizmo name to retrieve information for
Returns
tGizmoInfo struct struct fields:
cat - gizmo category
desc - gizmo description
icon - base64-encoded icon
type - gizmo type

Example

Find a specific type of gizmo in the current experiment

% get all gizmos
gizmos = syn.getGizmoNames();

% loop over gizmos, looking for 'AudioStim' gizmo
for gizmo = 1:numel(gizmos)
    info = syn.getGizmoInfo(gizmos{gizmo});
    if strcmp(info.type, 'AudioStim')
        disp('found AudioStim gizmo')
    end
end
# get all gizmos
gizmos = syn.getGizmoNames()

# loop over gizmos, looking for 'AudioStim' gizmo
for gizmo in gizmos:
    info = syn.getGizmoInfo(gizmo)
    if strcmp(info.type, 'AudioStim'):
        print('found AudioStim gizmo')

getParameterNames

cParameters = getParameterNames(sGizmo)

Returns a cell array of parameter names for the specified gizmo. This can be used with getGizmoNames and get/set parameter methods to change parameters at runtime.

Inputs Type Values
sGizmo string gizmo to find the parent of
Returns
cParameters cell strings of all parameter names for this gizmo

Example

Retrieve all parameter names of all gizmos

gizmo_names = syn.getGizmoNames()

for i = 1:numel(gizmo_names)
    gizmo = gizmo_names{i}
    params = syn.getParameterNames(gizmo);
end
gizmo_names = syn.getGizmoNames()

for gizmo in gizmo_names:
    params = syn.getParameterNames(gizmo)

getParameterInfo

tParameterInfo = getParameterInfo(sGizmo, sParameter)

Returns a structure containing parameter information.

Note

The same information is displayed in a table in the Synapse designtime interface when you click the API button on the gizmo options tab.

Inputs Type Values
sGizmoName string gizmo name to retrieve information for
sParameter string parameter to retrieve information for
Returns
tParameterInfo struct struct fields:
Unit - the units label for this parameter
Min - the minimum allowed value for this parameter
Max - the maximum allowed value for this parameter
Type - the parameters data type. Can be 'Float', 'Int', or 'Logic'
Array -
During designtime: If the parameter is an array of known size, this field contains the number of elements in this parameter. If the size is unknown (for example, User gizmo tag arrays or Legacy Hal parameter tags), this field contains 'Yes'. Otherwise it contains 'No' for any scalar parameters.

During runtime: this field will always contain the size of the parameter if it is an array (>1), or 'No' if it is not.

Example

Retrieve all parameter info for all gizmos.

% get all gizmo names
gizmo_names = syn.getGizmoNames();

% loop through the names
for i = 1:numel(gizmo_names)
    gizmo = gizmo_names{i}

    % get all parameters for this gizmo
    params = syn.getParameterNames(gizmo)

    % loop through the parameters, get their info
    for i = 1:numel(params)
        param = params{i};
        info = syn.getParameterInfo(gizmo, param);
    end
end
# get all gizmo names
gizmo_names = syn.getGizmoNames()

# loop through the names
for gizmo in gizmo_names:

    # get all parameters for this gizmo
    params = syn.getParameterNames(gizmo)

    # loop through the parameters, get their info
    for param in params:
        info = syn.getParameterInfo(gizmo, param)

getParameterSize

dValue = getParameterSize(sGizmo, sParameter)

Returns the size of the specified parameter from the specified gizmo. This can be used with getGizmoNames and getParameterNames.

Inputs Type Values
sGizmoName string gizmo name to retrieve information for
sParameter string parameter to retrieve information for
Returns
dValue double size of parameter, will be > 1 if it is an array

Example

Retrieve all parameter sizes for all gizmos.

% get all gizmo names
gizmo_names = syn.getGizmoNames();

% loop through the names
for i = 1:numel(gizmo_names)
    gizmo = gizmo_names{i}

    % get all parameters for this gizmo
    params = syn.getParameterNames(gizmo)

    % loop through the parameters, get their sizes
    for i = 1:numel(params)
        param = params{i};
        param_size = syn.getParameterSize(gizmo);
    end
end
# get all gizmo names
gizmo_names = syn.getGizmoNames()

# loop through the names
for gizmo in gizmo_names:

    # get all parameters for this gizmo
    params = syn.getParameterNames(gizmo)

    # loop through the parameters, get their sizes
    for param in params:
        param_size = syn.getParameterSize(gizmo, param)

getParameterValue

dValue = getParameterValue(sGizmo, sParameter)

Returns the value of the specified parameter from the specified gizmo. This can be used with getGizmoNames and getParameterNames.

Inputs Type Values
sGizmoName string gizmo name to retrieve value for
sParameter string parameter to retrieve value for
Returns
dValue double current value of parameter

Example

Retrieve a General Purpose Filter gizmo's high pass frequency setting.

filter_highpass = syn.getParameterValue('Filt1', 'HighPassFreq')
filter_highpass = syn.getParameterValue('Filt1', 'HighPassFreq')

setParameterValue

bSuccess = setParameterValue(sGizmo, sParameter, dValue)

Returns the value of the specified parameter from the specified gizmo. This can be used with getGizmoNames and getParameterNames.

Inputs Type Values
sGizmoName string gizmo name to set value for
sParameter string parameter to set value for
dValue double new value of parameter
Returns Type Values
bSuccess boolean 0 (fail), 1 (success)

Example

Retrieve a General Purpose Filter high pass frequency, then increments it by 1.

val = syn.getParameterValue('Filt1', 'HighPassFreq')

syn.setParameterValue('Filt1', 'HighPassFreq', val + 1)

val = syn.getParameterValue('Filt1', 'HighPassFreq')
val = syn.getParameterValue('Filt1', 'HighPassFreq')

syn.setParameterValue('Filt1', 'HighPassFreq', val + 1)

val = syn.getParameterValue('Filt1', 'HighPassFreq')

getParameterValues

fValues = getParameterValues(sGizmo, sParameter, count=-1, offset=0)

Returns the values of the specified parameter array.

Inputs Type Values
sGizmoName string gizmo name to retrieve value for
sParameter string parameter to retrieve value for
count integer (optional) number of values to return (default is to read the entire buffer)
offset integer (optional) buffer location to read from (default is beginning)
Returns
fValues float array contents of the buffer

Example

Retrieve the map array from a Channel Mapper gizmo.

currMap = syn.getParameterValues('Map1', 'ChanMap')
currMap = syn.getParameterValues('Map1', 'ChanMap')

setParameterValues

bSuccess = setParameterValue(sGizmo, sParameter, values, offset=0)

Returns the values of the specified parameter array.

Inputs Type Values
sGizmoName string gizmo name to retrieve value for
sParameter string parameter to retrieve value for
values number array of values to write into the parameter array
offset integer (optional) buffer location to write into (default is beginning)
Returns
bSuccess boolean 0 (fail), 1 (success)

Example

Set the map array of a Channel Mapper gizmo.

currMap = syn.getParameterValues('Map1', 'ChanMap')

defaultMap = 1:numel(currMap);

syn.setParameterValues('Map1', 'ChanMap', defaultMap);
currMap = syn.getParameterValues('Map1', 'ChanMap')

defaultMap = 1:len(currMap)

syn.setParameterValues('Map1', 'ChanMap', defaultMap)