File MIES_AnalysisFunctions_MultiPatchSeq_SpikeControl.ipf

SC Spike Control analysis function for multi patch sequence

Functions

static std::tuple<variable, variable> SC_GetTrials(string device, variable sweepNo, variable headstage)

Store the newly calculated rerun trials in the labnotebook and return the minimum and maximum of it.

static wave SC_GetHeadstageQCForSetCount(string device, variable sweepNo)

Return a 2D wave with the headstage QC result as a function of the set sweep count.

This function does return the result for all active headstages. The headstage argument is needed for fetching all sweeps from the current SCI.

Value:

  • Cumulated headstage QC result

Rows:

  • Headstage

Cols:

  • Stimulus set sweep count

static variable SC_GetSetSweepCount(wave numericalValues, variable sweepNo)

Return the stimulus set sweep count for the given sweep.

static variable SC_GetSetPassed(string device, variable sweepNo)

Return pass/fail state of the set.

This is true iff we have for very stimulus set sweep count a passing headstage

static variable SC_GetSweepPassed(string device, variable sweepNo)

Return pass/fail state of the sweep.

This is true iff we have for the current stimulus set sweep count a passing headstage

static variable SC_LastSweepInSet(string device, variable sweepNo, variable headstage)

Return 1 if we are currently acquiring the last sweep in the stimulus set, 0 otherwise.

static wave SC_FilterPulses(WaveRefWave propertiesWaves, WaveOrNull indizesAll, WaveOrNull indizesSweep)

Given a list of pulses by their indizes, this function return only the diagonal ones which are matching the given sweep.

static variable SC_AddPulseRegionLBNEntries(WaveText inputLBN, variable pulseIndex, variable region, variable headstage, WaveOrNull data = defaultValue)

Add a new PX_PY:.. entry in to the wave inputLBN

The value part after the : is only present if data is passed in

static std::tuple<WAVE, WaveRefWave> SC_GetPulseAveragePropertiesWaves(string device)

Return the PA plot waves from the databrowser connected to the given device.

static wave SC_GetPulseIndizes(wave properties, WaveRefWave propertiesWaves, variable sweepNo)

Return the diagonal pulses for the given sweep.

static std::tuple<WaveText, WaveText> SC_GetSpikeNumbersAndPositions(string device, variable sweepNo)

Return the spike numbers and positions in waves prepared for labnotebook writing.

static variable SC_ProcessPulses(string device, variable sweepNo, variable minimumSpikePosition, variable idealNumberOfSpikes)

Fetch the pulses from the PA plot and write the results into the labnotebooks.

static string SC_SpikeCountStateToString(variable countState)

Convert a numeric spike counts state to its string.

Returns “” for unknown state variables

static variable SC_SpikeCountsCalcDetail(variable minimum, variable maximum, variable idealNumberOfSpikes)

Determine the spike counts state.

  • Minimum[HS] == Maximum[HS] == idealNumberOfSpikes -> Pass

  • idealNumberOfSpikes >= Maximum[HS] -> Too few

  • idealNumberOfSpikes <= Mininum[HS] -> Too many

  • If nothing else matched -> Mixed

We assume:

  • minimum < maximum

  • idealNumberOfSpikes >= 1

  • All numbers are integers

static wave SC_SpikeCountsCalc(string device, wave minimum, wave maximum, variable idealNumberOfSpikes)

Determine the spike counts state for all headstages.

static wave SC_SpikeCountsQC(string device, WaveText spikeNumbersLBN, variable idealNumberOfSpikes)

Check that the we have found the expected number of spikes per pulse.

Returns:

Spike counts state according to SpikeCountsStateConstants stringified

static variable SC_SpikePositionsCalcDetail(wave spikePositions, variable minimumSpikePosition)

Calculate the QC state of a list of spike positions from one pulse.

All are in Pulse active coordinate system

Parameters:
  • spikePositions – spike position

  • minimumSpikePosition – minimum allowed spike position

static wave SC_SpikePositionQC(string device, WaveTextOrNull spikePositionsLBN, variable minimumSpikePosition)

Calculate the QC state of the spike positions of each pulse.

All values are in PA crd, see SC_SpikeControl().

Parameters:
  • device – device

  • spikePositionsLBN – spike position of each pulse, ordered per headstage, for the current sweep

  • minimumSpikePosition – minimum allowed spike position

static wave SC_RegionBlanked(wave data, variable totalOnsetDelay, WaveText oodDAQRegion)

Replace all points inside an oodDAQ region with NaN in the data wave.

static wave SC_SpontaneousSpikingCheckQC(string device, variable sweepNo)

Return a wave ready for the labnotebook with the spontaneous spike check QC entries.

static wave SC_HeadstageQC(string device, WaveText spikeCountStateLBN, wave spontaneousSpikingCheckLBN)

Determine the headstage QC result.

static variable SC_DetermineQCState(string device, variable sweepNo, wave spikeNumbersLBN, WaveOrNull spikePositionsLBN, variable minimumSpikePosition, variable idealNumberOfSpikes)

Determine and write the QC states to the labnotebook.

static variable SC_CanStillSkip(variable maxTrials, string params)

Check if we can still skip sweeps without running more than maxTrials

static variable SC_SkipsExhausted(variable minTrials, string params)

Check if we have exhausted the available trials on all headstages.

static variable SC_ReactToQCFailures(string device, variable sweepNo, string params)

Perform various actions on QC failures.

string SC_SpikeControl_GetParams()
string SC_SpikeControl_GetHelp(string name)
string SC_SpikeControl_CheckParam(string name, CheckParametersStruct *s)
variable SC_SpikeControl(string device, AnalysisFunction_V3 *s)

Analysis function to check sweeps for failed pulses and rerun them if the pulses failed.

Decision logic flowchart:

For judging the quality of the spike positions we have introduced a new coordinate system which we call pulse active coordinate system (PA crd).

Consider the following pulse on the DA wave and the response spike in the AD wave

///
///        +---------+
///        |         |
///        |         |
///        |         |
///        |         |
///        |         |
///        |         |
/// -------+         +----------------------
///
///                   X
///                  XXX
///                 X   XX
///                X      XX
///               X         X
///              X           X
///             X             X
///            X               X
///           X                X
///          X                  X
///         X                   X
/// -------X                    X--------
///
///
and the let pulse active start at 5ms and end at 15ms. We define the start as 0 and the end as 100.
Therefore the spike position will be 110 in `PA crd` which is one point after the end of the pulse.

The graphs were made with http://asciiflow.com.

Variables

static const string SC_PULSE_PREFIX_RE = "^[^:]+:"

Pulse information in the labnotebook is stored as PX_RY:.... This regular expression can be used to match the prefix in order to remove it with RemovePrefix.