Skip to content

Commit 6ee4550

Browse files
authored
Merge pull request #574 from AllenInstitute/bugfix/faster-pulse-average-updates
Faster pulse average updates
2 parents 7fc0060 + effb9ee commit 6ee4550

File tree

3 files changed

+43
-31
lines changed

3 files changed

+43
-31
lines changed

Packages/MIES/MIES_MiesUtilities.ipf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,7 +3492,7 @@ Function PostPlotTransformations(graph)
34923492

34933493
AverageWavesFromSameYAxisIfReq(graph, traces, pps.averageTraces, pps.averageDataFolder, pps.hideSweep)
34943494
AR_HighlightArtefactsEntry(graph)
3495-
PA_ShowPulses(graph, pps.averageDataFolder, pps.pulseAverSett)
3495+
PA_Update(graph)
34963496
BSP_ScaleAxes(graph)
34973497
End
34983498

@@ -3512,8 +3512,6 @@ static Function InitPostPlotSettings(win, pps)
35123512
pps.timeAlignLevel = GetSetVariable(bsPanel, "setvar_TimeAlignment_LevelCross")
35133513
pps.timeAlignRefTrace = GetPopupMenuString(bsPanel, "popup_TimeAlignment_Master")
35143514
pps.timeAlignment = GetCheckBoxState(bsPanel, "check_BrowserSettings_TA")
3515-
3516-
PA_GatherSettings(win, pps)
35173515
End
35183516

35193517
/// @brief Time Alignment for the BrowserSettingsPanel

Packages/MIES/MIES_PulseAveraging.ipf

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -303,35 +303,37 @@ static Function/WAVE PA_CreateAndFillPulseWaveIfReq(wv, singleSweepFolder, chann
303303
End
304304

305305
/// @brief Populates pps.pulseAverSett with the user selection from the panel
306-
Function PA_GatherSettings(win, pps)
306+
static Function PA_GatherSettings(win, s)
307307
string win
308-
STRUCT PostPlotSettings &pps
308+
STRUCT PulseAverageSettings &s
309309

310310
string extPanel
311311

312312
win = GetMainWindow(win)
313313
extPanel = BSP_GetPanel(win)
314314

315315
if(!PA_IsActive(win))
316-
InitPulseAverageSettings(pps.pulseAverSett)
316+
InitPulseAverageSettings(s)
317317
return 0
318318
endif
319319

320-
pps.pulseAverSett.showIndividualTraces = GetCheckboxState(extPanel, "check_pulseAver_indTraces")
321-
pps.pulseAverSett.showAverageTrace = GetCheckboxState(extPanel, "check_pulseAver_showAver")
322-
pps.pulseAverSett.multipleGraphs = GetCheckboxState(extPanel, "check_pulseAver_multGraphs")
323-
pps.pulseAverSett.startingPulse = GetSetVariable(extPanel, "setvar_pulseAver_startPulse")
324-
pps.pulseAverSett.endingPulse = GetSetVariable(extPanel, "setvar_pulseAver_endPulse")
325-
pps.pulseAverSett.fallbackPulseLength = GetSetVariable(extPanel, "setvar_pulseAver_fallbackLength")
326-
pps.pulseAverSett.regionSlider = BSP_GetDDAQ(win)
327-
pps.pulseAverSett.zeroTraces = GetCheckboxState(extPanel, "check_pulseAver_zeroTrac")
328-
pps.pulseAverSett.autoTimeAlignment = GetCheckboxState(extPanel, "check_pulseAver_timeAlign")
329-
330-
PA_DeconvGatherSettings(win, pps.pulseAverSett.deconvolution)
320+
s.dfr = BSP_GetFolder(win, MIES_BSP_PANEL_FOLDER)
321+
s.enabled = GetCheckboxState(extPanel, "check_BrowserSettings_PA")
322+
s.showIndividualTraces = GetCheckboxState(extPanel, "check_pulseAver_indTraces")
323+
s.showAverageTrace = GetCheckboxState(extPanel, "check_pulseAver_showAver")
324+
s.multipleGraphs = GetCheckboxState(extPanel, "check_pulseAver_multGraphs")
325+
s.startingPulse = GetSetVariable(extPanel, "setvar_pulseAver_startPulse")
326+
s.endingPulse = GetSetVariable(extPanel, "setvar_pulseAver_endPulse")
327+
s.fallbackPulseLength = GetSetVariable(extPanel, "setvar_pulseAver_fallbackLength")
328+
s.regionSlider = BSP_GetDDAQ(win)
329+
s.zeroTraces = GetCheckboxState(extPanel, "check_pulseAver_zeroTrac")
330+
s.autoTimeAlignment = GetCheckboxState(extPanel, "check_pulseAver_timeAlign")
331+
332+
PA_DeconvGatherSettings(win, s.deconvolution)
331333
End
332334

333335
/// @brief gather deconvolution settings from PA section in BSP
334-
Function PA_DeconvGatherSettings(win, deconvolution)
336+
static Function PA_DeconvGatherSettings(win, deconvolution)
335337
string win
336338
STRUCT PulseAverageDeconvSettings &deconvolution
337339

@@ -343,9 +345,18 @@ Function PA_DeconvGatherSettings(win, deconvolution)
343345
deconvolution.range = GetSetVariable(bsPanel, "setvar_pulseAver_deconv_range")
344346
End
345347

346-
Function PA_ShowPulses(win, dfr, pa)
348+
/// @brief Update the PA plot to accomodate changed settings
349+
Function PA_Update(string win)
350+
351+
string graph = GetMainWindow(win)
352+
353+
STRUCT PulseAverageSettings s
354+
PA_GatherSettings(graph, s)
355+
PA_ShowPulses(graph, s)
356+
End
357+
358+
static Function PA_ShowPulses(win, pa)
347359
string win
348-
DFREF dfr
349360
STRUCT PulseAverageSettings &pa
350361

351362
string graph, preExistingGraphs
@@ -364,7 +375,7 @@ Function PA_ShowPulses(win, dfr, pa)
364375

365376
preExistingGraphs = PA_GetAverageGraphs()
366377

367-
if(!PA_IsActive(win))
378+
if(!pa.enabled)
368379
KillWindows(preExistingGraphs)
369380
return NaN
370381
endif
@@ -390,7 +401,7 @@ Function PA_ShowPulses(win, dfr, pa)
390401
TUD_Clear(graph)
391402
endfor
392403

393-
DFREF pulseAverageDFR = GetDevicePulseAverageFolder(dfr)
404+
DFREF pulseAverageDFR = GetDevicePulseAverageFolder(pa.dfr)
394405
Make/FREE/T userDataKeys = {"fullPath", "sweepNumber", "region", "channelNumber", "channelType", \
395406
"pulseIndex", "traceType", "occurence", "XAXIS", "YAXIS", "DiagonalElement"}
396407

@@ -719,7 +730,7 @@ End
719730
/// Note: MIES_fWaveAverage() usually takes 5 times longer than CA_AveragingKey()
720731
///
721732
/// @returns wave reference to the average wave specified by @p outputDFR and @p outputWaveName
722-
Function/WAVE PA_Average(listOfWaves, outputDFR, outputWaveName)
733+
static Function/WAVE PA_Average(listOfWaves, outputDFR, outputWaveName)
723734
string listOfWaves
724735
DFREF outputDFR
725736
string outputWaveName
@@ -752,7 +763,7 @@ Function/WAVE PA_SmoothDeconv(input, deconvolution)
752763
return wv
753764
End
754765

755-
Function/WAVE PA_Deconvolution(average, outputDFR, outputWaveName, deconvolution)
766+
static Function/WAVE PA_Deconvolution(average, outputDFR, outputWaveName, deconvolution)
756767
WAVE average
757768
DFREF outputDFR
758769
string outputWaveName
@@ -783,7 +794,7 @@ Function PA_CheckProc_Common(cba) : CheckBoxControl
783794

784795
switch(cba.eventCode)
785796
case 2: // mouse up
786-
UpdateSweepPlot(cba.win)
797+
PA_Update(cba.win)
787798
break
788799
endswitch
789800

@@ -796,7 +807,7 @@ Function PA_CheckProc_Individual(cba) : CheckBoxControl
796807
switch(cba.eventCode)
797808
case 2: // mouse up
798809
BSP_SetIndividualControlStatus(cba.win)
799-
UpdateSweepPlot(cba.win)
810+
PA_Update(cba.win)
800811
break
801812
endswitch
802813

@@ -809,7 +820,7 @@ Function PA_CheckProc_Average(cba) : CheckBoxControl
809820
switch(cba.eventCode)
810821
case 2: // mouse up
811822
BSP_SetDeconvControlStatus(cba.win)
812-
UpdateSweepPlot(cba.win)
823+
PA_Update(cba.win)
813824
break
814825
endswitch
815826

@@ -838,7 +849,7 @@ Function PA_SetVarProc_Common(sva) : SetVariableControl
838849
case 1: // mouse up
839850
case 2: // Enter key
840851
case 3: // Live update
841-
UpdateSweepPlot(sva.win)
852+
PA_Update(sva.win)
842853
break
843854
endswitch
844855

@@ -895,7 +906,7 @@ Function PA_DeconvolutionIsActive(win)
895906
End
896907

897908
/// @brief Update deconvolution traces in Sweep Plots
898-
Function PA_UpdateSweepPlotDeconvolution(win, show)
909+
static Function PA_UpdateSweepPlotDeconvolution(win, show)
899910
string win
900911
variable show
901912

@@ -972,7 +983,7 @@ End
972983
/// traces are plotted on the diagonal graphs/axes of the PA graph(s).
973984
///
974985
/// @param refTraces list of graph#trace entries as reference for time alignment
975-
Function PA_AutomaticTimeAlignment(refTraces)
986+
static Function PA_AutomaticTimeAlignment(refTraces)
976987
string refTraces
977988

978989
string graphtrace

Packages/MIES/MIES_Structures.ipf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ EndStructure
4343
Function InitPulseAverageSettings(pa)
4444
STRUCT PulseAverageSettings &pa
4545

46+
pa.enabled = 0
4647
pa.showIndividualTraces = NaN
4748
pa.showAverageTrace = NaN
4849
pa.startingPulse = NaN
@@ -52,13 +53,15 @@ Function InitPulseAverageSettings(pa)
5253
pa.multipleGraphs = NaN
5354
pa.zeroTraces = NaN
5455
pa.autoTimeAlignment = NaN
56+
pa.dfr = $""
5557
End
5658

5759
Structure PulseAverageSettings
5860
variable showIndividualTraces, showAverageTrace
5961
variable startingPulse, endingPulse, regionSlider
6062
variable fallbackPulseLength, multipleGraphs
61-
variable zeroTraces, autoTimeAlignment
63+
variable zeroTraces, autoTimeAlignment, enabled
64+
DFREF dfr
6265

6366
STRUCT PulseAverageDeconvSettings deconvolution
6467
EndStructure

0 commit comments

Comments
 (0)