Timelapse API functions

For use in the timelapse scripts a Python API for some of the microscope functions has been created.
Listed below for each is the name of the function, the arguments it takes, the values it returns, and what it does.

Function: GetTimeLapsePoints
Parameters: None
Returns: A tuple of points wach of which is also a tuple

Gets the points defined in the timelapse module.

Example:
import microscope
points = microscope.GetTimeLapsePoints()
print "First Point", points[0]

Function: VisitPoints
Parameters: None
Returns: None

Starts the cycle of visiting the timelapse points.
Example:
import microscope
points = microscope.VisitPoints ()

Function: AbortTimeLapseVisitPoints
Parameters: None
Returns: None

Aborts the cycle of visiting the timelapse points
Example:
import microscope
points = microscope.AbortTimeLapseVisitPoints()

Function: HasTimeLapseBeenAborted
Parameters: None
Returns: Boolean

Indicates that the timelapse has been aborted.,
Example:
import microscope
if microscope.HasTimeLapseBeenAborted():
    print "Yes"

Camera API functions

Function: GetMicronsPerPixel
Parameters: None
Returns: Double

Returns the microns per pixel of the currently used camera.
Example:
import microscope
micronsPerPixel = microscope.GetMicronsPerPixel():
print micronsPerPixel

Function: SetCameraLiveMode
Parameters: takes one integer: 1 for live and 0 for snap mode
Returns: None

Sets the camera to live or snap mode.
Example:
import microscope
microscope.SetCameraLiveMode (1)


Function: SnapImage
Parameters: None
Returns: None

Instructs the camera to take an picture.
Example:
import microscope
microscope.SnapImage ()


Function: SetExposure
Parameters: takes one float: exposure time in milli seconds
Returns: One integer: 1 for success 0 for fail

Sets the camera to a specific exposure time in milliseconds
Example:
import microscope
microscope.SetExposure (10.0)


Function: SetGain
Parameters: takes one float: gain. Camera dependant
Returns: One integer: 1 for success 0 for fail

Sets all the camera channels to the same gain if the camera has more than one channel
Example:
import microscope
microscope.SetGain (200.0)


Function: PerformAutoExposure
Parameters: None Returns: None

Attempts to calculate a good exposure automatically using the values on the autofocus panel.
Example:
import microscope
microscope.PerformAutoExposure ()


Function: AbortSoftwareAutoFocus
Parameters: None. Returns: None

Attempts to abort a previous software autofocus
Example:
import microscope
microscope.AbortSoftwareAutoFocus ()


Cube Slider API functions

Function: GetCubes
Parameters: None
Returns: A list of dictionaries: contains cube data

Retrieves information on the cubes on the microscope
Example:
import microscope
cubes = microscope.GetCubes()
print "First Cube Info", cubes [0]

Function: MoveCubeToPosition
Parameters: takes one integer: cube position index starts at 1.
Returns: None

Changes the cube position on the microscope.
Example:
import microscope
microscope.MoveCubeToPosition(1)


Function: WaitForCube
Parameters: None
Returns: None

Waits for the cubes to stop moving
Example:
import microscope
microscope.WaitForCube ():


Stage API functions

Function: GetStagePosition
Parameters: None
Returns: Tuple (x,y,z)

Gets the position of the stage
Example:
import microscope
position = microscope.GetStagePosition()
print "Position: ", position

Function: SetStagePosition
Parameters: Three doubles: x, y, z
Returns: None

Sets the position of the stage to the x y and z co-ordinates given.
Example:
import microscope
position = microscope.SetStagePosition (200.0, 100.0, 70.0)


Function: WaitForStage
Parameters: takes two doubles: The amount of time to delay in seconds after the stage has stopped
and the comport timeout.
Returns: None

Waits for the stage to stop moving.
Example:
import microscope
microscope.WaitForStage (1.0, 5.0)


Function: SetStageRelativeZPosition
Parameters: Takes one double: z offset to apply
Returns: None

Sets the position of the z stage relative to the current position.
Example:
import microscope
position = microscope.SetStageRelativeZPosition(20.0)


Function: Lamp API functions

Function: TurnLampOn
Parameters: None
Returns: None

Turns the microscope lamp on.
Example:
import microscope
position = microscope.TurnLampOn ()


Function: TurnLampOff
Parameters: None
Returns: None

Turns the microscope lamp off.
Example:
import microscope
position = microscope.TurnLampOff ()


Function: SetLampIntensity
Parameters: takes one double: lamp intensity as a percentage of maximum
Returns: None

Sets the intensity of the lamp on the microscope.
Example:
import microscope
position = microscope.SetLampIntensity(100.0)


Optical Path API functions

Function: GetOpticalPaths
Parameters: None
Returns: A list of dictionaries: contains optical path data

Retrieves information on the optical paths on the microscope.
Example:
import microscope
paths = microscope.GetOpticalPaths()
print "First path Info", paths [0]

Function: MoveOpticalPathToPosition
Parameters: One integer: path position. Index starts at 1.
Returns: None

Changes the optical path on the microscope.
Example:
import microscope
microscope.MoveOpticalPathToPosition(1)


Function: MicroscopeSetMode
Parameters: takes one integer: Mode constants are:
FLUORESCENCE_MODE
BRIGHT_FIELD_MODE
PHASE_CONTRAST_MODE
LASER_SCANNING_MODE
FLUOR_NO_SHUTTER_MODE
Returns: None

Changes the mode of the microscope.
Example:
import microscope
microscope.MicroscopeSetMode(microscope.FLUORESCENCE_MODE)


Shutter API functions

Function: OpenShutter
Parameters: None
Returns: None

Opens the microscope shutter.
Example:
import microscope
microscope.OpenShutter ()


Function: CloseShutter
Parameters: None
Returns: None

Closes the microscope shutter.
Example:
import microscope
microscope.CloseShutter()


Function: IsShutterOpen
Parameters: None
Returns: One integer: 1 if open 0 if closed

Checks if the microscope shutter is open or closed.
Example:
import microscope
isShutterOpen = microscope.IsShutterOpen()


Function: SetShutterOpenTime
Parameters: takes one double: Open time in milliseconds
Returns: None

Sets the open time of the shutter in milli seconds. 0 is considered infinity.
Example:
import microscope
microscope.SetShutterOpenTime (10.0)


Saving and filename passing API functions

Function: GetUserDataDirectory
Parameters: None
Returns: one string: The directory containing data files for the microscope

Gets the directory where user data is saved.
Example:
import microscope
dir = microscope.GetUserDataDirectory ()


Function: SnapAndSaveImage
Parameters: one string, one integer: Filepath to save to, average frame count
Returns: None

Snaps an Image and then saves it to the desired location. If the optional integer is passed then that number of frames is acquired and the average saved.
Example:
import microscope
microscope.SnapAndSaveImage ("C:\\test.ics", 5)


Function: SaveCurrentDisplayedImage
Parameters: One string: Filepath to save to.
Returns: None

Saves the currently displayed image to the desired location.
Example:
import microscope
microscope.SaveCurrentDisplayedImage ("C:\\test.ics")


Function: ParseSequenceFilename
Parameters: One string, one integer: filename and sequence number
Returns: String passed filename

Parses a sequence filename, substituting in the current date time and sequence number.
Example:
import microscope
filename = microscope.ParseSequenceFilename ("C:\\test%d.ics", 5)


Function: ShowFileSequenceSaveDialog
Parameters: One string: default directory
Returns: Tuple containing the output directory and filename

Asks the user for the desired filename format.
Example:
import microscope
(outdir, filename) = microscope.ShowFileSequenceSaveDialog("C:\\")


Function: ShowSimpleFileSequenceSaveDialog
Parameters: one string: Default directory
Returns: Tuple containing the output directory, filename and extension

Asks the user for the desired filename prefix.
Example:
import microscope
(outdir, filename, ext) = microscope.ShowSimpleFileSequenceSaveDialog ("C:\\")


Function: InsertCubeIntoFilename
Parameters: one string: filename string, integer cube number
Returns: string: Replaced Filename

Takes a cube index and inserts it's name into a filename surrounded by underscores ('_').
Example:
import microscope
filename = microscope.InsertCubeIntoFilename("C:\\filename.ics", 6)


Function: InsertTextIntoFilename
Parameters: string: filename string text
Returns: string: Replaced Filename

Takes some text and inserts it into a filename surrounded by underscores ('_').
Example:
import microscope
filename = microscope.InsertTextIntoFilename("C:\\filename.ics", "test")


Autofocus

Function: PerformSoftwareAutoFocus
Parameters: None
Returns: None

Performs a software based auto focus and the snaps and image.
Example:
import microscope
microscope.PerformSoftwareAutoFocus()


SPC API functions

SPC functions are encapsulated within an object. To use this object import the package MicroscopeModules and construct the object with spc = MicroscopeModules.Spc() The methods of this object are

Function: Start
Parameters: SPC_ACQ_LIMIT_TYPE_SECONDS=1
SPC_ACQ_LIMIT_TYPE_FRAMES=2
SPC_ACQ_LIMIT_TYPE_MAX_COUNT=3
SPC_ACQ_LIMIT_TYPE_MEAN_COUNT=4
Defaults to 2
Integer (repeat) Default to 0
double (repeat_time) Defaults to 10.0
Integer (should display) Defaults to 1
double (Display time) Defaults to 2.0
int (accumulate) Defaults to 0
int (auto save) Defaults to 0
string or None (filepath) Defaults to None

Returns: None

Start the acquisition of a time resolved image using values from the user interface.
Example:
import MicroscopeModules
spc = MicroscopeModules.Spc()
spc.Start(spc.SPC_ACQ_LIMIT_TYPE_SECONDS, repeat = 0, repeat_time = 10.0, should_display = 1, display_time = 2.0, accumulate = 0, autosave = 0)


Function: AcquireAndSaveToFileUsingUIValues
Parameters: one integer and one string: Save 3D and filepath
Returns: None

Start the acquisition of a time resolved image. Using values from the user interface
Example:
import MicroscopeModules
spc = MicroscopeModules.Spc()
spc.AcquireAndSaveToFileUsingUIValues(1, "C:\\test.ics")


Function: ClearBoardMemory
Parameters: None
Returns: None

Clears the memory of the spc board.


Example:
import MicroscopeModules
spc = MicroscopeModules.Spc()
spc.ClearBoardMemory()


Function: SetSpcResolution
Parameters: one integer: from 4096, 1024, 256, 64, 16, 4, 1
Returns: None

Sets the ADC resolution of the SPC module.
Example:
import MicroscopeModules
spc = MicroscopeModules.Spc()
spc.SetSpcResolution (256)


Scanner API functions

Function: SetScannerProperties
Parameters: Five Integers: resolution, zoom, xshift, yshift, scan_type
Returns: None

Sets the properties of the scanner module.
Example:
import microscope
microscope.SetScannerProperties (256, 1, 0, 0, 1)
Function: StartScanner
Parameters: None
Returns: None

Starts the scanner


Example:
import microscope
microscope.StartScanner ()
Function: StopScanner Stops
Parameters: None
Returns: None

Stops the scanner.
Example:
import microscope
microscope.StopScanner ()

Regionscan API functions


Regionscan functions are encapsulated within an object. To use this object import the package MicroscopeModules and construct the object with rs = MicroscopeModules.RegionScan() The methods of this object are

Function: Start
Parameters: one integer, three strings: action, directory where images are saved,
filename prefix, filename extension
Returns: None

Starts the region scan.
Example:
import MicroscopeModules
rs = MicroscopeModules.RegionScan()
rs .Start(MicroscopeModules.RegionScan.SAVE_DISPLAY, subdir, filename, filename_ext)


Function: Stop
Parameters: None
Returns: None

Stops the region scan.


Example:
import MicroscopeModules
rs = MicroscopeModules.RegionScan()
rs .Stop()


Function: SetRoi
Parameters: four integers: left, top, width, height, in microns
Returns: None

Sets the region of interest for the region scan.
Example:
import MicroscopeModules
rs = MicroscopeModules.RegionScan()
rs .SetRoi(-1000, -1000, 1000, 1000)


Function: SetRelativeRoi
Parameters: two integers: width, height, in microns
Returns: None

Set the region of interest in microns relative from the current stage position.
Example:
import MicroscopeModules
rs = MicroscopeModules.RegionScan()
rs .SetRelativeRoi(2000,2000)


Function: SetSoftwareAutofocus
Parameters: One integer: Turn it on
Returns: None

Turn on or off the software autofocus on every point in the scan
Example:
import MicroscopeModules
rs = MicroscopeModules.RegionScan()
rs .SetSoftwareAutofocus(1)


Background Correction API functions

Function: BackgroundCorrectionEnable
Parameters: one integer: 1 to enable background correction.
Returns: None

Enables background correction.
Example:
import microscope
microscope.BackgroundCorrectionEnable (1)

Function: BackgroundCorrectionCanProcess
Parameters: None
Returns: one integer

Returns true if background correction can be performed. Enables background correction.
Example:
import microscope
canProcess = microscope.BackgroundCorrectionCanProcess ()