Skip to content

Commit

Permalink
AFH_GetNextSweepSetCount: Factor it out
Browse files Browse the repository at this point in the history
  • Loading branch information
t-b committed Nov 5, 2024
1 parent d95b7db commit 3d2acf3
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions Packages/MIES/MIES_AnalysisFunctionHelpers.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ End
/// 0 if not and NaN if it is not possible to determine
Function AFH_LastSweepInSet(string device, variable sweepNo, variable headstage, variable eventType)

variable DAC, sweepsInSet, setCount, skipCountExisting, sweepOffset
variable DAC, sweepsInSet, nextStimsetColumn, sweepOffset

switch(eventType)
case PRE_DAQ_EVENT:
Expand All @@ -1279,17 +1279,30 @@ Function AFH_LastSweepInSet(string device, variable sweepNo, variable headstage,
case MID_SWEEP_EVENT:
// we need to look at the last acquired sweep
sweepNo -= 1
sweepOffset = 2
sweepOffset = 1
break
default:
sweepOffset = 1
// do nothing
endswitch

DAC = AFH_GetDACFromHeadstage(device, headstage)
sweepsInSet = IDX_NumberOfSweepsInSet(AFH_GetStimSetName(device, DAC, CHANNEL_TYPE_DAC))

WAVE numericalValues = GetLBNumericalValues(device)
WAVE/Z sweepSetCount = GetLastSetting(numericalValues, sweepNo, "Set Sweep Count", DATA_ACQUISITION_MODE)
WAVE numericalValues = GetLBNumericalValues(device)

nextStimsetColumn = AFH_GetNextSweepSetCount(numericalValues, sweepNo, headstage)

return (nextStimsetColumn + sweepOffset) >= sweepsInSet
End

/// @brief Return the set count of the next sweep
///
/// No checking is done on the number of sweeps in the stimulus set
Function AFH_GetNextSweepSetCount(WAVE numericalValues, variable sweepNo, variable headstage)

variable setCount, skipCountExisting

WAVE/Z sweepSetCount = GetLastSetting(numericalValues, sweepNo, "Set Sweep Count", DATA_ACQUISITION_MODE)

if(!WaveExists(sweepSetCount))
setCount = 0
Expand All @@ -1299,5 +1312,5 @@ Function AFH_LastSweepInSet(string device, variable sweepNo, variable headstage,

skipCountExisting = GetLastSettingIndep(numericalValues, sweepNo, SKIP_SWEEPS_KEY, UNKNOWN_MODE, defValue = 0)

return (setCount + sweepOffset + skipCountExisting) >= sweepsInSet
return setCount + skipCountExisting + 1
End

0 comments on commit 3d2acf3

Please sign in to comment.