Skip to content

Save precise start times per TP #2408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
8 changes: 3 additions & 5 deletions Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -5970,8 +5970,7 @@ Function PSQ_Ramp(string device, STRUCT AnalysisFunction_V3 &s)
// stop DAQ, set DA to zero from now to the end and start DAQ again

// fetch the very last fifo position immediately before we stop it
NVAR tgID = $GetThreadGroupIDFIFO(device)
fifoOffset = TS_GetNewestFromThreadQueue(tgID, "fifoPos")
fifoOffset = HW_ITC_ReadFifoPos(device)
TFH_StopFIFODaemon(HARDWARE_ITC_DAC, deviceID)
HW_StopAcq(HARDWARE_ITC_DAC, deviceID)
HW_ITC_PrepareAcq(deviceID, DATA_ACQUISITION_MODE, offset = fifoOffset)
Expand All @@ -5988,14 +5987,13 @@ Function PSQ_Ramp(string device, STRUCT AnalysisFunction_V3 &s)

// fetch newest fifo position, blocks until it gets a valid value
// its zero is now fifoOffset
NVAR tgID = $GetThreadGroupIDFIFO(device)
fifoPos = TS_GetNewestFromThreadQueue(tgID, "fifoPos")
fifoPos = HW_ITC_ReadFifoPos(device)
ASSERT(fifoPos > 0, "Invalid fifo position, has the thread died?")

// wait until the hardware is finished with writing this chunk
// this is to avoid that two threads write simultaneously into the DAQDataWave
for(;;)
val = TS_GetNewestFromThreadQueue(tgID, "fifoPos")
val = HW_ITC_ReadFifoPos(device)

if(val > fifoPos)
break
Expand Down
6 changes: 5 additions & 1 deletion Packages/MIES/MIES_Constants.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2428,4 +2428,8 @@ StrConstant CONF_DEFAULT_SAVE_LOCATION = "C:MiesSave"
// TP_TSAnalysis
// GetTPResultAsyncBuffer
// GetTPResults (reuses same dimlabels partially)
StrConstant TP_ANALYSIS_DATA_LABELS = "BASELINE;STEADYSTATERES;INSTANTRES;ELEVATED_SS;ELEVATED_INST;NOW;HEADSTAGE;MARKER;NUMBER_OF_TP_CHANNELS;TIMESTAMP;TIMESTAMPUTC;CLAMPMODE;CLAMPAMP;BASELINEFRAC;CYCLEID;TPLENGTHPOINTSADC;PULSELENGTHPOINTSADC;PULSESTARTPOINTSADC;SAMPLINGINTERVALADC;TPLENGTHPOINTSDAC;PULSELENGTHPOINTSDAC;PULSESTARTPOINTSDAC;SAMPLINGINTERVALDAC;"
StrConstant TP_ANALYSIS_DATA_LABELS = "BASELINE;STEADYSTATERES;INSTANTRES;ELEVATED_SS;ELEVATED_INST;HEADSTAGE;MARKER;NUMBER_OF_TP_CHANNELS;TIMESTAMP;TIMESTAMPUTC;CLAMPMODE;CLAMPAMP;BASELINEFRAC;CYCLEID;TPLENGTHPOINTSADC;PULSELENGTHPOINTSADC;PULSESTARTPOINTSADC;SAMPLINGINTERVALADC;TPLENGTHPOINTSDAC;PULSELENGTHPOINTSDAC;PULSESTARTPOINTSDAC;SAMPLINGINTERVALDAC;"

// Object names for thread data transfer out of ITC Fifothread @ref TFH_FifoLoop
StrConstant ITC_THREAD_FIFOPOS = "fifopos"
StrConstant ITC_THREAD_TIMESTAMP = "timestamp"
39 changes: 36 additions & 3 deletions Packages/MIES/MIES_DAC-Hardware.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@ Function HW_WriteDeviceInfo(variable hardwareType, string device, WAVE deviceInf
endswitch
End

threadsafe Function/S HW_GetAcquisitionStartTimestamp()

return GetIso8601TimeStamp(numFracSecondsDigits = 9)
End

/// @brief Start data acquisition
///
/// @param hardwareType One of @ref HardwareDACTypeConstants
Expand All @@ -635,12 +640,18 @@ End
/// @param repeat [optional, default 0] for NI devices, repeats the scan after it ends
Function HW_StartAcq(variable hardwareType, variable deviceID, [variable triggerMode, variable flags, variable repeat])

string device

HW_AssertOnInvalid(hardwareType, deviceID)

if(ParamIsDefault(triggerMode))
triggerMode = HARDWARE_DAC_DEFAULT_TRIGGER
endif

device = HW_GetMainDeviceName(hardwareType, deviceID, flags = flags)
SVAR lastAcqStartTime = $GetLastAcquisitionStartTime(device)
lastAcqStartTime = HW_GetAcquisitionStartTimestamp()

switch(hardwareType)
case HARDWARE_ITC_DAC:
HW_ITC_StartAcq(deviceID, triggerMode, flags = flags)
Expand Down Expand Up @@ -1515,7 +1526,7 @@ threadsafe Function HW_ITC_StartAcq_TS(variable deviceID, variable triggerMode,
End

/// @see HW_StartAcq
Function HW_ITC_StartAcq(variable deviceID, variable triggerMode, [variable flags])
static Function HW_ITC_StartAcq(variable deviceID, variable triggerMode, [variable flags])

variable tries

Expand Down Expand Up @@ -2153,6 +2164,28 @@ Function HW_ITC_IsValidDeviceName(string deviceName)
return !isEmpty(deviceName)
End

/// @brief Read out the fifopos from the ITC fifothread and update the acquisition start time if needed
Function HW_ITC_ReadFifoPos(string device, [variable timeout_tries, variable timeout_default])

timeout_default = ParamIsDefault(timeout_default) ? NaN : timeout_default
timeout_tries = ParamIsDefault(timeout_tries) ? Inf : timeout_tries

Make/FREE/T varNames = {ITC_THREAD_FIFOPOS, ITC_THREAD_TIMESTAMP}

NVAR tgID = $GetThreadGroupIDFIFO(device)
WAVE/Z data = TS_GetNewestFromThreadQueueMult(tgID, varNames, timeout_tries = timeout_tries, timeout_default = timeout_default)
if(!WaveExists(data))
// ITC TFH_FifoLoop thread stopped
return NaN
endif
if(!IsNaN(data[%$ITC_THREAD_TIMESTAMP]))
SVAR lastAcqStartTime = $GetLastAcquisitionStartTime(device)
lastAcqStartTime = GetISO8601TimeStamp(secondsSinceIgorEpoch = data[%$ITC_THREAD_TIMESTAMP], numFracSecondsDigits = 9)
endif

return data[%$ITC_THREAD_FIFOPOS]
End

///@}
///@}

Expand Down Expand Up @@ -2224,7 +2257,7 @@ static Constant HW_NI_FIFO_MIN_FREE_DISK_SPACE = 960000000
///

/// @see HW_StartAcq
Function HW_NI_StartAcq(variable deviceID, variable triggerMode, [variable flags, variable repeat])
static Function HW_NI_StartAcq(variable deviceID, variable triggerMode, [variable flags, variable repeat])

string device, realDeviceOrPressure, FIFONote, noteID, fifoName, errMsg
variable i, pos, endpos, channelTimeOffset, err
Expand Down Expand Up @@ -3499,7 +3532,7 @@ static Function [variable hwChannel, string encode] HW_SU_GetEncodeFromUnassocDA
return [hwChannel, encode]
End

Function HW_SU_StartAcq(variable deviceId, [variable flags])
static Function HW_SU_StartAcq(variable deviceId, [variable flags])

string device, cmdError, cmdDone

Expand Down
5 changes: 2 additions & 3 deletions Packages/MIES/MIES_DataAcquisition_Multi.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ Function DQM_FIFOMonitor(STRUCT BackgroundStruct &s)
endtry
break
case HARDWARE_ITC_DAC:
NVAR tgID = $GetThreadGroupIDFIFO(device)
fifoLatest = TS_GetNewestFromThreadQueue(tgID, "fifoPos", timeout_default = HARDWARE_ITC_FIFO_ERROR, timeout_tries = THREAD_QUEUE_TRIES)
fifoLatest = HW_ITC_ReadFifoPos(device, timeout_default = HARDWARE_ITC_FIFO_ERROR, timeout_tries = THREAD_QUEUE_TRIES)

if(fifoLatest != s.lastReceivedFifoPos)
s.ticksLastReceivedFifoPos = ticks
Expand Down Expand Up @@ -126,7 +125,7 @@ Function DQM_FIFOMonitor(STRUCT BackgroundStruct &s)
endif

// once TFH_FifoLoop is finished the thread is done as well and
// therefore we get NaN from TS_GetNewestFromThreadQueue
// therefore we get NaN from HW_ITC_ReadFifoPos
isFinished = IsNaN(fifoLatest)

// Update ActiveChunk Entry for ITC, not used in DAQ mode
Expand Down
6 changes: 6 additions & 0 deletions Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,12 @@ Function/S GetNI_TTLTaskID(string device)
return GetNVARAsString(GetDevicePath(device), "NI_TTL_taskID", initialValue = NaN)
End

/// @brief Returns the global that stores the last acquisition start time
Function/S GetLastAcquisitionStartTime(string device)

return GetSVARAsString(GetDevicePath(device), "LastAcquisitionStartTime", initialValue = "")
End

/// @brief Return the experiment session start time in NWB-speech
///
/// This is the time when the last device was locked.
Expand Down
4 changes: 2 additions & 2 deletions Packages/MIES/MIES_LogbookViewer.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1228,8 +1228,8 @@ static Function LBV_LimitXRangeToSelected(string browser)
endif

// convert to local time zone
first += date2secs(-1, -1, -1)
last += date2secs(-1, -1, -1)
first = UTCTimeToLocal(first)
last = UTCTimeToLocal(last)

ASSERT(IsFinite(first) && IsFinite(last), "Invalid first/last")
else
Expand Down
7 changes: 5 additions & 2 deletions Packages/MIES/MIES_MiesUtilities_Sweep.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ threadsafe static Function UpgradeSweepWave(WAVE sweepWave, WAVE/T componentName
// we also have to preserve the original modification time
ASSERT_TS(!CmpStr(WaveUnits(sweepWave, ROWS), "ms"), "Expected ms as wave units")
modTimeStr = StringByKeY("MODTIME", WaveInfo(sweepWave, 0))
sweepCreationTimeUTC = str2num(modTimeStr) - date2secs(-1, -1, -1)
sweepCreationTimeUTC = LocalTimeToUTC(str2num(modTimeStr))
sweepCreationTimeUTC -= DimSize(sweepWave, ROWS) * DimDelta(sweepWave, ROWS) * MILLI_TO_ONE

oldSweepName = UniqueWaveName(sweepWaveDFR, sweepWaveName + "_preUpgrade")
Expand Down Expand Up @@ -440,7 +440,10 @@ End

Function LeftOverSweepTime(string device, variable fifoPos)

ASSERT(IsFinite(fifoPos), "Unexpected non-finite fifoPos")
if(IsNaN(fifopos))
// TFH_FifoLoop thread finished -> sweep finished regular (or manually stopped)
return 0
endif

WAVE DAQDataWave = GetDAQDataWave(device, DATA_ACQUISITION_MODE)
NVAR stopCollectionPoint = $GetStopCollectionPoint(device)
Expand Down
18 changes: 14 additions & 4 deletions Packages/MIES/MIES_Oscilloscope.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
STRUCT TPAnalysisInput tpInput
variable i, j
variable tpChannels, numADCs, numDACs, tpLengthPointsADC, tpStart, tpEnd, tpStartPos
variable TPChanIndex, saveTP, clampAmp
variable TPChanIndex, saveTP, clampAmp, timeSinceAcqStart, timeOfAcqStartUTC, tpCounter
variable headstage, fifoLatest, channelIndex
string hsList

Expand All @@ -478,6 +478,7 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
chunk = 0
endif
ASSERT(ParamIsDefault(fifoPos), "optional parameter fifoPos is not possible with TEST_PULSE_MODE")
tpCounter = chunk
elseif(dataAcqOrTP == DATA_ACQUISITION_MODE)
ASSERT(!ParamIsDefault(fifoPos), "optional parameter fifoPos missing")
ASSERT(ParamIsDefault(chunk), "optional parameter chunk is not possible with DATA_ACQUISITION_MODE")
Expand All @@ -489,11 +490,15 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
case HARDWARE_NI_DAC:
ASSERT(!ParamIsDefault(deviceID), "optional parameter deviceID missing (required for NI devices in TP mode)")
SCOPE_NI_UpdateOscilloscope(device, dataAcqOrTP, deviceID, fifoPos)
if(dataAcqOrTP == TEST_PULSE_MODE)
tpCounter = ROVar(GetNITestPulseCounter(device))
endif
break
case HARDWARE_SUTTER_DAC:
if(dataAcqOrTP == TEST_PULSE_MODE)
ASSERT(!ParamIsDefault(chunk), "optional parameter chunk is missing with TEST_PULSE_MODE")
ASSERT(ParamIsDefault(fifoPos), "optional parameter fifoPos is not possible with TEST_PULSE_MODE")
tpCounter = chunk
elseif(dataAcqOrTP == DATA_ACQUISITION_MODE)
ASSERT(!ParamIsDefault(fifoPos), "optional parameter fifoPos missing")
ASSERT(ParamIsDefault(chunk), "optional parameter chunk is not possible with DATA_ACQUISITION_MODE")
Expand Down Expand Up @@ -529,6 +534,8 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
numDACs = DimSize(DACs, ROWS)
numADCs = DimSize(ADCs, ROWS)

timeOfAcqStartUTC = ParseISO8601TimeStamp(ROStr(GetLastAcquisitionStartTime(device)))

// note: currently this works for multiplier = 1 only, see DC_PlaceDataInDAQDataWave
Make/FREE/N=(tpLengthPointsADC) channelData
WAVE tpInput.data = channelData
Expand All @@ -543,7 +550,6 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
tpInput.pulseStartPointsDAC = (dataAcqOrTP == TEST_PULSE_MODE) ? TPSettingsCalc[%pulseStartPointsTP] : TPSettingsCalc[%pulseStartPointsDAQ]
tpInput.samplingIntervalDAC = DimDelta(scaledDataWave[0], ROWS)
tpInput.baselineFrac = TPSettingsCalc[%baselineFrac]
tpInput.readTimeStamp = ticks * TICKS_TO_SECONDS
tpInput.activeADCs = tpChannels
tpInput.cycleId = ROVAR(GetTestpulseCycleID(device))

Expand All @@ -557,6 +563,9 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
DEBUGPRINT("tpChannels: ", var = tpChannels)
DEBUGPRINT("tpLength: ", var = tpLengthPointsADC)

// In TP mode the loop only runs once. Only the last TP is evaluated for ITC and SUTTER.
// For NI the caller loops over all pending TPs.
// In DAQ mode all TPs are evaluated in this loop
for(i = tpStart; i < tpEnd; i += 1)

tpInput.measurementMarker = tpMarker[i - tpStart]
Expand All @@ -574,8 +583,9 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
endif

// Use same time for all headstages
tpInput.timeStamp = DateTime
tpInput.timeStampUTC = DateTimeInUTC()
timeSinceAcqStart = (tpCounter + i) * tpInput.samplingIntervalDAC * tpInput.tpLengthPointsDAC * MILLI_TO_ONE
tpInput.timeStampUTC = timeOfAcqStartUTC + timeSinceAcqStart
tpInput.timeStamp = UTCTimeToLocal(tpInput.timeStampUTC)
tpInput.sendTPMessage = 1

for(j = 0; j < numADCs; j += 1)
Expand Down
1 change: 0 additions & 1 deletion Packages/MIES/MIES_Publish.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,6 @@ threadsafe Function PUB_TPResult(string device, WAVE tpData, WAVE ampParamStorag
JSON_AddVariable(jsonID, path + "/headstage", tpData[%HEADSTAGE])
JSON_AddVariable(jsonID, path + "/clamp mode", tpData[%CLAMPMODE])

PUB_AddTPResultEntry(jsonId, path + "/time of tp acquisition", tpData[%NOW], "s")
PUB_AddTPResultEntry(jsonId, path + "/clamp amplitude", tpData[%CLAMPAMP], daUnit)
PUB_AddTPResultEntry(jsonId, path + "/tp length ADC", tpData[%TPLENGTHPOINTSADC], "points")
PUB_AddTPResultEntry(jsonId, path + "/pulse duration ADC", tpData[%PULSELENGTHPOINTSADC], "points")
Expand Down
1 change: 0 additions & 1 deletion Packages/MIES/MIES_Structures.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ Structure TPAnalysisInput
variable pulseStartPointsDAC
variable samplingIntervalDAC
variable baselineFrac
variable readTimeStamp
variable headstage
string device
variable measurementMarker
Expand Down
25 changes: 9 additions & 16 deletions Packages/MIES/MIES_TestPulse.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ Function TP_ROAnalysis(STRUCT ASYNC_ReadOutStruct &ar)
MultiThread TPResults[%ResistanceInst][] = asyncBuffer[i][%INSTANTRES][q]
MultiThread TPResults[%ElevatedSteadyState][] = asyncBuffer[i][%ELEVATED_SS][q]
MultiThread TPResults[%ElevatedInst][] = asyncBuffer[i][%ELEVATED_INST][q]
MultiThread TPResults[%NOW][] = asyncBuffer[i][%NOW][q]
MultiThread TPResults[%HEADSTAGE][] = asyncBuffer[i][%HEADSTAGE][q]
MultiThread TPResults[%MARKER][] = asyncBuffer[i][%MARKER][q]
MultiThread TPResults[%NUMBER_OF_TP_CHANNELS][] = asyncBuffer[i][%NUMBER_OF_TP_CHANNELS][q]
Expand Down Expand Up @@ -405,7 +404,7 @@ Function TP_ROAnalysis(STRUCT ASYNC_ReadOutStruct &ar)

TP_AutoAmplitudeAndBaseline(device, TPResults, marker)
DQ_ApplyAutoBias(device, TPResults)
TP_RecordTP(device, TPResults, inData[%NOW])
TP_RecordTP(device, TPResults)
endif
End

Expand Down Expand Up @@ -1040,7 +1039,6 @@ threadsafe Function/DF TP_TSAnalysis(DFREF dfrInp)
variable pulseLengthPointsADC = ASYNC_FetchVariable(dfrInp, "pulseLengthPointsADC")
variable baselineFrac = ASYNC_FetchVariable(dfrInp, "baselineFrac")
variable tpLengthPointsADC = ASYNC_FetchVariable(dfrInp, "tpLengthPointsADC")
variable now = ASYNC_FetchVariable(dfrInp, "now")
variable headstage = ASYNC_FetchVariable(dfrInp, "headstage")
string device = ASYNC_FetchString(dfrInp, "device")
variable marker = ASYNC_FetchVariable(dfrInp, "marker")
Expand All @@ -1061,8 +1059,8 @@ threadsafe Function/DF TP_TSAnalysis(DFREF dfrInp)
Duplicate data, dfrOut:colors
Duplicate data, dfrOut:data
WAVE colors = dfrOut:colors
colors = 0
colors[0, lengthTPInPoints - 1] = 100
colors = 0
colors[0, tpLengthPointsADC - 1] = 100
#endif

WAVE tpData = GetTPAnalysisDataWave()
Expand Down Expand Up @@ -1098,7 +1096,7 @@ threadsafe Function/DF TP_TSAnalysis(DFREF dfrInp)
DEBUGPRINT_TS("steady state range eng (ms): ", var = refTime)
DEBUGPRINT_TS("steady state average: ", var = avgTPSS)
// color steady state
refpt = lengthTPInPoints - tpStartPoint - evalOffsetPointsCorrected
refpt = tpLengthPointsADC - tpStartPoint - evalOffsetPointsCorrected
colors[refpt - evalRange / samplingIntervalADC, refpt] = 50
// color instantaneous
refpt = tpStartPoint + evalOffsetPointsCorrected
Expand Down Expand Up @@ -1140,7 +1138,6 @@ threadsafe Function/DF TP_TSAnalysis(DFREF dfrInp)

// additional data copy
string/G dfrOut:device = device
tpData[%NOW] = now
tpData[%HEADSTAGE] = headstage
tpData[%MARKER] = marker
tpData[%NUMBER_OF_TP_CHANNELS] = activeADCs
Expand Down Expand Up @@ -1195,18 +1192,15 @@ End
/// @brief Records values from TPResults into TPStorage at defined intervals.
///
/// Used for analysis of TP over time.
static Function TP_RecordTP(string device, WAVE TPResults, variable now)
static Function TP_RecordTP(string device, WAVE TPResults)

variable delta, i, ret, lastPressureCtrl
variable delta, i, ret, lastPressureCtrl, now
WAVE TPStorage = GetTPStorage(device)
WAVE hsProp = GetHSProperties(device)
variable count = GetNumberFromWaveNote(TPStorage, NOTE_INDEX)
variable lastRescaling = GetNumberFromWaveNote(TPStorage, DIMENSION_SCALING_LAST_INVOC)

if(!count)
// time of the first sweep
TPStorage[0][][%TimeInSeconds] = now

WAVE statusHS = DAG_GetChannelState(device, CHANNEL_TYPE_HEADSTAGE)

for(i = 0; i < NUM_HEADSTAGES; i += 1)
Expand Down Expand Up @@ -1237,7 +1231,6 @@ static Function TP_RecordTP(string device, WAVE TPResults, variable now)
: TPStorage[count][q][%HoldingCmd_IC]
endif

TPStorage[count][][%TimeInSeconds] = TPResults[%NOW][q]
TPStorage[count][][%TimeStamp] = TPResults[%TIMESTAMP][q]
TPStorage[count][][%TimeStampSinceIgorEpochUTC] = TPResults[%TIMESTAMPUTC][q]

Expand All @@ -1255,7 +1248,7 @@ static Function TP_RecordTP(string device, WAVE TPResults, variable now)
TPStorage[count][][%Baseline_VC] = (hsProp[q][%ClampMode] == V_CLAMP_MODE) ? TPResults[%BaselineSteadyState][q] : NaN
TPStorage[count][][%Baseline_IC] = (hsProp[q][%ClampMode] == I_CLAMP_MODE) ? TPResults[%BaselineSteadyState][q] : NaN

TPStorage[count][][%DeltaTimeInSeconds] = (count > 0) ? (now - TPStorage[0][0][%TimeInSeconds]) : 0
TPStorage[count][][%DeltaTimeInSeconds] = TPResults[%TIMESTAMP][q] - TPStorage[0][q][%TimeStamp]
TPStorage[count][][%TPMarker] = TPResults[%MARKER][q]

TPStorage[count][][%TPCycleID] = TPResults[%CYCLEID][q]
Expand All @@ -1278,6 +1271,7 @@ static Function TP_RecordTP(string device, WAVE TPResults, variable now)
TPStorage[count][][%AutoTPCycleID] = hsProp[q][%Enabled] ? TPSettings[%autoTPCycleID][q] : NaN

lastPressureCtrl = GetNumberFromWaveNote(TPStorage, PRESSURE_CTRL_LAST_INVOC)
now = DateTime
if((now - lastPressureCtrl) > TP_PRESSURE_INTERVAL)
P_PressureControl(device)
SetNumberInWaveNote(TPStorage, PRESSURE_CTRL_LAST_INVOC, now, format = "%.06f")
Expand Down Expand Up @@ -1312,7 +1306,7 @@ threadsafe static Function TP_FitResistance(WAVE TPStorage, variable startRow, v
try
V_FitError = 0
V_AbortCode = 0
CurveFit/Q/N=1/NTHR=1/M=0/W=2 line, kwCWave=coefWave, TPStorage[startRow, endRow][headstage][%SteadyStateResistance]/X=TPStorage[startRow, endRow][headstage][%TimeInSeconds]/AD=0/AR=0; AbortOnRTE
CurveFit/Q/N=1/NTHR=1/M=0/W=2 line, kwCWave=coefWave, TPStorage[startRow, endRow][headstage][%SteadyStateResistance]/X=TPStorage[startRow, endRow][headstage][%TimeStamp]/AD=0/AR=0; AbortOnRTE
return coefWave[1]
catch
ClearRTError()
Expand Down Expand Up @@ -1679,7 +1673,6 @@ Function/DF TP_PrepareAnalysisDF(string device, STRUCT TPAnalysisInput &tpInput)
ASYNC_AddParam(threadDF, var = tpInput.pulseLengthPointsADC, name = "pulseLengthPointsADC")
ASYNC_AddParam(threadDF, var = tpInput.baselineFrac, name = "baselineFrac")
ASYNC_AddParam(threadDF, var = tpInput.tpLengthPointsADC, name = "tpLengthPointsADC")
ASYNC_AddParam(threadDF, var = tpInput.readTimeStamp, name = "now")
ASYNC_AddParam(threadDF, var = tpInput.headstage, name = "headstage")
ASYNC_AddParam(threadDF, str = tpInput.device, name = "device")
ASYNC_AddParam(threadDF, var = tpInput.measurementMarker, name = "marker")
Expand Down
Loading