Skip to content

Program Structure

Michelle Sands edited this page Nov 6, 2025 · 7 revisions

The StimControl h struct - GUI Objects

baseGrid
tabs
Setup
    Control.panel
    Preview.panel
    ComponentConfig.panel
    Logo
Session
    Tab
    Grid
    Control.panel
    Info.panel
    Hardware.panel
    Preview.panel
    Logo
Menu
    File
        Save
            ComponentConfig
            Protocol
            StimControlSession
        Load
            ComponentConfig
            StimControlSession
ConfirmComponentConfigBtn
CancelComponengConfigBtn
ComponentConfig
    Label
    Table
% notably not GUI objects but spiritually close
ComponentConfig
    SelectedComponentIndex
    ConfigStruct
    Component
        Handle
        Properties
    ValsToUpdate

The StimControl d struct

Available 
Active 
IDComponentMap          map from ComponentIDs to component handles
ProtocolIDMap           map from protocol IDs to components

The StimControl path struct

setup.base
session.base
paramBase           hardware params
protocolBase        experiment protocol files
sessionBase         for StimControl session saving
componentMaps       mapping components to protocols

Adding New Hardware

New hardware components should implement the HardwareComponent abstract class (which outlines required functions and properties), and have their defaults written in a struct of named Component Properties. To fully integrate a new HardwareComponent into StimControl, you will need to implement the following functionality:

  • in StimControl.m under 'findAvailableHardware', find all hardware of the component type and add it to obj.d.Available as a struct compatible with the 'Struct' argument of the HardwareComponent class
  • in callbackEditComponentConfig, under 'extract component', extract the component from the struct.

Component Properties

Device component properties are statically defined per device type. A DeviceComponentProperties obj has a single attribute - Data - which is a struct of named ComponentProperties. Each ComponentProperty has the following settable values

Field Default DataType Description
default [] any Default value for the property
allowable {} categorical-compatible Allowable values for the property. Should be categorical-compatible (see below)
validatefcn @(val) true function handle Validation function handle for inserted value. Takes value as arg. Either this or allowable should be set.
dependencies @(propStruct) true function handle Validation function handle for requirements for property to be set. Takes full struct as arg.
dependents {} cellstr List of properties that are affected when the value for this property is changed
required @(propStruct) true function handle Function handle that returns whether a property needs to be defined. Takes full struct as arg. Will only be evaluated if dependencies evaluates to true.
dynamic false logical If true, property can be changed without restarting device.
note "" string or char array Comments.

All DeviceComponentProperties should include a ComponentProperty named ID.

Hints for Non-Matlab Devs

When working with a ComponentProperty that takes a vector as its value (e.g. camera ROI - see CameraComponent and CameraComponentProperties for examples of this), you should format it as a string, then just use str2num and num2str to convert when necessary to interface with the hardware itself. The StimControl software uses some of Matlab's built-in table/struct/transposition tools that don't play well with non-scalar numeric values.

Clone this wiki locally