Skip to content

Commit

Permalink
Util: Add GUI channel number to TUD in CreateTiledChannelGraph
Browse files Browse the repository at this point in the history
- Having the GUI channel number simplifies code that use trace user data
  information
  • Loading branch information
MichaelHuth committed Jul 21, 2023
1 parent d5512a4 commit adc3ca4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
17 changes: 14 additions & 3 deletions Packages/MIES/MIES_MiesUtilities.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2652,7 +2652,7 @@ Function CreateTiledChannelGraph(string graph, WAVE config, variable sweepNo, WA

variable axisIndex, numChannels
variable numDACs, numADCs, numTTLs, i, j, k, hasPhysUnit, hardwareType
variable moreData, chan, numHorizWaves, numVertWaves, idx
variable moreData, chan, guiChannelNumber, numHorizWaves, numVertWaves, idx
variable numTTLBits, headstage, channelType
variable delayOnsetUser, delayOnsetAuto, delayTermination, delaydDAQ, dDAQEnabled, oodDAQEnabled
variable stimSetLength, samplingInt, xRangeStart, xRangeEnd, first, last, count, ttlBit
Expand All @@ -2667,7 +2667,7 @@ Function CreateTiledChannelGraph(string graph, WAVE config, variable sweepNo, WA

Make/T/FREE userDataKeys = {"fullPath", "channelType", "channelNumber", "sweepNumber", "headstage", \
"textualValues", "numericalValues", "clampMode", "TTLBit", "experiment", "traceType", \
"occurence", "XAXIS", "YAXIS", "YRANGE", "TRACECOLOR", "AssociatedHeadstage"}
"occurence", "XAXIS", "YAXIS", "YRANGE", "TRACECOLOR", "AssociatedHeadstage", "GUIChannelNumber"}

WAVE ADCs = GetADCListFromConfig(config)
WAVE DACs = GetDACListFromConfig(config)
Expand All @@ -2693,6 +2693,10 @@ Function CreateTiledChannelGraph(string graph, WAVE config, variable sweepNo, WA
numDACs = DimSize(DACs, ROWS)
numADCs = DimSize(ADCs, ROWS)
numTTLs = DimSize(TTLs, ROWS)
if(numTTLs > 0)
WAVE/Z channelMapHWToGUI = GetActiveChannels(numericalValues, textualValues, sweepNo, XOP_CHANNEL_TYPE_TTL, TTLmode = TTL_HWTOGUI_CHANNEL)
ASSERT(WaveExists(channelMapHWToGUI), "Can not find LNB entries for active TTL channels from config wave.")
endif

hardwareType = GetUsedHWDACFromLNB(numericalValues, sweepNo)
WAVE/Z ttlRackZeroBits = GetLastSetting(numericalValues, sweepNo, "TTL rack zero bits", DATA_ACQUISITION_MODE)
Expand Down Expand Up @@ -2939,6 +2943,12 @@ Function CreateTiledChannelGraph(string graph, WAVE config, variable sweepNo, WA
name = channelID + num2str(chan)
endif

if(channelType == XOP_CHANNEL_TYPE_TTL)
guiChannelNumber = channelMapHWToGUI[chan][IsNaN(ttlBit) ? 0 : ttlBit]
else
guiChannelNumber = chan
endif

DFREF singleSweepDFR = GetSingleSweepFolder(sweepDFR, sweepNo)

ASSERT(DataFolderExistsDFR(singleSweepDFR), "Missing singleSweepDFR")
Expand Down Expand Up @@ -3114,7 +3124,8 @@ Function CreateTiledChannelGraph(string graph, WAVE config, variable sweepNo, WA
{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))})
num2str(k), horizAxis, vertAxis, traceRange, traceColor, num2istr(IsFinite(headstage)), \
num2istr(guiChannelNumber)})
endfor
endfor

Expand Down
8 changes: 4 additions & 4 deletions Packages/tests/Basic/UTF_SweepFormula.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ static Function [variable numSweeps, variable numChannels, WAVE/U/I channels] Fi
WAVE wv = $name
AppendToGraph/W=$win wv/TN=$trace
channelNumber = channels[i][j]
TUD_SetUserDataFromWaves(win, trace, {"experiment", "fullPath", "traceType", "occurence", "channelType", "channelNumber", "sweepNumber"}, \
{"blah", GetWavesDataFolder(wv, 2), "Sweep", "0", channelType, num2str(channelNumber), num2str(sweepNumber)})
TUD_SetUserDataFromWaves(win, trace, {"experiment", "fullPath", "traceType", "occurence", "channelType", "channelNumber", "sweepNumber", "GUIChannelNumber"}, \
{"blah", GetWavesDataFolder(wv, 2), "Sweep", "0", channelType, num2str(channelNumber), num2str(sweepNumber), num2istr(channelNumber)})
values[connections[j]] = channelNumber
config[j][%ChannelType] = XOP_CHANNEL_TYPE_ADC
config[j][%ChannelNumber] = channelNumber
Expand Down Expand Up @@ -2517,8 +2517,8 @@ static Function TestOperationData()
Extract input, $name, q == i && r == j
WAVE wv = $name
AppendToGraph/W=$win wv/TN=$trace
TUD_SetUserDataFromWaves(win, trace, {"experiment", "fullPath", "traceType", "occurence", "channelType", "channelNumber", "sweepNumber"}, \
{"blah", GetWavesDataFolder(wv, 2), "Sweep", "0", StringFromList(j, channelTypeList), StringFromList(j, channelNumberList), num2istr(sweepNo)})
TUD_SetUserDataFromWaves(win, trace, {"experiment", "fullPath", "traceType", "occurence", "channelType", "channelNumber", "sweepNumber", "GUIChannelNumber"}, \
{"blah", GetWavesDataFolder(wv, 2), "Sweep", "0", StringFromList(j, channelTypeList), StringFromList(j, channelNumberList), num2istr(sweepNo), StringFromList(j, channelNumberList)})
endfor
endfor

Expand Down

0 comments on commit adc3ca4

Please sign in to comment.