Skip to content

Commit

Permalink
Merge pull request #1822 from AllenInstitute/feature/1822-Add_TTL_sup…
Browse files Browse the repository at this point in the history
…port_to_SF
  • Loading branch information
t-b authored Aug 3, 2023
2 parents f999f01 + 7da5363 commit 628dd73
Show file tree
Hide file tree
Showing 13 changed files with 491 additions and 257 deletions.
31 changes: 5 additions & 26 deletions Packages/MIES/MIES_BrowserSettingsPanel.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1274,9 +1274,9 @@ Function BSP_CheckProc_ChangedSetting(cba) : CheckBoxControl
endif
break
case "check_BrowserSettings_VisEpochs":
AdaptDependentControls(bsPanel, "check_BrowserSettings_splitTTL", CHECKBOX_UNSELECTED, checked, DEP_CTRLS_SAME)
if(checked)
DisableControls(bsPanel, "check_Display_EqualYrange;check_Display_EqualYignore")
AdaptDependentControls(bsPanel, "check_BrowserSettings_splitTTL", CHECKBOX_SELECTED, CHECKBOX_SELECTED, DEP_CTRLS_SAME)
else
EnableControls(bsPanel, "check_Display_EqualYrange;check_Display_EqualYignore")
endif
Expand Down Expand Up @@ -1608,7 +1608,7 @@ Function BSP_AddTracesForEpochs(string win)

variable i, j, start_x, start_y, end_x, end_y, yOffset
variable headstage, yLevelOffset, level, idx, numTraces, numEpochs
variable sweepNumber, traceIndex, channelType, hwChannelNumber, guiChannelNumber, ttlBit, fetchChanType
variable sweepNumber, traceIndex, channelType, channelNumber
STRUCT RGBColor c
string xaxis, yaxis, axes, axis, levels_x_name, levels_y_name, name, idPart, level_x_trace

Expand Down Expand Up @@ -1663,41 +1663,20 @@ Function BSP_AddTracesForEpochs(string win)
headstage = str2num(traceInfos[i][%headstage])
sweepNumber = str2num(traceInfos[i][%sweepNumber])
channelType = WhichListItem(traceInfos[i][%channelType], XOP_CHANNEL_NAMES)
hwChannelNumber = str2num(traceInfos[i][%channelNumber])
channelNumber = str2num(traceInfos[i][%GUIChannelNumber])

WAVE/Z/T numericalValues = BSP_GetLogbookWave(win, LBT_LABNOTEBOOK, LBN_NUMERICAL_VALUES, sweepNumber = sweepNumber)
ASSERT(WaveExists(numericalValues), "Numerical LabNotebook not found.")
WAVE/Z/T textualValues = BSP_GetLogbookWave(win, LBT_LABNOTEBOOK, LBN_TEXTUAL_VALUES, sweepNumber = sweepNumber)
ASSERT(WaveExists(textualValues), "Textual LabNotebook not found.")

fetchChanType = channelType
switch(channelType)
case XOP_CHANNEL_TYPE_ADC:
guiChannelNumber = hwChannelNumber
guiChannelNumber = SFH_GetDAChannel(win, sweepNumber, channelType, guiChannelNumber)
fetchChanType = XOP_CHANNEL_TYPE_DAC
break
case XOP_CHANNEL_TYPE_DAC:
guiChannelNumber = hwChannelNumber
break
case XOP_CHANNEL_TYPE_TTL:
ttlBit = str2num(traceInfos[i][%TTLBit])
WAVE/Z channelMapHWToGUI = GetActiveChannels(numericalValues, textualValues, sweepNumber, XOP_CHANNEL_TYPE_TTL, TTLmode = TTL_HWTOGUI_CHANNEL)
ASSERT(WaveExists(channelMapHWToGUI), "Expected TTL channel(s) for sweep " + num2istr(sweepNumber) + " in LNB, but none found.")
guiChannelNumber = channelMapHWToGUI[hwChannelNumber][IsNaN(ttlBit) ? 0 : ttlBit]
ASSERT(IsFinite(guiChannelNumber), "Could not retrieve GUI channel number for TTL hardware channel/ttlBits")
break
default:
ASSERT(0, "Unsupported channelType")
endswitch

// present since a2172f03 (Added generations of epoch information wave, 2019-05-22)
WAVE/T/Z epochsFromLBN = EP_FetchEpochs(numericalValues, textualValues, sweepNumber, guiChannelNumber, fetchChanType)
WAVE/T/Z epochsFromLBN = EP_FetchEpochs(numericalValues, textualValues, sweepNumber, channelNumber, channelType)
if(!WaveExists(epochsFromLBN))
continue
endif

sprintf idPart, "_sweep%d_chan%d_type%d_HS%.0g", sweepNumber, guiChannelNumber, channelType, headstage
sprintf idPart, "_sweep%d_chan%d_type%d_HS%.0g", sweepNumber, channelNumber, channelType, headstage
sprintf name, "epochs_%s", idPart
Duplicate/O/T epochsFromLBN, dfr:$name/Wave=epochs

Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_Constants.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Constant DAQ_CONFIG_WAVE_VERSION = 2

/// Used to upgrade the GuiStateWave as well as the DA Ephys panel
Constant DA_EPHYS_PANEL_VERSION = 62
Constant DATA_SWEEP_BROWSER_PANEL_VERSION = 46
Constant DATA_SWEEP_BROWSER_PANEL_VERSION = 47
Constant WAVEBUILDER_PANEL_VERSION = 14
Constant ANALYSISBROWSER_PANEL_VERSION = 3

Expand Down
1 change: 1 addition & 0 deletions Packages/MIES/MIES_DataBrowser.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Function DB_ResetAndStoreCurrentDBPanel()
PGC_SetAndActivateControl(bsPanel, "Settings", val = 0)
CheckBox check_overlaySweeps_disableHS, WIN = $bsPanel, value= 0
CheckBox check_overlaySweeps_non_commula, WIN = $bsPanel, value= 0
CheckBox check_BrowserSettings_splitTTL, WIN = $bsPanel, value= 1
PopupMenu popup_overlaySweeps_select, WIN = $bsPanel, mode=1
SetVariable setvar_overlaySweeps_offset, WIN = $bsPanel, value= _NUM:0
SetVariable setvar_overlaySweeps_step, WIN = $bsPanel, value= _NUM:1
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_DataBrowser_Macro.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ Window DataBrowser() : Graph
CheckBox check_BrowserSettings_splitTTL,userdata(ResizeControlsInfo)+=A"zzzzzzzzzzzz!!#u:Du]k<zzzzzzzzzzz"
CheckBox check_BrowserSettings_splitTTL,userdata(ResizeControlsInfo)+=A"zzz!!#u:Du]k<zzzzzzzzzzzzzz!!!"
CheckBox check_BrowserSettings_splitTTL,userdata(Config_RestorePriority)="20"
CheckBox check_BrowserSettings_splitTTL,value=0
CheckBox check_BrowserSettings_splitTTL,value=1
PopupMenu popup_DB_lockedDevices,pos={54.00,301.00},size={205.00,19.00},bodyWidth=100,proc=DB_PopMenuProc_LockDBtoDevice
PopupMenu popup_DB_lockedDevices,title="Device assignment:"
PopupMenu popup_DB_lockedDevices,help={"Select a data acquistion device to display data"}
Expand Down
24 changes: 16 additions & 8 deletions Packages/MIES/MIES_Epochs.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ Function/WAVE EP_GetEpochs(WAVE numericalValues, WAVE textualValues, variable sw
variable index, epochCnt, midSweep
string regexp

ASSERT(channelType == XOP_CHANNEL_TYPE_DAC || channelType == XOP_CHANNEL_TYPE_TTL, "Only channelType XOP_CHANNEL_TYPE_DAC and XOP_CHANNEL_TYPE_TTL is supported")
ASSERT(channelType == XOP_CHANNEL_TYPE_DAC || channelType == XOP_CHANNEL_TYPE_ADC || channelType == XOP_CHANNEL_TYPE_TTL, "Unsupported channel type")
treelevel = ParamIsDefault(treelevel) ? NaN : treelevel

if(ParamIsDefault(epochsWave) || !WaveExists(epochsWave))
Expand All @@ -926,14 +926,12 @@ Function/WAVE EP_GetEpochs(WAVE numericalValues, WAVE textualValues, variable sw
endif

if(!midsweep)
WAVE/T/Z epochInfo = EP_FetchEpochs(numericalValues, textualValues, sweepNo, channelNumber, channelType)

if(!WaveExists(epochInfo))
WAVE/T/Z epochInfoChannel = EP_FetchEpochs(numericalValues, textualValues, sweepNo, channelNumber, channelType)
if(!WaveExists(epochInfoChannel))
return $""
endif

Duplicate/FREE/T/RMD=[][][][channelType] epochInfo, epochInfoChannel
epochCnt = DimSize(epochInfo, ROWS)
epochCnt = DimSize(epochInfoChannel, ROWS)
else
epochCnt = EP_GetEpochCount(epochsWave, channelNumber, channelType)

Expand Down Expand Up @@ -992,10 +990,20 @@ End
///
/// See GetEpochsWave() for the wave layout.
threadsafe Function/WAVE EP_FetchEpochs(WAVE numericalValues, WAVE/T/Z textualValues, variable sweep, variable channelNumber, variable channelType)

variable index

if(channelType != XOP_CHANNEL_TYPE_DAC && channelType != XOP_CHANNEL_TYPE_TTL)
return $""
ASSERT_TS(channelType == XOP_CHANNEL_TYPE_DAC || channelType == XOP_CHANNEL_TYPE_ADC || channelType == XOP_CHANNEL_TYPE_TTL, "Unsupported channel type")
if(channelType == XOP_CHANNEL_TYPE_ADC)
[WAVE setting, index] = GetLastSettingChannel(numericalValues, $"", sweep, "DAC", channelNumber, XOP_CHANNEL_TYPE_ADC, DATA_ACQUISITION_MODE)
if(!WaveExists(setting))
return $""
endif
channelType = XOP_CHANNEL_TYPE_DAC
channelNumber = setting[index]
if(!(IsFinite(channelNumber) && index < NUM_HEADSTAGES))
return $""
endif
endif

[WAVE setting, index] = GetLastSettingChannel(numericalValues, textualValues, sweep, EPOCHS_ENTRY_KEY, channelNumber, channelType, DATA_ACQUISITION_MODE)
Expand Down
Loading

0 comments on commit 628dd73

Please sign in to comment.