User Functions

../_images/UserFunctions1.PNG

USER FUNCTIONS Panel

Note

Review the article ScanImage® API to learn more about automating ScanImage.

Description

Assign user-defined functions that will be called in response to acquisition events.

Controls

Table Field

Description

Event Name

Select one of several events of interest.

User Function

The function to call in response to the event. Note that multiple events can be sent to the same function.

Arguments

A cell array with optional arguments to pass to your user function.

Enable

If this is checked, the user function will be called when the event is triggered.

Button

Description

im2

Add or delete a user function. Delete operates on the currently selected row.

im3

User functions can be stored in the CFG file or the USR file. Typically USR-defined user functions override those in CFG. The main table view is toggled to show either the CFG or USR set based on these buttons.

im4

Saves the current set of user functions to the CFG or USR configuration.

Code

A user function has the format:

1
function name(source,event,arguments)

Argument

Description

source

The UserFunction Class.  You can access the root SI object by accessing the source’s hidden property `hSI`.

event

a MATLAB EventData Class

arguments

A cell array with optional parameters. Specified in the arguments column of the User Functions table.

A Very Very Brief Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
function myUserFcn(src,evt,varargin)

   % in myUserFcn.m somewhere on the matlab path.

   disp(['Got Event: ' evt.EventName]); % prints the event

   disp(src); % prints the source object (UserFunctions)

   disp(src.hSI); % each source object has access to the main

   % ScanImage® Model object

   disp(src.hSI.imagingSystem) % from which we can access ScanImage

   % methods and properties

end

Events

General Events

Event

Description

acqModeStart

Called just before the start of an Acquisition Mode such as GRAB or LOOP. This may happen before any data is acquired.

acqModeDone

Called just after the last frame at the end of an Acquisition Mode such as GRAB or LOOP.

acqStart

Called just after the first frame gets acquired from an Acquisition.

acqDone

Called just after the last frame gets acquired from an Acquisition.

acqAbort

Called just after an acquisition is aborted. Abort usually happens because the Abort button is pressed in the Main Con trols.

sliceDone

Called just after the shutter is closed after acquiring a slice during a acquisition.

focusStart

Called just after the user presses the FOCUS button in the Main Con trols.

focusDone

Called just after the FOCUS is aborted. Similar to acqAbort but only in FOCUS mode.

frameAcquired

Called just after a frame is acquired.

overvoltage

Called when the digitizer experiences an overvoltage condition during an acquisition.

Photostimulation-module Events

Event

Description

onDmdStimStart

Fires when command to perform an on demand stim is received, before the trigger is sent.

onDmdStimSingleComplete

Fires when an on demand stim completes if multiple outputs are allowed; more stims can be externally triggered.

onDmdStimComplete

Fires when an on demand stim completes if multiple outputs are not allowed; no more stims will occur until next on demand command.

onDmdStimExtSel

Fires when an external on demand stimulus selection occurs.

seqStimStart

Fires when a sequence stimulation begins.

seqStimAdvance

Fires when a sequence element is complete and sequence advances to the next stim.

seqStimSingleComplete

Fires when a single sequence is complete.

seqStimComplete

Fires when the last sequence is complete.

photostimAbort

Fires when photostimulation module aborts.