File MIES_MiesUtilities_Logbook.ipf

This file holds MIES utility functions for working with the various Logbooks.

Functions

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.

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.

static variable GetLogbookSettingsColumn(wave values, string key)
static variable GetLogbookSettingsColumnFromSorted(WaveText sortedKeys, wave indices, string key)
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, variable settingCol = 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

  • settingCol – [optional, default: determined by function] if the caller has already determined the setting column, it can set this argument then GetLastSettingNoCache saves the find

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()

std::tuple<WAVE, variable> GetNonEmptyLBNRows(wave labnotebookValues, string setting)

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

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.

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

Find the first and last point index of a consecutive range of values in the labnotebook, searches the range from the back.

Parameters:
  • wv[in] wave to search

  • col[in] column to look for

  • val[in] value to search

  • 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

variable GetSweepColumn(wave labnotebookValues)

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

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 GetUniqueSettings(wave values, string setting)

Return a unique list of labnotebook entries of the given setting.

Parameters:
  • values – numerical logbook wave

  • setting – name of the value to search

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

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.

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 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 CreateAnaFuncLBNKey(variable type, string formatString, variable chunk = defaultValue, variable query = defaultValue, variable waMode = defaultValue)

Return labnotebook keys for patch seq analysis functions.

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

Add a labnotebook entry denoting the analysis function version.

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

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

variable GetTotalOnsetDelayFromDevice(string device)

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

UTF_NOINSTRUMENTATION

std::tuple<variable, variable, variable> GetAnalysisFunctionType(wave numericalValues, WaveText textualValues, variable sweepNo, variable channelNumber, variable channelType)

Retrieve the analysis function that was run for a given sweep / channelNumber / channelType.

Parameters:
  • numericalValues – numerical labnotebook

  • textualValues – textual labnotebook

  • sweepNo – sweep number

  • channelNumber – channel number

  • channelType – channelType

Return values:
variable ParseLogbookMode(string modeText)

Variables

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 LBN_UNASSOC_REGEXP_LEGACY = "^(.*) UNASSOC_[[:digit:]]+$"
static const string LBN_UNASSOC_REGEXP = "^(.*) u_(AD|DA)[[:digit:]]+$"
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"