@@ -38,8 +38,8 @@ static Constant FROM_WAVE_TO_PANEL = 0x2
3838
3939Function WB_OpenStimulusSetInWaveBuilder ()
4040
41- string graph, trace, extPanel, waveBuilder
42- variable sweepNo, headstage
41+ string graph, trace, extPanel, waveBuilder, stimset , device
42+ variable sweepNo, headstage, abIndex , sbIndex
4343
4444 GetLastUserMenuInfo
4545 graph = S_graphName
@@ -57,16 +57,44 @@ Function WB_OpenStimulusSetInWaveBuilder()
5757 headstage = str2num ( TUD_GetUserData ( graph, trace, "headstage" ))
5858 WAVE /T textualValues = $ TUD_GetUserData ( graph, trace, "textualValues" )
5959
60- WAVE /T/ Z stimset = GetLastSetting ( textualValues, sweepNo, STIM_WAVE_NAME_KEY, DATA_ACQUISITION_MODE)
60+ WAVE /T/ Z stimsetLBN = GetLastSetting ( textualValues, sweepNo, STIM_WAVE_NAME_KEY, DATA_ACQUISITION_MODE)
6161
62- if ( ! WaveExists ( stimset ))
62+ if ( ! WaveExists ( stimsetLBN ) || IsNaN ( headstage ))
6363 printf "Context menu option \" %s\" could not find the stimulus set of the trace %s.\r " , S_Value, trace
6464 ControlWindowToFront ()
6565 return NaN
6666 endif
6767
68+ stimset = stimsetLBN[ headstage]
69+
70+ WAVE /Z stimsetWave = WB_CreateAndGetStimSet ( stimset)
71+
72+ if ( ! WaveExists ( stimsetWave))
73+ if ( BSP_IsDataBrowser ( graph))
74+ printf "Context menu option \" %s\" could not be find the stimulus set %s." , S_Value, stimset
75+ ControlWindowToFront ()
76+ return NaN
77+ else
78+ // we might need to load the stimset
79+ WAVE traceWave = $ TUD_GetUserData ( graph, trace, "fullPath" )
80+ DFREF sweepDataDFR = GetWavesDataFolderDFR ( traceWave)
81+ sbIndex = SB_GetIndexFromSweepDataPath ( graph, sweepDataDFR)
82+
83+ DFREF sweepBrowserDFR = SB_GetSweepBrowserFolder ( graph)
84+ WAVE /T sweepMap = GetSweepBrowserMap ( sweepBrowserDFR)
85+
86+ abIndex = SB_TranslateSBMapIndexToABMapIndex ( graph, sbIndex)
87+ device = sweepMap[ sbIndex][ % Device]
88+ if ( AB_LoadStimsetForSweep ( device, abIndex, sweepNo))
89+ printf "Context menu option \" %s\" could not load the stimulus set %s." , S_Value, stimset
90+ ControlWindowToFront ()
91+ return NaN
92+ endif
93+ endif
94+ endif
95+
6896 waveBuilder = WBP_CreateWaveBuilderPanel ()
69- PGC_SetAndActivateControl ( waveBuilder, "popup_WaveBuilder_SetList" , str = stimset[ headstage ] )
97+ PGC_SetAndActivateControl ( waveBuilder, "popup_WaveBuilder_SetList" , str = stimset)
7098End
7199
72100Function /S WBP_CreateWaveBuilderPanel ()
0 commit comments