Module QUB

These python objects are built in to QUB.

editTree( tree )

tree      a qubtree.Node
returns      the same tree you passed in

Shows a graphical qubtree browser/editor.

Report( message )

message      Any object compatible with str(message)

Prints message to the Report window.

Dialog( caption, buttons, fields )

caption      a string for the title bar
buttons      a list of captions for the buttons at the bottom
fields      a list of Dialogs.DialogField
returns      a dictionary mapping field.name to value

Shows a dialog with text fields and radio buttons.
Look at result['button'] to find out which button was clicked.
Various types of fields are documented
elsewhere.


CreateWizard()

Creates a Wizard window, initially invisible.

Wizard

A floating window with a message and some buttons.
The user can still interact with other windows while the wizard is visible, so a script can lead the user through a series of steps which require discernment while automating the grunt work.

caption

the window's title

message

a string to put in the window. Separate lines with '\r\n'.

buttons

a list of button titles, from right to left.

show()

Makes the window visible.

hide()

Makes the window invisible.

waitForButton()

Returns the text of the next button pressed (within the wizard window).


DataView

Represents the Data window.

[ index ]

Data: the index'th data

currData

Data: the current data

currIndex

Data: the 0-based index of the chosen file

selectedData

a list of the Data which are highlighted in the list


Data

Represents an open data file.

fileName

the full path of the file on disk

dataChannelCount

read The number of data channels.

activeChannel

read/write the data channel most operations will act on ("Ch" at the top left).

lists

Data.lists: a list of SelectionLists

currResults

the Results which is selected in the list

results

Data.results: a list of results trees

addResults( resultsTree )

resultsTree      a qubtree.Node with Results structure

Adds resultsTree to the list of results, as the last and selected item. It becomes immediately available as thisData.currResults.

copyImage( options = {} )

options      a dictionary of settings that override the "Copy Image" dialog box.

Copies an image of the data to the clipboard. Options can be:
  • DrawData: true/false:
  • DrawIdlData: true/false: draw the idealized data
  • DrawBase: true/false: draw the baseline nodes
  • ScaleBars: true/false: draw scale bars
  • ScaleBarsTop: true/false: draw scale bars above the data (not below)
  • DrawFrame: true/false: draw a box around the data
  • ShowTitles: true/false:
  • Landscape: true/false: draw sideways
  • Bitmap: true/false: draw dots instead of lines
  • Width: integer:
  • Height: integer:
  • HiRes: integer: copy the single-trace zoomed-in window instead

select( first, last )

Selects the interval between first point and last point, inclusive.

getList( name )

name      the name of a selection list

Returns the contents of a selection list as a list of tuples (first, last).

setList( name, list )

name      the name of a selection list
list      a list of tuples (first, last)

Replaces the named selection list with a new list of intervals.
Creates the selection list if none exists by that name.

chooseList( name )

name      the name of a selection list

Brings the named selection list to the front; makes it the current list.


Data.lists

Acts as a list of all SelectionLists for a data file.

[ index ]

SelectionList: the index'th selection list

currList

SelectionList: the active selection list

currIndex

index of the active selection list

delete( index )

Removes the index'th list from the list

indexOf( name )

Returns the index of the (first) list with that name, or -1 if none.

byName( name )

Returns the (first) list with that name, creating it if necessary.

choose( index )

Brings the index'th list to the front.

rename( index, name )

Gives the index'th list a new name.


SelectionList

Represents one selection list

[ index ]

tuple (first, last): the index'th selection

asTree

qubtree.Node: standard List form

setFromTree( tree )

Replaces the contents of the list with the contents of a standard List qubtree.

add( first, last )

Adds the selection to the list.

delete( index )

Removes the index'th selection from the list

rename( index, name )

Gives the index'th list a new name.

clear()

Removes all selections from the list.


Data.results

Acts as a list of all result trees for a data file.

[ index ]

qubtree.Node: the index'th result tree

add( resultsTree )

resultsTree      a qubtree.Node

Adds the results tree and brings it to the front.

delete( index )

Removes the index'th result from the list

choose( index )

Brings the index'th result to the front.


ModelView

An object representing the Model window.
Acts as a list of all open models.

[ index ]

Model: the index'th model

currModel

Model: the current model

currIndex

the number of the current model in the list of models

New()

returns      True on failure

Creates a new Model document with the specified name.

Choose()

Brings a model to the front. The argument is a model object or its index.

makeNewRate()

returns      qubtree.Node

Returns a "Rate" node to add to a Model tree. The rate is filled with the visual defaults, but the State indices are uninitialized.


Model

An object representing one model.

copyImage( options = {} )

options      a dictionary of settings to override the "Copy Image" dialog box

Copies an image of the model to the clipboard. Options can be:
  • DrawFrame: true/false: draw a box around the data
  • ShowTitles: true/false:
  • Landscape: true/false: draw sideways
  • Bitmap: true/false: draw dots instead of lines
  • Width: integer:
  • Height: integer:

CalcPeq()

Equivalent to "Equilibrium P -> Calculate and assign" in the model's context menu.

EnforceConstraints()

Equivalent to "Enforce constraints" in the model's context menu.

getAsNode()

returns      a qubtree.Node with all the info from the model

The result is a copy of the model; changes will not be reflected.

setAsNode( modelTree )

modelTree      a qubtree.Node such as is returned from getAsNode().

Replaces the contents of the model with the contents of modelTree.


ResultsView

An object representing the Results window.
Acts as a list of all open Results documents.

currResults

Results: the current results

selectedResults

a list of all selected Results

[ index ]

Returns the index'th Results

addResults( resultsTree )

resultsTree      a qubtree.Node with structure Results.

Adds a
Results document using resultsTree under the name resultsTree.name.
For lame technical reasons, the new Results will not be immediately available so don't try it.


Results

An object representing a Results document.

node

the qubtree.Node you see in the "As Text" tab.

fileName

the path to the Results document on disk.

visibleVars

a list of the variable names shown as charts in the "Select" tab

segmentCount

the number of data segments

numSD

In the "Select" tab, charts have lines overlaid showing the mean and +/- numSD standard deviations.

chosenColor

The index in range(0,10) of the chosen color in the "Select" and "Criteria" tabs

usedColors

A list of indices of the colors that have been assigned to at least one segment.

colorCounts

colorCounts[i] tells how many segments have color i

criteria

a qubtree.Node representing the contents of the "Criteria" tab

chartCount

the number of charts showing in the Select tab

[ varName ]

Returns the ResultsVar named varName. Use to get the full list of varNames.

keys()

Returns a list of the names of all ResultsVars.

updateSelection()

Draws the charts in "Select" with the current segment colors.
Only necessary if visual updates have been turned off with doUpdates(0).

doUpdates( yesno )

Enables/disables visual updates when you change a segment's color. By default updates are on, but you may want to turn them off temporarily if you're changing the color of several segments at once.

segment( index )

Returns the qubtree.Node of the index'th data segment inside node.

segmentColor( i )

Returns the color index of the i'th segment.

setSegmentColor( i, c )

Gives the i'th segment color index c.

segmentsOfColor( c )

Returns a list of segment indices for which segmentColor(i) == c.

copyChartImage( i )

Copies an image of the i'th visible Select chart to the clipboard.


ResultsVar

An object representing one "Select" variable.
Acts as a list of values, indexed by segment.

yIsLog

true/false whether the chart shows log(y)

xStyle

0: chart index vs. value
1: chart seg start time vs. value
2: chart as a histogram

units

string: the units of this variable, as given in a line comment

[ seg_index ]

Returns the value at one segment.
If yIsLog, returns the log value.

mean( color_index )

Returns the mean value of segments of one color.

sd( color_index )

Returns the standard deviation of the values of segments of one color.

count( color_index )

Returns the number of segments of that color.


GetDataSource()

Returns 'sel', 'list', 'file', or 'file list', as chosen at the upper right. The data source tells which data buttons should act on.

SetDataSource( src )

Sets the data source (upper-right) to 'sel', 'list', 'file', or 'file list'.

getChosenData()

Returns a qubtree.Node, of structure DataSets, describing the regions of data indicated by Data Source (i.e. sel, list, file, or filelist). Pass "Segment" nodes within it to QUB.fillData() to get the actual data points.

getChosenIdealization()

Returns a qubtree.Node, of structure DataSets, describing the regions of data indicated by "Data Source" (i.e. sel, list, file, or filelist). The Active Channel's idealization is included.

fillData( Node )

Given a "Segment" node within a DataSets structure, with segnode.data = [first, last], appends a child node named "Channel" with the data points between first and last, inclusive. You are advised to segnode.remove( segnode["Channel"] ) when you're done so as not to waste memory.

The data will be processed according to the child of DataSet named "ProcessData". By default the data is unprocessed, but you can choose:

>>> dataset['ProcessData'].data = 'AsDisplayed'
-- or --
>>> processData = dataset['ProcessData']
>>> processData.data = 'AsSuch'
>>> processData['Filter'].data = 1 # i.e. true
>>> processData['FilterFreq'].data = 5000.0
>>> processData['Baseline'].data = 0 # i.e. false

fillDataCh( Node )

Lorin made this? Apparently it fills the "Channel" as above, but with all the data channels, non-interleaved, so in other words all of channel 0 then all of channel 1 and so forth.

Caveat: if you process data "AsSuch", all channels will be processed that way.



Simulation

Modeling

Preprocessing

Lists

Sound

Scripts

These are dictionaries containing all the buttons on the right-hand panel.

>>> MIL = QUB.Modeling['MIL Rates']
>>> MIL() # simulate a left-click on MIL
>>> MIL.RClick() # simulate a right-click on MIL
>>> tree = MIL.Properties() # get MIL's current settings
>>> MIL.Properties(tree) # change MIL's current settings