File MIES_MiesUtilities.ipf

This file holds utility functions which need to know about MIES internals.

Functions

variable HorizExpandWithVisX()

Custom graph marquee.

Requires an existing marquee and a graph as current top window

variable GetLogbookType(wave wv)

Return the logbook type, one of LogbookTypes.

wave GetLogbookWaves(variable logbookType, variable logbookWaveType, string device = defaultValue)

Return the logbook waves.

Parameters:
wave ExtractLogbookSliceTimeStamp(wave logbook)

Extract a date/time slice of the logbook wave.

wave ExtractLogbookSliceDeltaTime(wave logbook)

Extract the delta time slice of the logbook wave.

wave ExtractLogbookSliceSweep(wave values)

Extract the sweep number slice of the labnotebook values wave.

wave ExtractLogbookSliceEmpty(wave values)

Extract a slice of the logbook wave and makes it empty.

static wave ExtractLogbookSlice(wave logbook, variable logbookType, variable colOrLayer, string suffix)

Extract a single column/layer of the labnotebook/TPStorage values wave.

This is useful if you want to plot values against e.g time and let Igor do the formatting of the date/time values. Always returns a numerical wave.

The slice is returned as-is if it exists already. Callers which modify the logbook are responsible to resize the slice as well.

wave GetADCListFromConfig(wave config)

Return a list of the AD channels from the DAQ config.

wave GetDACListFromConfig(wave config)

Return a list of the DA channels from the DAQ config.

wave GetTTLListFromConfig(wave config)

Return a list of the TTL channels from the DAQ config.

static wave GetChanneListFromDAQConfigWave(wave config, variable channelType)

Return a wave with all active channels.

Todo:

change to return a 0/1 wave with constant size a la DAG_GetChannelState

Parameters:
variable GetNrOfTypedChannels(wave chanTypes, variable type)

Returns the number of given mode channels from channelType wave.

Parameters:
Returns:

number of types present in chanTypes

wave GetTTLTypesFromConfig(wave config)

Return a types of the AD channels from the ITC config.

wave GetADCTypesFromConfig(wave config)

Return a types of the AD channels from the ITC config.

wave GetDACTypesFromConfig(wave config)

Return a types of the DA channels from the ITC config.

static wave GetTypeListFromITCConfig(wave config, variable channelType)

Return a wave with all active channels.

Todo:

change to return a 0/1 wave with constant size a la DAG_GetChannelState

Parameters:
variable GotTPChannelsOnADCs(string device)

Checks if a channel of TP type exists on ADCs.

Parameters:

device – device

Returns:

1 if TP type present, 0 otherwise

string GetSpecialControlLabel(variable channelType, variable controlType)

Return the dimension label for the special, aka non-unique, controls.

string ChannelTypeToString(variable channelType)

Convert a channel type constant from ChannelTypeAndControlConstants to a string.

variable ParseChannelTypeFromString(string channelType, variable allowFail = defaultValue)

Convert a channel type string from ChannelTypeToString to one of the constants from ChannelTypeAndControlConstants.

UTF_NOINSTRUMENTATION

Parameters:
  • channelType – channel type

  • allowFail – [optional, defaults to false] return NaN on unknown channel types (true) or assert (false)

string GetPanelControl(variable channelIndex, variable channelType, variable controlType)

Returns the name of a control from the DA_EPHYS panel.

Constants are defined at ChannelTypeAndControlConstants

static variable FindRange(wave wv, variable col, variable val, variable forwardORBackward, variable entrySourceType, variable *first, variable *last)

Find the first and last point index of a consecutive range of values in the labnotebook.

Parameters:
  • wv[in] wave to search

  • col[in] column to look for

  • val[in] value to search

  • forwardORBackward[in] find the first(1) or last(0) range

  • entrySourceType[in] type of the labnotebook entry, one of DataAcqModes

  • first[out] point index of the beginning of the range

  • last[out] point index of the end of the range

static variable EnforceIndependentSetting(wave settings)

Test helper to enforce that every query done for an INDEP_HEADSTAGE setting does not search an entry which is HEADSTAGE dependent. The additional check that not all entries are the same is for really old legacy entries which are INDEP but set for all headstages.

Does nothing outside of CI.

variable GetSweepColumn(wave labnotebookValues)

Returns the numerical index for the sweep number column in the settings history waves (numeric and text)

variable GetLastSettingIndep(wave numericalValues, variable sweepNo, string setting, variable entrySourceType, variable defValue = defaultValue)

Return a headstage independent setting from the numerical labnotebook.

See also

GetLastSetting()

Returns:

the headstage independent setting or defValue

string GetLastSettingTextIndep(WaveText textualValues, variable sweepNo, string setting, variable entrySourceType, string defValue = defaultValue)

Return a headstage independent setting from the textual labnotebook.

See also

GetLastSetting()

Returns:

the headstage independent setting or defValue

variable GetLastSettingIndepRAC(wave numericalValues, variable sweepNo, string setting, variable entrySourceType, variable defValue = defaultValue)

Return a headstage independent setting from the numerical labnotebook of the sweeps in the same RA cycle.

See also

GetLastSetting()

Returns:

the headstage independent setting or defValue

variable GetLastSettingIndepSCI(wave numericalValues, variable sweepNo, string setting, variable headstage, variable entrySourceType, variable defValue = defaultValue)

Return a headstage independent setting from the numerical labnotebook of the sweeps in the same SCI cycle.

See also

GetLastSetting()

Returns:

the headstage independent setting or defValue

string GetLastSettingTextIndepSCI(wave numericalValues, WaveText textualValues, variable sweepNo, string setting, variable headstage, variable entrySourceType, string defValue = defaultValue)

Return a headstage independent setting from the textual labnotebook of the sweeps in the same SCI cycle.

See also

GetLastSetting()

Returns:

the headstage independent setting or defValue

string GetLastSettingTextIndepRAC(wave numericalValues, WaveText textualValues, variable sweepNo, string setting, variable entrySourceType, string defValue = defaultValue)

Return a headstage independent setting from the numerical labnotebook of the sweeps in the same RA cycle.

Returns:

the headstage independent setting or defValue

std::tuple<WaveOrNull, variable> GetLastSettingChannel(wave numericalValues, WaveTextOrNull textualValues, variable sweepNo, string setting, variable channelNumber, variable channelType, variable entrySourceType)

Return a numerical or text setting for the given channel.

It also returns headstage independent entries when the given channel refers to an active channel.

Returns:

the wave containing the setting and the index into it.

static std::tuple<WaveOrNull, variable> GetLastSettingChannelInternal(wave numericalValues, wave values, variable sweepNo, string setting, variable channelNumber, variable channelType, variable entrySourceType)

Return a numerical/textual setting for the given channel.

The function takes care of associated/unassociated channel properties and all other internals.

Parameters:
  • numericalValues – numerical labnotebook

  • values – labnotebook to read data from, either numerical or textual

  • sweepNo – sweep number

  • setting – name of the labnotebook entry to search

  • channelNumber – channel number

  • channelType – channel type, one of XopChannelConstants

  • entrySourceType – type of the labnotebook entry, one of DataAcqModes. If you don’t care about the entry source type pass UNKNOWN_MODE.

Returns:

A tuple of the result wave and the index into it.

wave GetLastSetting(wave values, variable sweepNo, string setting, variable entrySourceType)

Return a numeric/textual wave with the latest value of a setting from the numerical/labnotebook labnotebook for the given sweep number.

Parameters:
  • values – numerical/textual labnotebook

  • sweepNo – sweep number

  • setting – name of the setting to query

  • entrySourceType – type of the labnotebook entry, one of DataAcqModes. If you don’t care about the entry source type pass UNKNOWN_MODE.

Returns:

a free wave with LABNOTEBOOK_LAYER_COUNT rows. In case the setting could not be found an invalid wave reference is returned.

wave GetLastSettingNoCache(wave values, variable sweepNo, string setting, variable entrySourceType, variable *first = defaultValue, variable *last = defaultValue, variable *rowIndex = defaultValue)

Return a wave with the latest value of a setting from the numerical/textual labnotebook for the given sweep number. Uncached version, general users should prefer GetLastSetting().

Parameters:
  • values – numerical/textual labnotebook

  • sweepNo – sweep number

  • setting – name of the setting to query

  • entrySourceType – type of the labnotebook entry, one of DataAcqModes

  • first[inout] [optional] Can be used to query and return the labnotebook row range. Useful for routines which must make a lot of queries to the same sweep and want to avoid the overhead of calculating first and last. Passing LABNOTEBOOK_GET_RANGE will set the calculated values of first and last after the function returns. Passing a value greater or equal zero will use these values instead.

  • last[inout] [optional] see first

  • rowIndex[out] [optional] return the row where the setting could be found, otherwise it is set to LABNOTEBOOK_MISSING_VALUE

Returns:

a free wave with LABNOTEBOOK_LAYER_COUNT rows. In case the setting could not be found an invalid wave reference is returned.

wave GetLastSettingTextRAC(wave numericalValues, WaveText textualValues, variable sweepNo, string setting, variable entrySourceType)

Return the last textual value of the sweeps in the same RA cycle.

See also

GetLastSetting()

wave GetLastSettingRAC(wave numericalValues, variable sweepNo, string setting, variable entrySourceType)

Return the last numerical value of the sweeps in the same RA cycle.

See also

GetLastSetting()

wave GetLastSettingIndepEachRAC(wave numericalValues, variable sweepNo, string setting, variable entrySourceType, variable defValue = defaultValue)

Return the last numerical value for the given setting of each sweep in the same RA cycle.

The returned wave will have NaN for sweeps which do not have that entry. This is done in order to keep the indizes intact.

See also

GetLastSetting()

wave GetLastSettingTextIndepEachRAC(wave numericalValues, WaveText textualValues, variable sweepNo, string setting, variable entrySourceType, string defValue = defaultValue)

Return the last textual value for the given setting of each sweep in the same RA cycle.

The returned wave will have NaN for sweeps which do not have that entry. This is done in order to keep the indizes intact.

See also

GetLastSetting()

wave GetLastSettingEachRAC(wave numericalValues, variable sweepNo, string setting, variable headstage, variable entrySourceType)

Return the last numerical value for the given setting of each sweep for a given headstage in the same RA cycle.

The returned wave will have NaN for sweeps which do not have that entry. This is done in order to keep the indizes intact.

See also

GetLastSetting

wave GetLastSettingTextEachRAC(wave numericalValues, WaveText textualValues, variable sweepNo, string setting, variable headstage, variable entrySourceType)

Return the last textual value for the given setting of each sweep for a given headstage in the same RA cycle.

The returned wave will have NaN for sweeps which do not have that entry. This is done in order to keep the indizes intact.

See also

GetLastSetting()

wave GetLastSettingTextSCI(wave numericalValues, WaveText textualValues, variable sweepNo, string setting, variable headstage, variable entrySourceType)

Return the last textual value of the sweeps in the same stimset cycle.

See also

GetLastSetting()

wave GetLastSettingSCI(wave numericalValues, variable sweepNo, string setting, variable headstage, variable entrySourceType)

Return the last numerical value of the sweeps in the same stimset cycle.

See also

GetLastSetting()

wave GetLastSettingIndepEachSCI(wave numericalValues, variable sweepNo, string setting, variable headstage, variable entrySourceType, variable defValue = defaultValue)

Return the last numerical value for the given setting of each sweep in the same stimset cycle.

The returned wave will have NaN for sweeps which do not have that entry. This is done in order to keep the indizes intact.

See also

GetLastSetting()

wave GetLastSettingTextIndepEachSCI(wave numericalValues, WaveText textualValues, variable sweepNo, variable headstage, string setting, variable entrySourceType, string defValue = defaultValue)

Return the last textual value for the given setting of each sweep in the same stimset cycle.

The returned wave will have NaN for sweeps which do not have that entry. This is done in order to keep the indizes intact.

See also

GetLastSetting()

wave GetLastSettingEachSCI(wave numericalValues, variable sweepNo, string setting, variable headstage, variable entrySourceType)

Return the last numerical value for the given setting of each sweep for a given headstage in the same stimset cycle.

The returned wave will have NaN for sweeps which do not have that entry. This is done in order to keep the indizes intact.

See also

GetLastSetting

wave GetLastSettingTextEachSCI(wave numericalValues, WaveText textualValues, variable sweepNo, string setting, variable headstage, variable entrySourceType)

Return the last textual value for the given setting of each sweep for a given headstage in the same stimset cycle.

The returned wave will have NaN for sweeps which do not have that entry. This is done in order to keep the indizes intact.

See also

GetLastSetting()

wave GetNonEmptyLBNRows(wave labnotebookValues, string setting)

Return a wave with all labnotebook rows which have a non-empty entry for setting.

wave GetSweepsWithSetting(wave labnotebookValues, string setting)

Return a wave with all sweep numbers which have a non-empty entry for setting.

Parameters:
  • labnotebookValues – numerical/textual labnotebook

  • setting – name of the value to search

Returns:

a 1D free wave with the matching sweep numbers. In case the setting could not be found an invalid wave reference is returned.

wave GetLastSweepWithSetting(wave numericalValues, string setting, variable *sweepNo)

Return the last numerical value of a setting from the labnotebook and the sweep it was set.

Parameters:
  • numericalValues[in] numerical labnotebook

  • setting[in] name of the value to search

  • sweepNo[out] sweep number the value was last set

Returns:

a free wave with LABNOTEBOOK_LAYER_COUNT rows. In case the setting could not be found an invalid wave reference is returned.

variable GetLastSweepWithSettingIndep(wave numericalValues, string setting, variable *sweepNo, variable defValue = defaultValue)

Return the last numerical value of a headstage independent setting from the labnotebook and the sweep it was set.

Parameters:
  • numericalValues[in] numerical labnotebook

  • setting[in] name of the value to search

  • sweepNo[out] sweep number the value was last set

  • defValue[in] [optional, defaults to NaN] value to return in case nothing could be found

wave GetLastSweepWithSettingText(WaveText textualValues, string setting, variable *sweepNo)

Return the last textual value of a setting from the labnotebook and the sweep it was set.

Parameters:
  • textualValues[in] textual labnotebook

  • setting[in] name of the value to search

  • sweepNo[out] sweep number the value was last set

Returns:

a free wave with LABNOTEBOOK_LAYER_COUNT rows. In case the setting could not be found an invalid wave reference is returned.

string GetLastSweepWithSettingTextI(wave numericalValues, string setting, variable *sweepNo, string defValue = defaultValue)

Return the last textual value of a headstage independent setting from the labnotebook and the sweep it was set.

Parameters:
  • numericalValues[in] numerical labnotebook

  • setting[in] name of the value to search

  • sweepNo[out] sweep number the value was last set

  • defValue[in] [optional, defaults to an empty string] value to return in case nothing could be found

string GetAllDevices()

Returns a list of all devices, e.g. “ITC18USB_Dev_0;…” which were locked at some point.

static variable DeviceHasUserComments(string device)
string GetAllDevicesWithContent(variable contentType = defaultValue)

Returns a list of all devices, e.g. “ITC18USB_Dev_0;”, which have content.

Parameters:

contentType – [optional, defaults to CONTENT_TYPE_SWEEP] type of content to look for, one of CONTENT_TYPES

variable KillOrMoveToTrash(WaveOrNull wv = defaultValue, dfref dfr = defaultValue)

Convenience wrapper for KillOrMoveToTrashPath()

variable KillOrMoveToTrashPath(string path)

Delete a datafolder or wave. If this is not possible, because Igor has locked the file, the wave or datafolder is moved into a trash folder named root:mies:trash_$digit.

The trash folders will be removed, if possible, from KillTemporaries().

Parameters:

path – absolute path to a datafolder or wave

variable MoveToTrash(WaveOrNull wv = defaultValue, dfref dfr = defaultValue)
wave GetDAQDataSingleColumnWaves(dfref sweepDFR, variable channelType)

Return a wave reference wave with all single column waves of the given channel type.

Holds invalid wave refs for non-existing entries.

See also

GetDAQDataSingleColumnWave() or SplitSweepIntoComponents()

Parameters:
  • sweepDFR – datafolder reference with 1D sweep data

  • channelType – One of XopChannelConstants

wave GetDAQDataSingleColumnWaveNG(wave numericalValues, WaveText textualValues, variable sweepNo, dfref sweepDFR, variable channelType, variable GUIchannelNumber)

Return a 1D sweep data wave previously created by SplitSweepIntoComponents()

Returned wave reference can be null.

Parameters:
  • numericalValues – numerical labnotebook

  • textualValues – textual labnotebook

  • sweepNo – sweep number

  • sweepDFR – datafolder holding 1D waves

  • channelType – One of XopChannelConstants

  • GUIchannelNumber – GUI channel number

wave GetDAQDataSingleColumnWave(dfref sweepDFR, variable channelType, variable channelNumber, variable splitTTLBits = defaultValue, variable ttlBit = defaultValue)

Return a 1D data wave previously created by SplitSweepIntoComponents()

Returned wave reference can be invalid.

Parameters:
  • sweepDFR – datafolder holding 1D waves

  • channelType – One of XopChannelConstants

  • channelNumber – hardware channel number

  • splitTTLBits – [optional, defaults to false] return a single bit of the TTL wave

  • ttlBit – [optional] number specifying the TTL bit

variable IsValidSweepNumber(variable sweepNo)

Check if the given sweep number is valid.

UTF_NOINSTRUMENTATION

variable IsValidEpochNumber(variable epochNo)

Check if the given epoch number is valid.

wave GetConfigWave(wave sweepWave)

Returns the config wave for a given sweep wave.

wave GetSweepWave(string device, variable sweepNo)

Returns the, possibly non existing, sweep data wave for the given sweep number There are two persistent formats how sweep data is stored.

The current format is: The sweep wave is a 1D text wave. Each entry contains the relative path to a single channel wave, including the wave name. The reference data folder for the relative path is the data folder where the sweep wave is located. The number of rows of the sweep wave equals the number of columns of the config wave and indexes the channels. Thus, the sweep wave can not be a free wave.

The deprecated format is: A 2D numeric wave, where the rows are the sample points and the columns the sweep channels. In that format all channels have the same number of points and the same sample interval. The sample interval is saved a ROW DimDelta. The number of columns equals the number of columns of the config waves and indexes the channels.

Intermediate sweep wave format: Intermediate sweep format is used in some parts of MIES, e.g. NWB saving as it is easier to handle. The sweep wave is a wave reference wave, where each element refers to a channel. It can be a free wave. The number of rows of the sweep wave equals the number of columns of the config wave and indexes the channels. To convert a text sweep wave to a waveRef sweep wave use TextSweepToWaveRef The programmer has to consider if pure references to channels are good enough (TextSweepToWaveRef) or if the channels should be duplicated.

string GetConfigWaveName(variable sweepNo)

Return the config wave name.

string GetSweepWaveName(variable sweepNo)

Return the sweep wave name.

variable GetSamplingInterval(wave config)

Returns the sampling interval of the sweep in microseconds (1e-6s)

variable GetDataOffset(wave config)

Returns the data offset of the sweep in points.

variable UpdateSweepConfig(wave config, variable samplingInterval = defaultValue)

Write the given property to the config wave.

Note

Please add new properties as required

Parameters:
  • config – configuration wave

  • samplingInterval – sampling interval in microseconds (1e-6s)

variable GetHardwareType(string device)

Return the hardware type of the device.

UTF_NOINSTRUMENTATION

Returns:

One of HardwareDACTypeConstants

variable ParseDeviceString(string device, string *deviceType, string *deviceNumber)

Parse a device string: for ITC devices of the form X_DEV_Y, where X is from DEVICE_TYPES_ITC and Y from DEVICE_NUMBERS. for NI devices of the form X, where X is from DAP_GetNIDeviceList()

Returns the result in deviceType and deviceNumber. Currently the parsing is successfull if for ITC devices X and Y are non-empty. for NI devices X is non-empty. deviceNumber is empty for NI devices as it does not apply

UTF_NOINSTRUMENTATION

Parameters:
  • device[in] input device string X_DEV_Y

  • deviceType[out] returns the device type X

  • deviceNumber[out] returns the device number Y

Returns:

one on successfull parsing, zero on error

variable LayoutGraph(string win, TiledGraphSettings *tgs)

Layout the DataBrowser/SweepBrowser graph.

Takes also care of adding free axis for the headstage display.

Concept:

  • Block [#]: One axis with surrounded GRAPH_DIV_SPACING space

  • Slot [#]: Unit of vertical space, a block can occupy multiple slots

  • We have 100% space for all axes

  • AD axes should occupy four times the space of DA/TTL channels

  • So DA/TTL occupy one slot, AD occupy four slots

  • Between each axes we want GRAPH_DIV_SPACING clear space

  • Count the number of vertical blocks and slots to be used

  • Derive the space per slot

  • For overlay channels we reserve only one slot times slot multiplier per channel

The display order from top to bottom:

  • Associated channels (above: DA, below: AD) with increasing headstage number

  • Unassociated channels (above: DA, below: AD)

  • TTL channels

For overlayed channels we have up to three blocks (DA, AD, TTL) in that order.

static variable TweakAxes(string graph, TiledGraphSettings *tgs, WaveText allVerticalAxes, WaveText allHorizontalAxes)
static variable EnableAxis(string graph, WaveText axes, variable spacePerSlot, variable *first, variable *last)

Helper function for LayoutGraph()

Enables the given axis between [last - spacePerSlot, last] and updates both on return. Expects last to be 1.0 on the first call.

variable GetNextTraceIndex(string graph)

Helper function for CreateTiledChannelGraph and friends.

Return the next trace index for a graph which uses our trace data storage wave.

variable CreateTiledChannelGraph(string graph, wave config, variable sweepNo, wave numericalValues, WaveText textualValues, TiledGraphSettings *tgs, dfref sweepDFR, WaveText axisLabelCache, variable *traceIndex, string experiment, wave channelSelWave, BufferedDrawInfo *bdi = defaultValue)

Create a vertically tiled graph for displaying AD and DA channels.

For preservering the axis scaling callers should do the following:

WAVE ranges = GetAxesRanges(graph)

CreateTiledChannelGraph()

    SetAxesRanges(graph, ranges)

Parameters:
  • graph – window

  • config – DAQ config wave

  • sweepNo – number of the sweep

  • numericalValues – numerical labnotebook wave

  • textualValues – textual labnotebook wave

  • tgs – settings for tuning the display, see TiledGraphSettings

  • sweepDFR – top datafolder to splitted 1D sweep waves

  • axisLabelCache – store existing vertical axis labels

  • traceIndex – [internal use only] set to zero on the first call in a row of successive calls

  • experiment – name of the experiment the sweep stems from

  • channelSelWave – channel selection wave

  • bdi – [optional, default = n/a] initialized BufferedDrawInfo structure, when given draw calls are buffered instead for later execution

string GetTraceNamePrefix(variable traceIndex)

Return a trace name prefix suitable for GetNextTraceIndex()

variable TiledGraphAccelerateDraw(BufferedDrawInfo *bdi)

Runs through all graph groups in the json and appends them to the graph.

static variable TiledGraphAccelerateAppendTracesImpl(string w, string v, string h, variable r, variable g, variable b, wave y, WaveText t, WaveRefWave d)

Appends a group of traces to a graph, properties w to b must be constant for the group.

Parameters:
  • w[in] name of graph window

  • v[in] name of vertical axis

  • h[in] name of horizontal axis

  • r[in] red color component

  • g[in] green color component

  • b[in] blue color component

  • y[in] 1D wave with indices into wave d for the actual plot data

  • t[in] 1D wave with trace names, same size as y

  • d[in] wave reference wave with plot data

std::tuple<RGBColor> GetHeadstageColor(variable headstage, variable channelType = defaultValue, variable channelNumber = defaultValue, variable isSplitted = defaultValue)

Return the color of the given headstage.

Parameters:
  • headstage – Headstage, Use “NaN” for non-associated channels

  • channelType – [optional, empty by default] The channel type for non-associated channels, currently only XOP_CHANNEL_TYPE_TTL is evaluated

  • channelNumber – [optional, empty by default] For plotting “TTL” channels only, GUI channel number

  • isSplitted – [optional, default 1] For plotting “TTL” channels only, Flag if the color for a splitted or unsplitted channel should be returned

variable EquallySpaceAxis(string graph, string axisRegExp = defaultValue, variable axisOffset = defaultValue, variable axisOrientation = defaultValue, variable sortOrder = defaultValue, string listForBegin = defaultValue, string listForEnd = defaultValue)

Space the matching axis in an equal manner.

Parameters:
  • graph – graph

  • axisRegExp – [optional, defaults to “.*”] regular expression matching the axes names

  • axisOffset – [optional, defaults to 0] offset of first axis in parts of total width

  • axisOrientation – [optional, defaults to all] allows to apply equalization to all axis of one orientation

  • sortOrder – [optional, defaults to no sorting (NaN)] apply different sorting schemes to list of axes, see sortingOrder parameter of SortList

  • listForBegin – [optional, defaults to an empty list] list of axes to move to the front of the sorted axis list

  • listForEnd – [optional, defaults to an empty list] list of axes to move to the end of the sorted axis list

variable EquallySpaceAxisPA(string graph, string allAxes, string distAxes, variable axisOffset = defaultValue)

This is a light weight adapted version of.

See also

EquallySpaceAxis It allows to give a list of distAxes that do not require to exist. Non-existing axes are taken into account on the distribution, but are skipped when the graph is accessed. Also removing images from a graph does not update AxisList until the graph is updated, so we can not rely on Axislist here as we do the Layout after pending changes So with allAxes = “1;2;3;4;” and distAxes = “2;3;” axis 2 and 3 are set at 25% to 50% and 50% to 75% respectively.

Parameters:
  • graph[in] Name of graph where axes from distAxes list exist

  • allAxes[in] List of all axes, that should be distributed. May include non-existing axes.

  • distAxes[in] List of axes that are distributed. Only axes that appear in allAxes as well are modified.

  • axisOffset[in] [optional, default = 0] offset between 0 and 1 where distribution starts.

variable SaveExperimentSpecial(variable mode)

Save the current experiment under a new name and clear all/some data.

Parameters:

mode – mode for generating the experiment name, one of SaveExperimentModes

string CleanupExperimentName(string expName)

Cleanup the experiment name.

variable GetNumberFromType(variable var = defaultValue, string str = defaultValue, variable xopVar = defaultValue)

Return the maximum count of the given type.

Parameters:
  • var – numeric channel types

  • str – string channel types

  • xopVar – numeric XOP channel types

wave ExtractOneDimDataFromSweep(wave config, wave sweep, variable index)

Extract an one dimensional wave from the given sweep/hardware data wave and column.

Parameters:
  • config – config wave

  • sweep – sweep wave or hardware data wave from all hardware types

  • index – index into sweep, can be queried with AFH_GetDAQDataColumn

Returns:

a reference to a free wave with the single channel data

variable PostPlotTransformations(string win, variable mode, WaveOrNull additionalData = defaultValue)

Perform common transformations on the graphs traces.

Keeps track of all internal details wrt. to the order of the operations, backups, etc.

Needs to be called after adding/removing/updating sweeps via AddSweepToGraph(), RemoveSweepFromGraph(), UpdateSweepInGraph().

Parameters:
  • win – graph with sweep traces

  • mode – update mode, one of PostPlotUpdateModes

  • additionalData – [optional, defaults to invalid wave reference] additional data for subsequent users. Currently supported:

    • POST_PLOT_REMOVED_SWEEPS -> OVS indizes of the removed sweep

    • POST_PLOT_ADDED_SWEEPS -> OVS indizes of the added sweep Use OVS_GetSweepAndExperiment() to convert an index into a sweep/experiment pair.

static variable InitPostPlotSettings(string win, PostPlotSettings *pps)
variable TimeAlignMainWindow(string graph, PostPlotSettings *pps)

Time Alignment for the BrowserSettingsPanel.

This function should work for any given reference trace in pps.timeAlignRefTrace in the popup menu. (DB and SB)

Parameters:
  • graph – graph with sweep traces

  • pps – settings

string TimeAlignGetAllTraces(string graph)

return a list of all traces relevant for TimeAlignment

variable TimeAlignHandleCursorDisplay(string win)

Adds or removes the cursors from the graphs depending on the panel settings.

Parameters:

win – main DB/SB graph or any subwindow panel.

variable TimeAlignUpdateControls(string win)

Enable/Disable TimeAlignment Controls and Cursors.

variable TimeAlignCursorMovedHook(WMWinHookStruct *s)
wave GetAllSweepTraces(string graphs, variable region = defaultValue, variable channelType = defaultValue, variable prefixTraces = defaultValue)

Get a textwave of all traces from a list of graphs.

Parameters:
  • graphs – semicolon separated list of graph names

  • region – [optional] return only traces with the specified region userdata entry

  • channelType – [optional] return only the traces with the given channel type

  • prefixTraces – [optional, defaults to true] prefix the traces names with the graph name and a #

Returns:

graph::trace named patterns

wave GetSweepUserData(string graph, string key, variable channelType = defaultValue, variable region = defaultValue)
static variable AverageWavesFromSameYAxisIfReq(string graph, variable averagingEnabled, dfref averageDataFolder, variable hideSweep)

Average traces in the graph from the same y-axis and append them to the graph.

Parameters:
  • graph – graph with traces create by CreateTiledChannelGraph

  • averagingEnabled – switch if averaging is enabled or not

  • averageDataFolder – permanent datafolder where the average waves can be stored

  • hideSweep – are normal channel traces hidden or not

wave CalculateAverage(WaveRefWave waveRefs, dfref averageDataFolder, string averageWaveName, variable skipCRC = defaultValue, variable writeSourcePaths = defaultValue, wave inputAverage = defaultValue)

Calculate the average of a list of waves, wrapper for MIES_fWaveAverage().

For performance enhancements:

  • The average waves are cached

  • References to existing average waves are returned in case they already exist

Parameters:
  • waveRefs – waves to average in a wave reference wave

  • averageDataFolder – folder where the data is to be stored

  • averageWaveName – base name of the averaged data

  • skipCRC – [optional, defaults to false] Add the average wave CRC as suffix to its name

  • writeSourcePaths – [optional, defaults to true] Write the full paths of the source waves into the average wave note

  • inputAverage – [optional, defaults to invalid wave ref] Override the average calculation and use the given wave as result. This is relevant for callers which want to leverage MultiThread statements together with MIES_fWaveAverage.

Returns:

wave reference to the average wave

wave ConvertFreeWaveToPermanent(wave freeWave, dfref dfr, string wName)

Converts a free wave to a permanent wave with Overwrite.

Parameters:
  • freeWave[in] wave that should be converted to a permanent wave

  • dfr[in] data folder where permanent wave is stored

  • wName[in] name of permanent wave that is created

Returns:

wave reference to the permanent wave

wave MoveFreeWaveToPermanent(wave freeWave, dfref dfr, string wvName)
static variable ZeroTracesIfReq(string graph, WaveTextOrNull traces, variable zeroTraces)

Zero all given traces.

variable TimeAlignmentIfReq(string graphtrace, variable mode, variable level, variable pos1x, variable pos2x, variable force = defaultValue)

Perform time alignment of features in the sweep traces.

Parameters:
  • graphtrace – reference trace in the form of graph::trace

  • mode – time alignment mode

  • level – level input to the FindLevel operation in

  • pos1x – specify start range for feature position

  • pos2x – specify end range for feature position

  • force – [optional, defaults to false] redo time aligment regardless of wave note

static variable CalculateFeatureLoc(wave wv, variable mode, variable level, variable first, variable last)

Find the given feature in the given wave range first and last are in x coordinates and clipped to valid values.

variable EqualizeVerticalAxesRanges(string graph, variable ignoreAxesWithLevelCrossing = defaultValue, variable level = defaultValue, variable rangePerClampMode = defaultValue)

Equalize all vertical axes ranges so that they cover the same range.

Parameters:
  • graph – graph

  • ignoreAxesWithLevelCrossing – [optional, defaults to false] ignore all vertical axis which cross the given level in the visible range

  • level – [optional, defaults to zero] level to be used for ignoreAxesWithLevelCrossing=1

  • rangePerClampMode – [optional, defaults to false] use separate Y ranges per clamp mode

variable ExtractSweepNumber(string str)

Extract the sweep number from a $something_* string.

string GetListOfUnlockedDevices()

Return the list of unlocked DA_Ephys panels.

string GetListOfLockedDevices()

Return the list of locked devices.

string GetListOfLockedITC1600Devices()

Return the list of locked ITC1600 devices.

variable GetStimSetType(string setName)

Return the type, CHANNEL_TYPE_DAC, CHANNEL_TYPE_TTL or CHANNEL_TYPE_UNKNOWN, of the stimset.

All callers must ensure that they can handle the unexpected CHANNEL_TYPE_UNKNOWN properly.

dfref GetSetFolder(variable channelType)

Return the stimset folder from the numeric channelType, CHANNEL_TYPE_DAC or CHANNEL_TYPE_TTL.

Returns:

Data Folder reference to Stimset dataFolder

string GetSetFolderAsString(variable channelType)

Return the stimset folder from the numeric channelType, CHANNEL_TYPE_DAC or CHANNEL_TYPE_TTL.

Returns:

String with full path to Stimset dataFolder

dfref GetSetParamFolder(variable channelType)

Get the stimset parameter folder.

Parameters:

channelTypeCHANNEL_TYPE_DAC or CHANNEL_TYPE_TTL

Returns:

dataFolder as DFREF

string GetSetParamFolderAsString(variable channelType)

Get the stimset parameter folder.

Parameters:

channelTypeCHANNEL_TYPE_DAC or CHANNEL_TYPE_TTL

Returns:

dataFolder as String

variable GetTTLBits(wave numericalValues, variable sweep, variable channel)

Get the TTL bit mask from the labnotebook.

Parameters:
  • numericalValues – Numerical labnotebook values

  • sweep – Sweep number

  • channel – TTL hardware channel

variable GetUsedHWDACFromLNB(wave numericalValues, variable sweep)

Returns the used hardware DAC type from the LNB.

See also

HardwareDACTypeConstants

Parameters:
  • numericalValues – Numerical labnotebook values

  • sweep – Sweep number

Returns:

used hardware dac type

static wave GetActiveChannelsTTL(wave numericalValues, wave textualValues, variable sweep, variable TTLmode)

Return a wave with the requested TTL channel information defined by TTLmode.

Parameters:
  • numericalValues – Numerical labnotebook values

  • textualValues – Text labnotebook values

  • sweep – Sweep number

  • TTLmode – One of ActiveChannelsTTLMode.

wave GetActiveChannels(wave numericalValues, wave textualValues, variable sweepNo, variable channelType, variable TTLmode = defaultValue)

Return a fixed size wave with the the active channels for the given channel type.

The function takes into account unassociated DA/AD channels as well. It returns fixed size waves with the active entries having the same value as their index. This allows users to either remove unused entries and use the wave as active entries list or use the whole wave where not being NaN is active.

With the following DAEphys setup (only the first four channels are shown)

Nr

DA

AD

TTL

0

1

2

3

this function returns the following:

  • DA: {NaN,  1, NaN, NaN, ...}

  • AD: {0, NaN, NaN, NaN, ...}

  • TTL:

    • NI hardware (regardless of TTLmode): {NaN, NaN, 2, 3, ...}

    • ITC hardware with TTLmode, example for two active racks:

      • TTL_DAEPHYS_CHANNEL: {NaN, NaN, 2, 3, NaN, 5, NaN, NaN}

      • TTL_HARDWARE_CHANNEL: {0, NaN, NaN, 3, NaN, NaN, Nan, NaN}

      • TTL_GUITOHW_CHANNEL: returns a 2D wave that allows to index by GUI channel (row) and retrieve hardware channel number and ttlbit number. The columns are %HWCHANNEL and %TTLBITNR. The %TTLBITNR column is only valid for ITC hardware.

      • TTL_HWTOGUI_CHANNEL: returns a 2D wave that allows to index by hardware channel number and TTL bit number and retrieve the GUI channel number. The hardware channel is indexed in the row and the TTL bit number in the column dimension. For NI hardware the TTL bit index should be zero. Inactive hardware channel/ttlbit combinations return NaN.

Parameters:
variable GetIndexForHeadstageIndepData(wave values)

Return the index for headstage independent data.

Before dfe2d862 (Make the function AB_SplitTTLWaveIntoComponents available for all, 2015-10-07) we stored headstage independent data in either all entries or only the first one. Since that commit we store the data in INDEP_HEADSTAGE.

wave GetTTLLabnotebookEntry(WaveText textualValues, string name, variable sweep)

Return a list of TTL stimsets which are indexed by DAEphys TTL channels.

The indexing here is hardware independent. For ITC hardware the assertion “log(ttlBit)/log(2) == DAEphys TTL channel” holds.

Parameters:
  • textualValues – Text labnotebook values

  • name – One of LabnotebookTTLNames

  • sweep – Sweep number

string GetWaveBuilderParameterTypeName(variable type)

Return the name short String of the Parameter Wave used in the WaveBuilder.

Parameters:

type – One of ParameterWaveTypes

Returns:

name as string

wave GetAllDAEphysSetVarNum(string device, variable channelType, variable controlType)

Returns the mode of all setVars in the DA_Ephys panel of a controlType.

wave GetAllDAEphysSetVarTxT(string device, variable channelType, variable controlType)

Returns the mode of all setVars in the DA_Ephys panel of a controlType.

wave GetAllDAEphysPopMenuIndex(string device, variable channelType, variable controlType)

Returns the index of all popupmenus in the DA_Ephys panel of a controlType.

wave GetAllDAEphysPopMenuString(string device, variable channelType, variable controlType)

Returns the string contents of all popupmenus in the DA_Ephys panel of a controlType.

string ExtractAnalysisFuncFromStimSet(wave stimSet, variable eventType)

Extract the analysis function name from the wave note of the stim set.

Returns:

Analysis function for the given event type, empty string if none is set

string ExtractAnalysisFunctionParams(wave stimSet)

Return the analysis function parameters as comma (,) separated list.

See also

GetWaveBuilderWaveTextParam() for the exact format.

static variable SplitTTLWaveIntoComponents(wave data, variable ttlBits, dfref targetDFR, string wavePrefix, variable rescale, variable createBackup)

Split TTL data into a single wave for each bit.

This function is only for data from ITC hardware.

The created waves will be named TTL_3_3 so the final suffix is the running TTL Bit.

Parameters:
  • data – 1D channel data extracted by ExtractOneDimDataFromSweep

  • ttlBits – bit mask of the active TTL channels form e.g. GetTTLBits

  • targetDFR – datafolder where to put the waves, can be a free datafolder

  • wavePrefix – prefix of the created wave names

  • rescale – One of TTLRescalingOptions. Rescales the data to be in the range [0, 1] when on, does no rescaling when off.

  • createBackup – when set then backups are created

variable CloseNWBFile()

Close a possibly open export-into-NWB file.

We have only one NWB file open for all running devices

variable IsDeviceActiveWithBGTask(string device, string task)

Check wether the given background task is running and that the device is active in multi device mode.

string CalcHashForFile(string path, variable method = defaultValue)

Calculate a cryptographic hash for the file contents of path.

Parameters:
  • path – absolute path to a file

  • method – [optional, defaults to HASH_SHA2_256] Type of cryptographic hash function, one of HASH_SHA2_256

variable CheckIfPathsRefIdenticalFiles(string list)

Check if the file paths referenced in list are pointing to identical files.

variable RemoveFreeAxisFromGraph(string graph)

Remove all free axis from the given graph.

variable RemoveDrawLayers(string graph)

Remove all draw layers from the graph.

variable RemoveTracesFromGraph(string graph, string trace = defaultValue, WaveOrNull wv = defaultValue, dfref dfr = defaultValue)

Remove traces from a graph.

Only one of trace/wv/dfr may be supplied.

Parameters:
  • graph – graph

  • trace – [optional, default: all] remove the given trace only

  • wv – [optional, default: ignored] remove all traces which stem from the given wave

  • dfr – [optional, default: ignored] remove all traces which stem from one of the waves in dfr

variable RestoreFromBackupWavesForAll(dfref dfr)

Looks for backup waves in the datafolder and recreates the original waves from them. The original waves do not need to be present. If present they are overwritten. This is different to RestoreFromBackupWavesForAll, where the original waves need to be existing.

variable CreateBackupWavesForAll(dfref dfr)

Create backup waves for all waves in the datafolder.

static string GetBackupNameOfWave(wave wv)
static wave GetBackupWave_TS(wave wv)
wave CreateBackupWave(wave wv, variable forceCreation = defaultValue)

Create a backup of the wave wv if it does not already exist or if forceCreation is true.

The backup wave will be located in the same data folder and its name will be the original name with WAVE_BACKUP_SUFFIX appended. If the backup wave exists and the main type of the backup wave can be overridden by Duplicate/O then the wave reference of the backup wave is kept. Otherwise the main type is changed and the wave reference is not kept (e.g. backup wave is numerical, original wave is text)

wave GetBackupWave(wave wv)

Return a wave reference to the possibly not existing backup wave.

variable ReplaceWaveWithBackupForAll(dfref dfr)

Replace all waves from the datafolder with their backup.

wave ReplaceWaveWithBackup(wave wv, variable nonExistingBackupIsFatal = defaultValue, variable keepBackup = defaultValue)

Replace the wave wv with its backup. If possible the backup wave will be killed afterwards. If the backup wave exists then the wave reference of the restored wave stays the same. Thus the returned wave reference equals the wv wave reference.

Parameters:
  • wv – wave to replace by its backup

  • nonExistingBackupIsFatal – [optional, defaults to true] behaviour for the case that there is no backup. Passing a non-zero value will abort if the backup wave does not exist, with zero it will just do nothing.

  • keepBackup – [optional, defaults to false] don’t delete the backup after restoring from it

Returns:

wave reference to the restored data, in case of no backup an invalid wave reference

variable DuplicateWaveAndKeepTargetRef(WaveOrNull source, WaveOrNull target)

Duplicate a source wave to a target wave and keep the target wave reference intact. Use with free/local waves. For global waves use “Duplicate/O source, target”.

Parameters:
  • source – source wave

  • target – target wave

variable SaveExperimentWrapper(string path, string filename, variable overrideInteractiveMode = defaultValue)

Returns 1 if the user cancelled, zero if SaveExperiment was called.

It is currently not possible to check if SaveExperiment was successfull (E-Mail from Howard Rodstein WaveMetrics, 30 Jan 2015)

Parameters:
  • path – Igor symbolic path where the experiment should be stored

  • filename – filename of the experiment including suffix, usually PACKED_FILE_EXPERIMENT_SUFFIX

  • overrideInteractiveMode – [optional, defaults to GetInteractiveMode()] Overrides the current setting of the interactive mode

variable SearchForDuplicates(wave wv)

Detects duplicate values in a 1d wave.

Returns:

one if duplicates could be found, zero otherwise

variable IsITC1600(string device)

Check that the device is of type ITC1600.

string GetProgramFilesFolder()

Return a path to the program folder with trailing dir separator.

Hardcoded as Igor does not allow to query that information.

Distinguishes between i386 and x64 Igor versions

string GetDefaultElectrodeName(variable headstage)

Return the default name of a electrode.

string CreateLBNUnassocKey(string setting, variable channelNumber, variable channelType)

Create a labnotebook key for unassociated channels.

We support two types of unassociated keys. Old style, prior to 403c8ec2 (Merge pull request #370 from AllenInstitute/feature/sweepformula_enable, 2019-11-13) but after its introduction in ad8dc8ec (Allow AD/DA channels not associated with a headstage again, 2015-10-22) are written as “$Name UNASSOC_$ChannelNumber”.

New style have the format “$Name u_(AD|DA)$ChannelNumber”, these include the channel type to make them more self explaining.

string CreateTTLChannelLBNKey(string entry, variable channelNumber)

Create a LBN key for TTL channels.

variable IsUnassocLBNKey(string name)

Check if the given labnotebook entry is from an unassociated DA/AD channel.

string RemoveUnassocLBNKeySuffix(string name)

Remove the unassociated, old and new, prefix of the given labnotebook entry name.

variable GetZeroMQXOPFlags()
variable StartZeroMQSockets(variable forceRestart = defaultValue)

Start the ZeroMQ sockets and the message handler.

Debug note: Tracking the connection state can be done via netstat | grep $port. The binded port only shows up after a successfull connection with zeromq_client_connect() is established.

Returns:

NaN if already running, otherwise it returns the number of trials it had to iterate for an unused port.

wave CopySweepToWRef(wave sweep, wave config)

Creates a copy of the sweep data and returns it in wRef format.

static variable SplitSweepWave(wave numericalValues, variable sweep, wave sweepWave, wave configWave, variable rescale, dfref targetDFR, WaveText componentNames, variable createBackup)
static variable AreAllSingleSweepWavesPresent(dfref targetDFR, WaveText componentNames)
static dfref GetParentDFR(dfref dfr)
static variable UpgradeSweepWave(wave sweepWave, WaveText componentNames, dfref targetDFR)
variable SplitAndUpgradeSweep(wave numericalValues, variable sweep, wave sweepWave, wave configWave, variable rescale, variable doUpgrade, dfref targetDFR = defaultValue, variable createBackup = defaultValue)

Split a sweep wave into one 1D-wave per channel/ttlBit and convert the sweep wave to the current text sweep format. Sweeps already in text format are not split (because that already part of their format). When attempted to split, already existing single channel waves are preserved. The old 2D sweep format is converted automatically to the current text sweep format. If targetDFR is a free DF then only splitting is done. The sweepWave can get invalid and must be reobtained after calling. See GetSweepWave for detailed documentation of the sweep format.

Parameters:
  • numericalValues – numerical labnotebook

  • sweep – sweep number

  • sweepWave – sweep wave, either old 2D numerical sweep wave, wave ref wave or text sweep wave

  • configWave – config wave

  • rescale – One of TTLRescalingOptions

  • doUpgrade – When this flag is set, then the sweep wave is upgraded to the latest format. When set, createBackup must be set and targetDFR must not be a free DF.

  • targetDFR – [optional, defaults to the sweep wave DFR] datafolder where to put the waves, can be a free datafolder

  • createBackup – [optional, defaults 1] flag to enable/disable backup creation of single channel sweep waves

wave ResolveSweepChannel(WaveText sweepWave, variable index, variable allowFail = defaultValue)

Resolves a single channel of a text sweep wave and returns a reference to it.

Parameters:
  • sweepWave – text sweep wave

  • index – index of the channel

  • allowFail – [optional: default = 0] when set a null wave ref is returned if the channel could not be resolved, e.g. through a missing single channel wave. On default the function checks for a valid wave and asserts if none was found.

std::tuple<string, string> SplitTextSweepElement(string element)

Splits a text sweep wave element into the DF and wave name part.

static std::tuple<variable, variable> GetConfigWaveDims(wave config)
string GetSweepComponentWaveName(wave config, variable channelIndex)

Returns a wave name for a single channel sweep wave. The wave name is based on the channel type and channel number and is built from the XOP_CHANNEL_NAMES in the form DA_0, DA_1, AD_0, AD_1, TTL_0 and so on.

Parameters:
  • config – config wave

  • channelIndex – index in config wave

Returns:

string with a constructed wave name

variable AddVersionToPanel(string win, variable version)

Add user data “panelVersion” to the panel.

variable HasPanelLatestVersion(string win, variable expectedVersion)

Return 1 if the panel is up to date, zero otherwise.

variable GetPanelVersion(string win)

Get the user data “panelVersion”.

Parameters:

win – panel window as string

Returns:

numeric panel version greater 0 and -1 if no version is present or -2 if the windows does not exist

variable UpdateSweepPlot(string win)
variable UpdateSettingsPanel(string win)

update of panel elements and related displayed graphs in BSP

wave GetPlainSweepList(string win)
string ConvertAmplifierModeShortStr(variable mode)

Stringified short version of the clamp mode.

string ConvertAmplifierModeToString(variable mode)

Stringified version of the clamp mode.

variable UpdateLeftOverSweepTime(string device, variable fifoPos)

Update the repurposed sweep time global variable.

Currently only useful for handling mid sweep analysis functions.

variable LeftOverSweepTime(string device, variable fifoPos)
variable CalculateTPLikePropsFromSweep(wave numericalValues, wave textualValues, wave sweep, wave deltaI, wave deltaV, wave resistance)

Calculate deltaI/deltaV from a testpulse like stimset in “Current Clamp” mode.

Todo:

unify with TP_Delta code

add support for evaluating “inserted TP” only

See CalculateTPLikePropsFromSweep Algorithm for the full documentation.

variable MoveWaveWithOverwrite(wave dest, wave src, variable recursive = defaultValue)

Move the source wave to the location of the given destination wave. The destination wave must be a permanent wave.

Workaround for MoveWave having no /O flag.

Parameters:
  • dest – permanent wave

  • src – wave (free or permanent)

  • recursive – [optional, defaults to false] Overwrite referenced waves in dest with the ones from src (wave reference waves only with matching sizes)

variable IsValidConfigWave(WaveOrNull config, variable version = defaultValue)

Check if the given wave is a valid ITCConfigWave.

The optional version parameter allows to check if the wave is at least comaptible with this version. The function assumes that higher versions are compatible with lower versions which is for most callers true. For a special case see AFH_GetChannelUnits.

Parameters:
  • config – wave reference to a ITCConfigWave

  • version – [optional, default=DAQ_CONFIG_WAVE_VERSION], check against a specific version current versions known are 0 (equals NaN), 1, 2, 3

variable IsValidSweepWave(WaveOrNull sweep)

Check if the given wave is a valid DAQDataWave.

variable IsValidSweepAndConfig(WaveOrNull sweep, WaveOrNull config, variable configVersion = defaultValue)

Check if the two waves are valid and compatible.

Parameters:
  • sweep – sweep wave

  • config – config wave

  • configVersion – [optional, defaults to DAQ_CONFIG_WAVE_VERSION] minimum required version of the config wave

variable GetNextRandomNumberForDevice(string device)

Return the next random number using the device specific RNG seed.

variable EntrySourceTypeMapper(variable entrySourceType)

Maps the labnotebook entry source type, one of DataAcqModes, to a valid wave index.

UTF_NOINSTRUMENTATION

variable ReverseEntrySourceTypeMapper(variable mapped)

Rerverse the effect of EntrySourceTypeMapper()

UTF_NOINSTRUMENTATION

string GetNIFIFOName(variable deviceID)

constructs a fifo name for NI device ADC operations from the deviceID

UTF_NOINSTRUMENTATION

variable GetTotalOnsetDelay(wave numericalValues, variable sweepNo)

Return the total onset delay of the given sweep from the labnotebook.

UTF_NOINSTRUMENTATION

variable GetTotalOnsetDelayFromDevice(string device)

Return the total onset delay from the given device during DAQ.

UTF_NOINSTRUMENTATION

variable IsValidSamplingMultiplier(variable multiplier)

Check if the given multiplier is a valid sampling interval multiplier.

UTF_NOINSTRUMENTATION

variable ToggleCheckBoxes(string win, string checkBoxIn, string checkBoxPartner, variable checkBoxInState)

Places paired checkboxes in opposite state.

Parameters:
  • win – window name

  • checkBoxIn – ctrl checkbox ex. cba.ctrlName

  • checkBoxPartner – checkbox that will be placed in opposite state

  • checkBoxInState – state of the ctrl checkbox

variable EqualizeCheckBoxes(string win, string checkBoxIn, string checkBoxPartner, variable checkBoxInState)

Placed paired checkboxes in same state.

Parameters:
  • win – window name

  • checkBoxIn – ctrl checkbox ex. cba.ctrlName

  • checkBoxPartner – checkbox that will be placed in the same state

  • checkBoxInState – state of the ctrl checkbox

string GetMIESVersionAsString()

Return the MIES version with canonical EOLs.

variable SetupBackgroundTasks()
variable ZeroWave(wave wv)

Zero the wave using differentiation and integration.

Overwrites the input wave Preserves the WaveNote and adds the entry NOTE_KEY_ZEROED

2D waves are zeroed along each row

Returns:

0 if nothing was done, 1 if zeroed

variable ZeroWaveImpl(wave wv)

Zeroes a wave in place.

variable GetDecimatedWaveSize(variable numRows, variable decimationFactor, variable method)

Return the size of the decimated wave.

Query that to create the output wave before calling DecimateWithMethod().

Parameters:
  • numRows – number of rows in the input wave

  • decimationFactor – decimation factor, must be an integer and larger than 1

  • method – one of DecimationMethods

variable DecimateWithMethod(wave input, wave output, variable decimationFactor, variable method, variable firstRowInp = defaultValue, variable lastRowInp = defaultValue, variable firstColInp = defaultValue, variable lastColInp = defaultValue, variable firstColOut = defaultValue, variable lastColOut = defaultValue, WaveOrNull factor = defaultValue)

Decimate the the given input wave.

This allows to decimate a given input row range into output rows using the given method. The columns of input/output can be different. The input row coordinates can be used to do a chunked conversion, e.g. when receiving data from hardware. Incomplete chunks will be redone when necessary.

Algorithm visualized:

Input (16 entries): [ | | | | | | | | | | | | | | | ]
Decimation factor: 4
Method: MinMax
Output (4 entries): [ min(input[0, 7]) | max(input[0, 7]) | min(input[8, 15]) | max(input[8, 15]) ]

Parameters:
  • input – wave to decimate

  • output – target wave which will be around decimationFactor smaller than input

  • decimationFactor – decimation factor, must be an integer and larger than 1

  • method – one of DecimationMethods

  • firstRowInp – [optional, defaults to 0] first row input coordinates

  • lastRowInp – [optional, defaults to last element] last row in input coordinates

  • firstColInp – [optional, defaults to 0] first col in input coordinates

  • lastColInp – [optional, defaults to last element] last col in input coordinates

  • firstColOut – [optional, defaults to firstColInp] first col in output coordinates

  • lastColOut – [optional, defaults to lastColInp] last col in output coordinates

  • factor – [optional, defaults to none] factor which is applied to all input columns and written into the output columns

static variable DecimateMinMax(wave input, wave output, variable idx, variable firstRowInp, variable lastRowInp, variable colInp, variable colOut, variable decimationFactor)

Threadsafe helper function for DecimateWithMethod.

Parameters:
  • input – input wave

  • output – output wave

  • idx – output pair index

  • firstRowInp – first row in input coordinates

  • lastRowInp – last row in input coordinates

  • colInp – column in input coordinates

  • colOut – column in output coordinates

  • decimationFactor – decimation factor

variable NewExperiment()

Starts with a new experiment.

You have to manually save before, see SaveExperimentWrapper()

variable ConvertXOPErrorCode(variable err)

Remove the volatile part of the XOP error code.

The result is constant and can therefore be compared with constants.

wave FindIndizes(wave numericOrTextWave, variable col = defaultValue, string colLabel = defaultValue, variable var = defaultValue, string str = defaultValue, variable prop = defaultValue, variable startRow = defaultValue, variable endRow = defaultValue, variable startLayer = defaultValue, variable endLayer = defaultValue)

Extended version of FindValue

Allows to search only the specified column for a value and returns all matching row indizes in a wave. By defaults only looks into the first layer for backward compatibility reasons. When multiple layers are searched startLayer/endLayer the result contains matches from all layers, and this also means the resulting wave is still 1D.

Exactly one of var/str/prop has to be given except for prop == PROP_MATCHES_VAR_BIT_MASK and prop == PROP_NOT_MATCHES_VAR_BIT_MASK which requires a var/str parameter as well. prop == PROP_GREP requires str. prop == PROP_WILDCARD requires str.

Exactly one of col/colLabel has to be given.

Parameters:
  • numericOrTextWave – wave to search in

  • col – [optional, default=0] column to search in only

  • colLabel – [optional] column label to search in only

  • var – [optional] numeric value to search

  • str – [optional] string value to search

  • prop – [optional] property to search, see FindIndizesProps

  • startRow – [optional] starting row to restrict the search to

  • endRow – [optional] ending row to restrict the search to

  • startLayer – [optional, defaults to zero] starting layer to restrict search to

  • endLayer – [optional, defaults to zero] ending layer to restrict search to

Returns:

A wave with the row indizes of the found values. An invalid wave reference if the value could not be found.

string GetLastNonEmptyEntry(WaveText wv, string colLabel, variable endRow)

Searches the column colLabel in wv for an non-empty entry with a row number smaller or equal to endRow.

Return an empty string if nothing could be found.

Parameters:
  • wv – text wave to search in

  • colLabel – column label from wv

  • endRow – maximum row index to consider

variable GenerateSettingsDefaults()

Generate a default settings file in JSON format.

{
  "diagnostics": {
    "last upload": "2020-03-05T13:43:32Z"
  },
  "version": 1
}

Explanation:

Window coordinates are stored as


{“coordinates” : {“left” : 123, “top” : 456, “bottom” 789, “right” : 101112}}

Entries:

  • “version”: Major version number to track breaking changes

  • ”diagnostics”: Groups settings related to diagnostics and crash dump handling

  • ”diagnostics/last upload”: ISO8601 timestamp when the last successfull upload of crash dumps was tried. This is also set when no crash dumps have been uploadad.

  • ”analysisbrowser”: Groups settings related to the Analysisbrowser

  • ”analysisbrowser/directory”: The directory initially opened for browsing existing NWB/PXP files

  • ”logfiles”: Groups settings related to log files

  • ”logfiles/last upload”: ISO8601 timestamp when the last successfull upload of log files was tried. This is also set when no log files have been uploadad.

  • ”*[/*]/coordinates”: window coordinates

Caller is responsible for releasing the document.

Returns:

JSONid

variable UpgradeSettings(variable JSONid)
variable UploadCrashDumpsDaily()

Call UploadCrashDumps() if we haven’t called it since at least a day.

variable UploadLogFilesDaily()

Call UploadLogFiles() if we haven’t called it since at least a day.

variable UploadPingPeriodically()
static variable UploadPing()
wave GetTraceInfos(string graph, WaveText addFilterKeys = defaultValue, WaveText addFilterValues = defaultValue)

Return the graph user data as 2D text wave.

Only returns infos for sweep traces without duplicates. Duplicates are present with oodDAQ display mode.

Parameters:
  • graph[in] Name of graph

  • addFilterKeys[in] [optional, default = $””] additional keys for filtering

  • addFilterValues[in] [optional, default = $””] additional values for filtering, must have same size as keys

variable RemoveSweepFromGraph(string win, variable index)

Remove the given sweep from the Databrowser/Sweepbrowser.

Needs a manual call to PostPlotTransformations() afterwards.

Parameters:
  • win – graph

  • index – overlay sweeps listbox index

variable AddSweepToGraph(string win, variable index, BufferedDrawInfo *bdi = defaultValue)

Add the given sweep to the Databrowser/Sweepbrowser.

Needs a manual call to PostPlotTransformations() afterwards.

Parameters:
  • win – graph

  • index – overlay sweeps listbox index

  • bdi – [optional, default = n/a] BufferedDrawInfo structure, when given buffered draw is used.

variable UpdateSweepInGraph(string win, variable index)

Update the given sweep in the Databrowser/Sweepbrowser plot.

Needs a manual call to PostPlotTransformations() afterwards.

Parameters:
  • win – graph

  • index – overlay sweeps listbox index

variable StoreWindowCoordinatesHook(WMWinHookStruct *s)

Generic window hooks for storing the window coordinates in the JSON settings file.

string GetAbbreviationForAnalysisFunction(string anaFunc)

Return the short/abbreviated analysis function name used in the tables.

variable MapAnaFuncToConstant(string anaFunc)

Map from analysis function name to numeric constant.

Returns:

One of SpecialAnalysisFunctionTypes which includes INVALID_ANALYSIS_FUNCTION and for CI testing TEST_ANALYSIS_FUNCTION

string CreateAnaFuncLBNKey(variable type, string formatString, variable chunk = defaultValue, variable query = defaultValue, variable waMode = defaultValue)

Return labnotebook keys for patch seq analysis functions.

Parameters:
variable GetAnalysisFunctionVersion(variable type)

Return the current version of the analysis functions.

variable SetAnalysisFunctionVersion(string device, variable type, variable headstage, variable sweepNo)

Add a labnotebook entry denoting the analysis function version.

variable GenerateJSONTemplateForUpload(string timeStamp = defaultValue)

Return JSON text with default entries for upload.

Caller is responsible for releasing JSON text.

variable UploadCrashDumps()

Convert the Igor Pro crash dumps and the report file to JSON and upload them.

Does nothing if none of these files exists.

The uploaded files are moved out of the way afterwards.

See tools/http-upload/upload-json-payload-v1.php for the JSON format description.

Returns:

1 if crash dumps had been uploaded, 0 otherwise

variable UploadLogFiles(variable verbose = defaultValue, variable firstDate = defaultValue, variable lastDate = defaultValue)

Upload the MIES and ZeroMQ logfiles.

Parameters:
  • verbose – [optional, defaults to true] Only in verbose mode the ticket ID is output to the history

  • firstDate – [optional, defaults to false] Allows to filter the logfiles to include entries within the given dates. Both firstDate and lastDate must be present for filtering. The timestamps are in seconds since Igor Pro epoch.

  • lastDate – [optional, defaults to false] See firstDate

static variable UploadLogFilesPrint(string str, variable verbose)
static variable ArchiveLogFile(WaveText logData, string fullFilePath, variable index)
static variable SaveRemainingLog(WaveText logData, variable index, string fullFilePath)
static string LastArchivedLogFile(string fullFilePath)
static string GetDateOfLogEntry(string entry)
variable UpdateXOPLoggingTemplate()

Update the logging template used by the ZeroMQ-XOP and ITCXOP2.

string GetZeroMQXOPLogfile()

Return the disc location of the (possibly non-existing) ZeroMQ-XOP logfile.

string GetITCXOP2Logfile()

Return the disc location of the (possibly non-existing) ITCXOP2 logfile.

variable RecreateMissingSweepAndConfigWaves(string device, dfref deviceDataDFR)

Tries to find deleted sweep and config waves which are still present due to 1D waves from databrowser backups or labnotebook entries.

The result is placed in root:reconstructed which is overwritten.

For reconstructing single sweep or config waves, see RecreateSweepWaveFromBackupAndLBN() and RecreateConfigWaveFromLBN().

Example invocation:

  • RecreateMissingSweepAndConfigWaves(“ITC18USB_DEV_0”, root:MIES:HardwareDevices:ITC18USB:Device0:Data:)

  • Inspect the results in root:reconstructed

  • If you are satisfied, move the waves from root:reconstructed into e.g. root:MIES:HardwareDevices:ITC18USB:Device0:Data:

  • Proceed with the data as usual

In case the routine throws an assertion, please open an issue so that we can investigate.

wave RecreateSweepWaveFromBackupAndLBN(wave numericalValues, WaveText textualValues, variable sweepNo, dfref deviceDataDFR)

Try recreating a WaveRef sweep wave from its databrowser backup. For a text sweep wave, call SplitSweepIntoComponents afterwards with a target DF.

Returns:

$”” if reconstruction failed or a free wave with the sweep data and correct metadata

wave RecreateConfigWaveFromLBN(string device, wave numericalValues, wave textualValues, variable sweepNo)

Try recreating the DAQ config wave from labnotebook entries.

Returns:

$"" if recreation failed or a free wave on success.

static variable GetSamplingIntervalFromLBN(wave numericalValues, variable sweepNo)

Return the sampling interval [ms] rounded to microseconds.

static variable AddChannelPropertiesFromLBN(wave numericalValues, wave textualValues, variable sweepNo, wave configWave, variable channelType)

Set ChannelNumber and ChannelType in configWave.

static variable AddDAQChannelTypeFromLBN(wave numericalValues, wave textualValues, variable sweepNo, wave configWave)

Set DAQChannelType in configWave.

static variable AddHeadstageFromLBN(wave numericalValues, variable sweepNo, wave configWave)

Set Headstage in configWave.

static variable AddClampModeFromLBN(wave numericalValues, variable sweepNo, wave configWave)

Set ClampMode in configWave.

static variable AddChannelUnitFromLBN(wave numericalValues, WaveText textualValues, variable sweepNo, wave configWave)

Add wave note entry CHANNEL_UNIT_KEY for the used channel units.

static std::tuple<WAVE, WaveRefWave> GetSingleSweepWaves(dfref singleSweepFolder, variable channelType)

Return waves with the channel numbers and references to 1D waves from the X_XXXX folders.

static variable AddToSweepWave(WaveRefWave channelWaves, wave channelNumbers, WaveRefWave sweepWave, variable indexOffset)

Add the returned 1D waves from GetSingleSweepWaves() into sweepWave. sweepWave must be WaveRef wave. The size of sweepWave is increased if required.

Returns:

index of last row filled

variable TestOverrideActive()

Return if the function results are overriden for testing purposes.

variable GetHeadstageForChannel(wave numericalValues, variable sweep, variable channelType, variable channelNumber, variable entrySourceType)

Returns the active headstage for a given sweep, channelType, channelNumber from the LBN.

Parameters:
  • numericalValues – LBN wave with numerical values

  • sweep – sweep number

  • channelType – channel type number

  • channelNumber – channel number

  • entrySourceType – type of the labnotebook entry, one of DataAcqModes

Returns:

headstage number or NaN if no headstage was found

variable HandleOutOfMemory(string device, string name)
variable AlreadyCalledOnce(string name)

Return 1 if the function was already called with that argument, and 0 otherwise As named use or create a constant in.

See also

CalledOnceNames

std::tuple<WaveText, variable> FilterByDate(WaveText entries, variable first, variable last)
static variable FindFirstLogEntryElementByDate(WaveText entries, variable timeStamp)

Find the index of the first log file line that is from a time greater or equal than timeStamp The algorithm is a binary search that requires ascending order of time stamps of the log file entries. entries is a text wave where each line contains a log file entry as JSON. This JSON can contain a timestamp but can also contain no or an invalid timestamp. If the binary search hits an invalid timestamp the current search index is moved by a linear search to lower indices until a valid timestamp or the lower boundary is reached.

Parameters:
  • entries – text wave where each line contains a log file entry as serialized JSON with ascending order of time stamps

  • timeStamp – time stamp that is searched

Returns:

index + 1 of the last entry with a time stamp lower than timeStamp

static variable FindLastLogEntryElementByDate(WaveText entries, variable timeStamp)

Find the index of the last log file line that is from a time smaller or equal than timeStamp The algorithm is a binary search that requires ascending order of time stamps of the log file entries. entries is a text wave where each line contains a log file entry as JSON. This JSON can contain a timestamp but can also contain no or an invalid timestamp. If the binary search hits an invalid timestamp the current search index is moved by a linear search to higher indices until a valid timestamp or the higher boundary is reached.

Parameters:
  • entries – text wave where each line contains a log file entry as serialized JSON with ascending order of time stamps

  • timeStamp – time stamp that is searched

Returns:

index - 1 of the first entry with a time stamp greater than timeStamp

variable ToggleUserPingSetting()
variable GetUserPingEnabled()
string GetUserPingTimestamp()
variable SetUserPingTimestamp(variable timeStamp)
variable ArchiveLogFilesOnceAndKeepMonth()
string GetWorkLoadName(string workload, string device)
variable GetFirstADCChannelIndex(wave config)
variable SplitAndUpgradeSweepGlobal(string device, variable sweepNo)
std::tuple<WAVE, WAVE> GetSweepAndConfigWaveFromDevice(string device, variable sweepNo)
wave TextSweepToWaveRef(wave sweepWave)

Converts a text sweep wave to a free waveRef sweep wave. The waveRef sweep wave contains references to the channels from the text sweep wave, that are local or global waves. See also GetSweepWave docu on “intermediate sweep format”. Generally waveRef waves are easier to handle. It is currently used for NWB saving where the sweep channel data needs to be available in a preemptive thread.

Variables

static const double ADC_SLOT_MULTIPLIER = 4
static const double EPOCH_SLOT_MULTIPLIER = 3
static const double NUM_CHANNEL_TYPES = 3
static const double GET_LB_MODE_NONE = 0
static const double GET_LB_MODE_READ = 1
static const double GET_LB_MODE_WRITE = 2
static const string PSQ_PB_LBN_PREFIX = "Pipette in Bath"
static const string PSQ_CR_LBN_PREFIX = "Chirp"
static const string PSQ_SP_LBN_PREFIX = "Squ. Pul."
static const string PSQ_DS_LBN_PREFIX = "DA Scale"
static const string PSQ_RB_LBN_PREFIX = "Rheobase"
static const string PSQ_RA_LBN_PREFIX = "Ramp"
static const string PSQ_SE_LBN_PREFIX = "Seal evaluation"
static const string PSQ_VM_LBN_PREFIX = "True Rest Memb."
static const string PSQ_AR_LBN_PREFIX = "Access Res. Smoke"
static const string MSQ_FRE_LBN_PREFIX = "F Rheo E"
static const string MSQ_DS_LBN_PREFIX = "Da Scale"
static const string MSQ_SC_LBN_PREFIX = "Spike Control"
static const string LBN_UNASSOC_REGEXP_LEGACY = "^(.*) UNASSOC_[[:digit:]]+$"
static const string LBN_UNASSOC_REGEXP = "^(.*) u_(AD|DA)[[:digit:]]+$"
static const string ARCHIVEDLOG_SUFFIX = "_old_"
static const string EXPCONFIG_JSON_HWDEVBLOCK = "DAQHardwareDevices"
static const string UPLOAD_BLOCK_USERPING = "UserPing"
static const double ARCHIVE_SIZETHRESHOLD = 52428800