File MIES_MiesUtilities_Algorithm.ipf

This file holds MIES utility functions implementing various algorithms.

Functions

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

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

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 which requires a var/str parameter as well. prop == PROP_GREP requires str. prop == PROP_WILDCARD requires str. PROP_NOT can be set by logical ORing it to one of the other PROP_* constants prop == PROP_NOT can also be set solely to invert the matching of the default behavior

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.