Script Classes and Functions

In addition to the standard math, string, file I/O and other functions provided with the Lua language, the classes and function groups listed below are provided with the Scripting Module in Mira MX x64, Mira Pro x64, and Mira Pro Ultimate Edition.

Classes

CApphot

Used for performing aperture photometry measurements on images. This class is used to measure the brightness of objects or sources in images using the aperture photometry method. The aperture may be a circle or an ellipse and the background is computed locally around the source. The class uses many data members to provide flexibility and to control how the measurements are made.

CArray

The CArray class manages a 1-dimensional array of values. The class implements a vector as a Lua table of (index, value) pairs. The values may be any supported type of thing (number, string, object) and indexing starts at 1. The CArray is sparse, so that an array can stretch from index 1 to index 10000 by holding just 1 member with index 10000. See also the CMatrix class and the CSet class.

CCentroid

The CCentroid class encapsulates functionality for computing accurate centroid coordinates in an image. The centroid position is a refined coordinate based upon higher order moments of the pixel value distribution. This class provides methods for calculating the centroid position and for working with control parameters. The pixel coordinates may be converted to world coordinates using one of the CImage class methods such as XyToWcs.

CColorRef

Used for working with colors. Holds color data members and provides methods for working with the colors.

CFile

The CFile class encapsulates file operations. This class wraps several C functions for working with text and binary files.

CFindFiles

The CFindFiles class provides file searching capability. This class iterates through the files in a folder using a filename template for file selection.

CFwhm

The CFwhm class encapsulates functionality for computing the Full Width at Half Maximum values in an image. This class provides methods for calculating the FWHM and for working with control parameters. The centroid computation collects points around a central position, then fits a Gaussian + Constant model to the data. The fit parameters lead to the FWHM value, the background value, and the peak value of the point spread function. Both peaks and valleys can be measured. The Calc method usually uses a centroid position as the center point of the FWHM calculation.

CImage

The CImage class works with image data. More than 180 class methods are provided for working with image files, doing image math operations, changing image geometry, making measurements, and working with header data. Additional methods for combining and merging images are found in the CImCombine class.

CImageSet

The CImageSet class manages a list of CImage objects. The class contains methods for working with Mira Image Sets.

CImageView

The CImageView class provides 50 methods for working with a Mira image window that displays images. The Image View window uses an image set to work with a group of images. This class encloses a pointer to the view window and provides methods for displaying and adjusting images and for working with the image cursor.

CImCombine

The CImCombine class contains methods for combining images in various ways. The processing methods take their images from a CImageSet collection of images

The combining methods operate in the "depth" direction through the image set. Each pixel location is considered in turn, and all values in the images at that single location are combining using the specified method. This procedure is repeated for each pixel location in the image.

The available combining methods fall into 2 groups: The first group of methods merge individual images into a single, higher quality image according to the mean, median, or other statistical averaging process applied at each pixel location. The second group produces an image showing the properties of the image collection at each location, such as the range of pixel values or the standard deviation among the images. Methods in the first group are further split into two subgroups: those that compute means and weighted means and those that perform some type of bad data rejection, or "clipping".

CLabels

The CLabels class applies labels to displayed images. This class works with the CImageView class, which itself manages the displayed images

CMatrix

The CMatrix class manages a 2-dimensional matrix. The members (or elements) of the matrix are usually numbers but may be any type of value, such as strings or references to other types. The class implements a matrix as a Lua table of (row, CArray) pairs, with each row being a CArray of (column, value) pairs. See the detailed description of the CMatrix class in "Working with Matrices".

CPlotView

The CPlotView class displays 1-dimensional data in a Mira Plot Window. This class can plot data from the following sources:

  • An internal data matrix belonging to the class. The matrix holds point data and error bars for producing a scatter plot. This is a CMatrix that is automatically created when the CPlotView object is created using the new operator. Each CPlotView object has its own private data matrix.
  • Equally spaced data stored in the rows of a CMatrix. These data can be plotted as a line plot or using symbols.
  • The rows and columns of a CImage.
  • The rows and columns of a displayed image as outlined by the image cursor in a CImageView.

CRect

The CRect class encapsulates functionality for a rectangle object used for computing statistics, setting window boundaries, setting up the image cursor for measurements, and plots, and for other uses. The rectangle is described in terms of pixel coordinates.

CRegistry

Methods for saving and retrieving values from the Windows Registry.

CSplitpath

The CSplitpath class is used to manipulate file paths. Use this class to replace elements of the path such as the file name, directory, file extension, etc.

CSet

The CSet class manages a list of objects. This is different from the indexed list managed by the CArray class.

CStats

The CStats class computes statistics over a rectangular region of an image.

CStrTok

Parses strings into shorter strings (tokens) based on separator characters.

CTextView

The CTextView class manages the Mira Text Editor window. Use this class to print messages in a scrolling editor window. For further information on the Text Editor, see the Mira User's Guide. This is a class based version of the global CreateTextWindow function.

Functions

Text Formatting Functions These functions format text to strings and windows.
Dialog Functions These functions use pop-up dialogs to display messages and input data into a script.
Miscellaneous Functions These functions set global parameters, and various other things.

Text Formatting Functions

These functions format text to strings and windows.

CreateTextWindow The CreateTextWindow function opens a new Mira Text Editor window. The title and size can be specified.
MsgBox The MsgBox function displays a string in a standard Windows Message Box. After you click [OK] the script continues.
Msg The Msg function opens a small dialog window to show a message.
Msg2 The Msg2 function opens a medium size dialog to show a message.
Printf The global Printf function writes formatted text in the default Script Messages window. This method provides functionality like the printf function in the C language. This function creates the Script Messages window if it does not already exist.
Sprintf The global Sprintf function formats text to a string and returns the string to the script. This provides functionality similar to the sprintf function in the C language.
WPrintf The global Wprintf function writes formatted text in a specified text editor window. A reference to the text window is passed as the first function argument. This method provides functionality like the printf function in the C language. The Printf function is similar except that Printf uses the default Script Messages window. The name of the present function means "window printf".

Dialog Functions

These functions use pop-up dialogs to display messages and input data into a script.

GetAbortRetryIgnore The GetAbortRetryIgnore function displays a message in a standard Windows message box containing [Abort], [Retry], and [Ignore] buttons. Use this dialog to query how to proceed after an error occurs.
GetChoice The GetChoice function opens a dialog showing a binary choice to be made. This function returns the choice index and the button that was clicked. All text labels can be configured or defaults can be used.
GetFileName The GetFileName function opens the Windows Open dialog to browse for a file name string. If the [Open] button is clicked, the selected file name is returned.
GetItem The GetItem function opens a dialog showing a list of items in a list box. This function returns the index of the selected item and the button that was clicked. All labels can be configured. This is similar to the GetItemStr function except that it returns the index of the selected string and not the string itself.
GetItemStr The GetItemStr function opens a dialog showing a list of items in a list box. This function returns the string for the selected item plus the button that was clicked. All labels can be configured. This is similar to the GetItem function except that it returns the selected string and not its index.
GetNumber The GetNumber function opens a dialog to request a number. If you click [OK], the entered number is returned.
GetRetryCancel The GetRetryCancel function displays a message in a standard Windows message box containing [Retry] and [Cancel] buttons. Use this dialog to query how to proceed after an error occurs.
GetString The GetString function opens a dialog to request a string. If you click [OK], the entered string is returned.
GetText The GetText function opens a dialog to request a multi-line text string. If you click [OK], the entered text is returned.
GetTrueFalse The GetTrueFalse function opens a dialog showing a True or False choice to be made. This function returns the choice and the button that was clicked. All text labels can be configured or defaults can be used.
GetValue The GetValue function opens a dialog to request a string (or a value). If you click [OK], the entered string is saved to a history list and is returned. The current string is shown in the edit field of the list box. The remaining items in the list box show a history of strings that have been recently used and which may be selected. This function is similar to GetString except that a history list is maintained.
GetYesNo The GetYesNo function displays a message in a standard Windows message box containing [Yes] and [No] buttons. Use this dialog to get a true or false response
GetYesNoCancel The GetYesNoCancel function displays a message in a standard Windows message box containing [Yes], [No], and [Cancel] buttons. The returned value may be tested for which button was pressed.

Miscellaneous Functions

AbbrevPath The AbbrevPath function returns a string that is an abbreviated form of a file path. The returned string is no longer than a specified number of characters. The original name is unchanged.
Assert The Assert function tests a condition and aborts the script if the condition tests false. This function mimics the common C/C++ ASSERT or assert macro.
Beep The Beep function plays a system waveform sound. See the Remarks section for options.
DatatypeToStr The DatatypeToStr function returns the data type name corresponding to the numeric data type code. For example passing 5 returns "float".
Exit The Exit function terminates the script and, optionally, lists a message in the Script Messages window.
GetFileList The GetFileList function returns a table containing the names of files in a folder. The names are included if they match a specified template.
GetFileOpenDlgTitle The GetFileOpenDlgTItle function returns the current title used for Open dialogs.
GetFileSaveDlgTitle The GetFileSaveDlgTitle function returns the current title used for Save As dialogs.
GetFolder The GetFolder function returns the name of a folder. The folder browser can access any folder on the system, including shared network folders and the Windows desktop. The selected folder is returned without a trailing backslash.
GetKeyState The GetKeyState function returns the state of a Windows virtual key. Use this function to poll the status of keyboard keys or mouse keys.
GetMathErrVal The GetMathErrVal function sets a replacement value for math errors.
GetMathErrValStr The GetMathErrValStr function returns the math error value as a string.
GetViewportSize The GetViewportSize function returns the width and height of the interior of the main Mira window.
Include The Include function inserts an additional script file, or "chunk", into a script file. The external chunk is compiled and executed when the Include statement is executed. Any chunk may Include other chunks.
SetFileOpenDlgTitle The SetFileOpenDlgTitle function changes the title of all subsequent Open dialogs. The change persists until the function is called again or the script ends.
SetFileSaveDlgTitle The SetFileSaveDlgTitle function changes the title of all subsequent Save As dialogs. The change persists until the function is called again or the script ends.
SetMathErrVal The SetMathErrVal function specifies the value to be used when Mira traps a numerical error such as division by zero.
SetResampleParams The SetResampleParams function sets default parameters for resampling images.
StrToDatatype The DatatypeToStr function returns the data type number corresponding to the data type name. For example passing float" returns 5.
 


Learn More

Name  *

E-mail  *

Item of Interest

Organization

Telephone

Application

Comments

Verification *