Skip to content

Commit

Permalink
IsValidHeadstage: Prefer it
Browse files Browse the repository at this point in the history
  • Loading branch information
t-b committed Feb 3, 2025
1 parent b0f8afb commit 13196f7
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static Function/WAVE SC_GetHeadstageQCForSetCount(string device, variable sweepN

setSweepCount = SC_GetSetSweepCount(numericalValues, sweeps[i])

headstageQCTotalPerSweepCount[][setSweepCount] += IsFinite(headstageQCLBN[p]) ? headstageQCLBN[p] : NaN
headstageQCTotalPerSweepCount[][setSweepCount] += IsValidHeadstage(headstageQCLBN[p]) ? headstageQCLBN[p] : NaN
endfor

#ifdef DEBUGGING_ENABLED
Expand Down
12 changes: 6 additions & 6 deletions Packages/MIES/MIES_Browser_Plotter.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ Function CreateTiledChannelGraph(string graph, WAVE config, variable sweepNo, WA
endif

// ignore TP during DAQ channels
if(WaveExists(status) && IsFinite(headstage))
if(WaveExists(status) && IsValidHeadstage(headstage))
if(channelType == XOP_CHANNEL_TYPE_DAC \
&& WaveExists(daChannelType) \
&& daChannelType[headstage] != DAQ_CHANNEL_TYPE_DAQ)
Expand Down Expand Up @@ -531,11 +531,11 @@ Function CreateTiledChannelGraph(string graph, WAVE config, variable sweepNo, WA
endif
endif

TUD_SetUserDataFromWaves(graph, trace, userDataKeys, \
{GetWavesDataFolder(wv, 2), channelID, num2str(chan), num2str(sweepNo), num2str(headstage), \
GetWavesDataFolder(textualValues, 2), GetWavesDataFolder(numericalValues, 2), \
num2str(IsFinite(headstage) ? clampModes[headstage] : NaN), num2str(ttlBit), experiment, "Sweep", \
num2str(k), horizAxis, vertAxis, traceRange, traceColor, num2istr(IsFinite(headstage)), \
TUD_SetUserDataFromWaves(graph, trace, userDataKeys, \
{GetWavesDataFolder(wv, 2), channelID, num2str(chan), num2str(sweepNo), num2str(headstage), \
GetWavesDataFolder(textualValues, 2), GetWavesDataFolder(numericalValues, 2), \
num2str(IsValidHeadstage(headstage) ? clampModes[headstage] : NaN), num2str(ttlBit), experiment, "Sweep", \
num2str(k), horizAxis, vertAxis, traceRange, traceColor, num2istr(IsValidHeadstage(headstage)), \
num2istr(guiChannelNumber), device, num2str(mapIndex)})
endfor
endfor
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 @@ -680,15 +680,15 @@ static Function LBV_AddTraceToLBGraphTPStorage(string graph, DFREF dfr, string k
if(legacyActiveADColumns)
headstage = AFH_GetHeadstageFromActiveADC(statusADC, j)

if(IsNaN(headstage))
if(!IsValidHeadstage(headstage))
BUG("Could not derive headstage from active ADC")
headstage = j
endif
else
headstage = j
endif

if(IsFinite(headstage) && !channelSel[headstage][%HEADSTAGE])
if(IsValidHeadstage(headstage) && !channelSel[headstage][%HEADSTAGE])
continue
endif

Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_MiesUtilities_GUI.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Function [STRUCT RGBColor s] GetHeadstageColor(variable headstage, [variable cha

isSplitted = ParamIsDefault(isSplitted) ? 1 : !!isSplitted

if(IsFinite(headstage))
if(IsValidHeadstage(headstage))
colorIndex = headstage
elseif(!ParamIsDefault(channelType) && channelType == XOP_CHANNEL_TYPE_TTL)
// The mapping is based on ITC hardware with unsplitted and splitted TTL channels in the following index order
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_Oscilloscope.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ Function SCOPE_CreateGraph(string device, variable dataAcqOrTP)
AppendToGraph/W=$graph/R=$rightAxis/T=$AXIS_SCOPE_TP_TIME TPStorage[][headstage][%SteadyStateResistance]/TN=$steadyStateTrace vs TPStorage[][headstage][%DeltaTimeInSeconds]
SetAxis/W=$graph/A=2/N=1 $rightAxis
ModifyGraph/W=$graph fSize($rightAxis)=10, grid($rightAxis)=1, gridStyle($rightAxis)=4, gridRGB($rightAxis)=(0, 0, 0, 3277)
ASSERT(isFinite(headStage), "invalid headStage")
ASSERT(IsValidHeadstage(headStage), "invalid headStage")
if(isFinite(PressureData[headStage][%DAC_DevID])) // Check if pressure is enabled
ModifyGraph/W=$graph marker($steadyStateTrace)=19, mode($steadyStateTrace)=4
ModifyGraph/W=$graph msize($steadyStateTrace)=1, gaps($steadyStateTrace)=0
Expand Down
4 changes: 2 additions & 2 deletions Packages/MIES/MIES_PulseAveraging.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -3162,7 +3162,7 @@ static Function PA_AddColorScales(string win, STRUCT PulseAverageSettings &pa, S
endif
// assume that all pulses are from the same headstage
headstage = properties[setIndizes[0]][PA_PROPERTIES_INDEX_HEADSTAGE]
ASSERT(IsFinite(headstage), "Invalid headstage")
ASSERT(IsValidHeadstage(headstage), "Invalid headstage")

name = "colorScale_AD_" + num2str(channelNumber)
text = "HS" + num2str(headstage) + " (\\U)"
Expand Down Expand Up @@ -3214,7 +3214,7 @@ static Function PA_AddColorScales(string win, STRUCT PulseAverageSettings &pa, S
continue
endif
headstage = properties[setIndizes[0]][PA_PROPERTIES_INDEX_HEADSTAGE]
ASSERT(IsFinite(headstage), "Invalid headstage")
ASSERT(IsValidHeadstage(headstage), "Invalid headstage")

WAVE img = GetPulseAverageSetImageWave(pasi.pulseAverageDFR, channelNumber, region)
traceName = NameOfWave(img)
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_SweepFormula.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -5617,7 +5617,7 @@ static Function/WAVE SF_GetAdditionalSweepsWithSameSCIorRAC(WAVE numericalValues

if(mode == SELECTDATA_MODE_SCI)
headstage = GetHeadstageForChannel(numericalValues, sweepNo, channelType, channelNumber, DATA_ACQUISITION_MODE)
if(IsNaN(headstage))
if(!IsValidHeadstage(headstage))
return $""
endif
WAVE/Z additionalSweeps = AFH_GetSweepsFromSameSCI(numericalValues, sweepNo, headstage)
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_TestPulse.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ static Function TP_AnalyzeTP(string device, WAVE/Z TPStorage, variable endRow)

headstage = TPStorage[endRow][i][%Headstage]

if(!IsFinite(headstage) || DC_GetChannelTypefromHS(device, headstage) != DAQ_CHANNEL_TYPE_TP)
if(!IsValidHeadstage(headstage) || DC_GetChannelTypefromHS(device, headstage) != DAQ_CHANNEL_TYPE_TP)
continue
endif

Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_WaveBuilderPanel.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Function WB_OpenStimulusSetInWaveBuilder()

WAVE/Z/T stimsetLBN = GetLastSetting(textualValues, sweepNo, STIM_WAVE_NAME_KEY, DATA_ACQUISITION_MODE)

if(!WaveExists(stimsetLBN) || IsNaN(headstage))
if(!WaveExists(stimsetLBN) || !IsValidHeadstage(headstage))
printf "Context menu option \"%s\" could not find the stimulus set of the trace %s.\r", S_Value, trace
ControlWindowToFront()
return NaN
Expand Down

0 comments on commit 13196f7

Please sign in to comment.