Skip to content

Add support for replaying data#2712

Draft
t-b wants to merge 6 commits into
mainfrom
feature/2712-replay-data-support
Draft

Add support for replaying data#2712
t-b wants to merge 6 commits into
mainfrom
feature/2712-replay-data-support

Conversation

@t-b
Copy link
Copy Markdown
Collaborator

@t-b t-b commented May 22, 2026

Current limitations:

  • Works only with 1HS
  • No documentation, tests

Steps:

  • Load Experiment and or acquire data
  • Define in the builtin procedure window #define REPLAY_DATA
  • RD_PrepareMIES()
  • RD_ReplayData("ITC18USB_DEV_0", 0) // 0 is the sweepNo
  • RD_CompareSCI("ITC18USB_DEV_0", 0, 0) // sweepNo, HS

ToDos:

  • Instead of overriding the async QC value we should read the read out AD value (Async AD X [XXX]) from the LBN and return that in ASD_ReadChannel
  • Add flag to not override ITI so that it is more accurate
  • Add LBN entry if the data was replayed or not, ignore that in CompareLabnotebook

Open issues:

  • Gad2-IRES-Cre;Ai14-863395.03.06.01_replay.pxp
    • Clamp Mode is different from Operating Mode but both should be the same??
      •RD_ReplayData("ITC18USB_Dev_0", 5)
      ****************************************************************************************
      Enabling replay data logic. All future data will be replayed and *not* freshly acquired.
      ****************************************************************************************
      •RD_CompareSCI("ITC18USB_Dev_0", 5, 0)
      *** Evaluating sweep and LBN data ***
      *** Sweep: 5 ***
      AcquisitionState: 0;0;0;0;0;0;0;0;0 (orig) vs 5;5;5;5;5;5;5;5;5 (replay)
      TP Baseline Vm: -73.5176 (orig) vs (empty) (replay)
      TP Baseline pA: 6.81421 (orig) vs (empty) (replay)
      TP Peak Resistance: 2.96281 (orig) vs (empty) (replay)
      TP Steady State Resistance: 68.3608 (orig) vs (empty) (replay)
      Slow compensation time: 7.74194e-05 (orig) vs 1e-05 (replay)
      Clamp Mode: 1 (orig) vs 0 (replay)
      TP Baseline Fraction: 0.4714 (orig) vs 0.45 (replay)
      TP Amplitude IC: -57.34 (orig) vs 50 (replay)
      TP Auto QC: 1 (orig) vs (empty) (replay)
      TP Cycle ID: 1.34712e+06 (orig) vs (empty) (replay)
      V-Clamp Holding Enable: 1 (orig) vs 0 (replay)
      V-Clamp Holding Level: -69.9835 (orig) vs -0.000253133 (replay)
      Whole Cell Comp Cap: 1.00004 (orig) vs 1 (replay)
      Whole Cell Comp Resist: 0.999858 (orig) vs 1.00037 (replay)
      Pipette Offset: 76.816 (orig) vs -13.001 (replay)
      Async 2 Gain: 0.01 (orig) vs 1 (replay)
      Async 3 Gain: 0.01 (orig) vs 1 (replay)
      The analysis function procedure window can not be opened when the testpulse is running.
    

Close #1123

@t-b t-b self-assigned this May 22, 2026
Copilot AI review requested due to automatic review settings May 22, 2026 19:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an automated-testing-only “replay” mechanism that re-runs acquisition/analysis using previously acquired sweep data and stored LBN settings (intended to support debugging and reproducing analysis behavior from saved experiments).

Changes:

  • Add new replay helper module (UTF_ReplayData.ipf) that backs up MIES state, replays sweeps, and injects acquired AD data into the DAQ pipeline.
  • Hook replay behavior into core acquisition/config paths (set column/cycle count, SCI/RAC IDs, oscilloscope DAQ data) under #ifdef AUTOMATED_TESTING.
  • Extend hardware test acquisition configuration (DAQSettings + parser + AcquireData_NG) to support additional settings (autobias, DA scale, async channels).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
Packages/tests/UTF_ReplayData.ipf New replay/compare helpers and data injection logic for automated testing.
Packages/tests/UTF_HardwareHelperFunctions.ipf Extend DAQSettings and acquisition setup to apply more controls (autobias, DA scaling, async channels).
Packages/tests/HardwareAnalysisFunctions/UTF_HardwareAnalysisFunctions_Includes.ipf Include replay helpers for hardware analysis tests.
Packages/MIES/MIES_WaveDataFolderGetters.ipf Documentation updates for async settings key naming/columns.
Packages/MIES/MIES_Oscilloscope.ipf Inject replay data into DAQDataWave during DAQ in automated testing.
Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf Add global accessor for replay enable flag.
Packages/MIES/MIES_DataConfigurator.ipf Override set column/cycle count and SCI ID from replay settings in automated testing.
Packages/MIES/MIES_DAEphys.ipf Initialize DAQ counters/flags (count, RAC, PRE_SET_EVENT) from replay settings in automated testing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Packages/tests/UTF_ReplayData.ipf Outdated
WAVE numericalValues = GetLBNumericalValues(device)
WAVE/T textualValues = GetLBTextualValues(device)

WAVE sweeps = AFH_GetSweepsFromSameSCI(numericalValues, sweepNo, headstage)
Comment on lines +63 to +71
// now delete all acquired data with sweep <= refSweepNo
WAVE sweeps = AFH_GetSweeps(device)

DFREF deviceData = GetDeviceDataPath(device)

for(sweepNo : sweeps)
if(sweepNo < refSweepNo)
continue
endif
Comment on lines +121 to +126
WAVE numericalValues_replay = root:MIES:LabNoteBook:ITC18USB:Device0:numericalValues
WAVE/T textualValues_replay = root:MIES:LabNoteBook:ITC18USB:Device0:textualValues

WAVE numericalValues_orig = root:MIES_backup:LabNoteBook:ITC18USB:Device0:numericalValues
WAVE/T textualValues_orig = root:MIES_backup:LabNoteBook:ITC18USB:Device0:textualValues

Comment on lines +242 to +245

DFREF sweepDFR_orig = root:MIES_backup:HardwareDevices:ITC18USB:Device0:Data:$("X_" + num2str(sweepNo)):
DFREF sweepDFR_replay = root:MIES:HardwareDevices:ITC18USB:Device0:Data:$("X_" + num2str(sweepNo)):

Comment on lines +401 to +406

// todo
WAVE numericalValues_orig = root:MIES_backup:LabNoteBook:ITC18USB:Device0:numericalValues

settings[%RAC] = GetLastSettingIndep(numericalValues_orig, sweepNo, RA_ACQ_CYCLE_ID_KEY, DATA_ACQUISITION_MODE)

Comment on lines +397 to +416
// todo
Make/FREE/N=(5)/D settings

SetDimensionLabels(settings, "RAC;SCI;SetColumn;SetCycleCount;Count", ROWS)

// todo
WAVE numericalValues_orig = root:MIES_backup:LabNoteBook:ITC18USB:Device0:numericalValues

settings[%RAC] = GetLastSettingIndep(numericalValues_orig, sweepNo, RA_ACQ_CYCLE_ID_KEY, DATA_ACQUISITION_MODE)

WAVE stimsetCycleIDs = GetLastSetting(numericalValues_orig, sweepNo, STIMSET_ACQ_CYCLE_ID_KEY, DATA_ACQUISITION_MODE)
settings[%SCI] = ExtractSingelValue(stimsetCycleIDs)

WAVE setSweepCount = GetLastSetting(numericalValues_orig, sweepNo, "Set Sweep Count", DATA_ACQUISITION_MODE)
settings[%SetColumn] = ExtractSingelValue(setSweepCount)

WAVE setCycleCount = GetLastSetting(numericalValues_orig, sweepNo, "Set Cycle Count", DATA_ACQUISITION_MODE)
settings[%SetCycleCount] = ExtractSingelValue(setCycleCount)

return settings
Comment on lines 1299 to 1302
Make/FREE/N=(NUM_HEADSTAGES) s.asyncAlarm = NaN
Make/FREE/N=(NUM_HEADSTAGES)/D s.da_scale = NaN

Make/FREE/T/N=(NUM_HEADSTAGES) s.st, s.ist, s.af, s.st_ttl, s.iaf
Comment on lines +1355 to +1357
s.ab[headstage] = ParseNumber(str, "_AB", defValue = NaN)
s.abv[headstage] = ParseNumber(str, "_ABV", defValue = NaN)
s.abvv[headstage] = ParseNumber(str, "_ABVV", defValue = NaN)
Comment on lines +1574 to +1576
PGC_SetAndActivateControl(device, "check_DataAcq_AutoBias", val = s.ab[i])
PGC_SetAndActivateControl(device, "setvar_DataAcq_AutoBiasV", val = s.abv[i])
PGC_SetAndActivateControl(device, "setvar_DataAcq_AutoBiasVrange", val = s.abvv[i])
if(RoVar(GetReplayDataEnable()))
WAVE replaySettings = RD_GetReplaySettings(device)

stimsetAcqIDHelper[][%id] = replaySettings[%SCI]
Copilot AI review requested due to automatic review settings May 29, 2026 13:17
@t-b t-b force-pushed the feature/2712-replay-data-support branch from 3ac64b0 to ff700f7 Compare May 29, 2026 13:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Comment on lines 2015 to 2016
for(device : devices)
Make/FREE/WAVE valuesWave = {GetLBNumericalValues(device), GetLBTextualValues(device)}

InvalidateLBIndexAndRowCaches_Impl(valuesWave)
endfor

s.tbp = ParseNumber(str, "_TBP", defValue = NaN)

s.tad = ParseNumber(str, "_TAD", defValue = 0)
Comment on lines +1308 to +1310
Make/FREE/N=(NUM_HEADSTAGES) s.asyncAD = NaN
Make/FREE/N=(NUM_HEADSTAGES) s.asyncAlarm = NaN
Make/FREE/N=(NUM_HEADSTAGES)/D s.da_scale = NaN
Comment on lines +1586 to +1590
if(s.cm[i] == I_CLAMP_MODE)
PGC_SetAndActivateControl(device, "check_DataAcq_AutoBias", val = s.ab[i])
PGC_SetAndActivateControl(device, "setvar_DataAcq_AutoBiasV", val = s.abv[i])
PGC_SetAndActivateControl(device, "setvar_DataAcq_AutoBiasVrange", val = s.abvv[i])
endif
Comment on lines +1365 to +1367
s.ab[headstage] = ParseNumber(str, "_AB", defValue = NaN)
s.abv[headstage] = ParseNumber(str, "_ABV", defValue = NaN)
s.abvv[headstage] = ParseNumber(str, "_ABVV", defValue = NaN)
@t-b t-b force-pushed the feature/2712-replay-data-support branch from ff700f7 to 8efb3ab Compare May 29, 2026 20:24
@t-b
Copy link
Copy Markdown
Collaborator Author

t-b commented May 29, 2026

Gad2-IRES-Cre;Ai14-863395.03.06.01_replay.pxp:

•RD_CompareRAC("ITC18USB_Dev_0", 7)
  *** Evaluating sweep and LBN data ***
  *** Sweep: 7 ***
  *** Sweep: 8 ***
  *** Sweep: 9 ***
  *** Sweep: 10 ***
  *** Sweep: 11 ***
  *** Sweep: 12 ***
  *** Sweep: 13 ***
  *** Sweep: 14 ***
  *** Sweep: 15 ***
  *** Sweep: 16 ***
  *** Sweep: 17 ***
  *** Sweep: 18 ***
  *** Sweep: 19 ***
  *** Sweep: 20 ***
  *** Sweep: 21 ***
  *** Sweep: 22 ***
  *** Sweep: 23 ***
  *** Sweep: 24 ***
  *** Sweep: 25 ***
  *** Sweep: 26 ***
  *** Sweep: 27 ***
  *** Sweep: 28 ***
  *** Sweep: 29 ***
  *** Sweep: 30 ***
  *** Sweep: 31 ***
  *** Sweep: 32 ***
  *** Sweep: 33 ***
  *** Sweep: 34 ***
  *** Sweep: 35 ***
  *** Sweep: 36 ***
  *** Sweep: 37 ***
  *** Sweep: 38 ***
  *** Sweep: 39 ***
  *** Sweep: 40 ***
  *** Sweep: 41 ***
  *** Sweep: 42 ***
  *** Sweep: 43 ***
  *** Sweep: 44 ***
  *** Sweep: 45 ***
  *** Sweep: 46 ***
  *** Sweep: 47 ***
  *** Sweep: 48 ***
  *** Sweep: 49 ***
  *** Sweep: 50 ***
  *** Sweep: 51 ***
  *** Sweep: 52 ***
  *** Sweep: 53 ***
  Difference DA_0 at 184030: 0 (orig) vs 75.125 (replay)
  Difference DA_0 at 184031: 0 (orig) vs 75.125 (replay)
  Difference DA_0 at 184032: 0 (orig) vs 75.125 (replay)
  Difference DA_0 at 184033: 0 (orig) vs 75.125 (replay)
  Difference DA_0 at 184034: 0 (orig) vs 75.125 (replay)
  Difference DA_0 at 184035: 0 (orig) vs 75.125 (replay)
  Difference DA_0 at 184036: 0 (orig) vs 75.125 (replay)
  Difference DA_0 at 184037: 0 (orig) vs 75.125 (replay)
  Difference DA_0 at 184038: 0 (orig) vs 75.125 (replay)
  Difference DA_0 at 184039: 0 (orig) vs 75.125 (replay)
  USER_Ramp Pulse duration: 3003.28 (orig) vs 3003.64 (replay)
  *** Sweep: 54 ***
  Difference DA_0 at 185952: 76.125 (orig) vs 0 (replay)
  Difference DA_0 at 185953: 76.125 (orig) vs 0 (replay)
  Difference DA_0 at 185954: 76.125 (orig) vs 0 (replay)
  Difference DA_0 at 185955: 76.125 (orig) vs 0 (replay)
  Difference DA_0 at 185956: 76.125 (orig) vs 0 (replay)
  Difference DA_0 at 185957: 76.125 (orig) vs 0 (replay)
  Difference DA_0 at 185958: 76.125 (orig) vs 0 (replay)
  Difference DA_0 at 185959: 76.125 (orig) vs 0 (replay)
  Difference DA_0 at 185960: 76.125 (orig) vs 0 (replay)
  Difference DA_0 at 185961: 76.125 (orig) vs 0 (replay)
  TP Baseline pA: 1.04115 (orig) vs (empty) (replay)
  Clamp Mode: 0 (orig) vs 1 (replay)
  USER_Ramp Pulse duration: 3043.18 (orig) vs 3041.72 (replay)
  USER_Ramp Chk1 T-V BL: -0.074638 (orig) vs -0.07464 (replay)
  USER_Ramp Chk4 T-V BL: -0.074305 (orig) vs -0.0743064 (replay)

The differences in the RAMP stimset is expected. The "Clamp Mode" difference is known, see #2712. Adaptive works exactly the same in this experiment.

Copilot AI review requested due to automatic review settings May 29, 2026 21:57
@t-b t-b force-pushed the feature/2712-replay-data-support branch from 8efb3ab to 0dcf361 Compare May 29, 2026 21:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 8 comments.

Comment on lines +245 to +249
#ifdef AUTOMATED_TESTING
if(ROvar(GetReplayDataEnable()))
maxITI = 0.5
endif
#endif // AUTOMATED_TESTING
Comment on lines +4917 to +4921
#ifdef AUTOMATED_TESTING
if(RoVar(GetReplayDataEnable()))
index = 0
endif
#endif // AUTOMATED_TESTING
Comment on lines +242 to +247
elseif(GrepString(elem, "^ASYNC"))
async = ACD_ParseNumber(elem, "ASYNC")
s.asyncAD[async] = 1

s.asyncAlarm[async] = ACD_ParseNumber(elem, "_ALARM")
continue
Comment on lines +227 to +228
Make/FREE/N=(NUM_HEADSTAGES) s.asyncAD = NaN
Make/FREE/N=(NUM_HEADSTAGES) s.asyncAlarm = NaN
Comment on lines +500 to +504
if(s.cm[i] == I_CLAMP_MODE)
PGC_SetAndActivateControl(device, "check_DataAcq_AutoBias", val = s.ab[i])
PGC_SetAndActivateControl(device, "setvar_DataAcq_AutoBiasV", val = s.abv[i])
PGC_SetAndActivateControl(device, "setvar_DataAcq_AutoBiasVrange", val = s.abvv[i])
endif

s.tbp = ACD_ParseNumber(str, "_TBP", defValue = NaN)

s.tad = ACD_ParseNumber(str, "_TAD", defValue = 0)
Comment on lines +1250 to +1252
WAVE replaySettings = RD_GetReplaySettings(device, RD_MODE_ONCE, RD_SWEEP_SELECTOR_NEXT)

count = replaySettings[%SetColumn]
Comment on lines +1278 to +1283
WAVE replaySettings = RD_GetReplaySettings(device, RD_MODE_ONCE, RD_SWEEP_SELECTOR_NEXT)

raCycleID = replaySettings[%RAC]
activeSetCount -= replaySettings[%SetColumn]

setEventFlag[][%PRE_SET_EVENT] = (replaySettings[%SetColumn] == 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow replaying acquired data

2 participants