Bug 15: _current_plot_data Cleared After Being Set
Date: November 17, 2025 Severity: CRITICAL Impact: All analysis tabs showed “Please load and plot data before running analysis” even after data was loaded
Problem Description
After refactoring, all analysis tabs (Event Detection, RMP, Spike) were showing the error:
“Please load and plot data before running analysis.”
Even though:
Files were successfully loaded
Data was successfully plotted (log shows “Successfully plotted Average from channel 0”)
_current_plot_datawas set by the base class
Root Cause
The refactoring introduced a call order bug:
Base class (
base.py):
_on_analysis_item_selected()→ calls_populate_channel_and_source_comboboxes()Which calls
_plot_selected_data()→ sets_current_plot_dataThen calls
_update_ui_for_selected_item()(subclass method)
Subclasses (Event Detection, RMP, Spike):
_update_ui_for_selected_item()→ clears_current_plot_data = None
Result: Data was set, then immediately cleared, causing analysis to fail!
The Fix
Removed the lines that clear _current_plot_data from _update_ui_for_selected_item() in all three affected tabs.
Files Fixed
event_detection_tab.py(line 334)rmp_tab.py(line 278)spike_tab.py(line 165)
Code Changes
Before (WRONG):
def _update_ui_for_selected_item(self):
log.debug(f"{self.get_display_name()}: Updating UI for selected item index {self._selected_item_index}")
# Clear previous results
self._current_plot_data = None # This clears data that base class just set!
if self.mini_results_textedit:
self.mini_results_textedit.setText("")
After (CORRECT):
def _update_ui_for_selected_item(self):
log.debug(f"{self.get_display_name()}: Updating UI for selected item index {self._selected_item_index}")
# Clear previous results (but NOT _current_plot_data - base class manages it)
if self.mini_results_textedit: # No longer clearing _current_plot_data
self.mini_results_textedit.setText("")
Why This Happened
During refactoring, the responsibility for managing _current_plot_data was moved to the base class. However, the subclasses still had leftover code from the old implementation that cleared this data.
Old Pattern (Before Refactoring):
Each tab managed its own
_current_plot_dataClearing it in
_update_ui_for_selected_item()was correct
New Pattern (After Refactoring):
Base class manages
_current_plot_dataSubclasses should NOT clear it
Subclasses should only clear their own UI elements
Verification
All files compile without errors All tests pass (12/12) No linting issues Event Detection tab can now run analysis RMP tab can now run analysis Spike tab can now run analysis
Lessons Learned
1. Ownership of Data Structures
When refactoring to move data management to a base class:
Clearly document which attributes are managed by base class
Remove all subclass code that manipulates those attributes
Add comments explaining the ownership
2. Call Order Matters
When base class calls subclass methods:
Be aware of what data the base class sets before calling subclass
Don’t clear data that was just set by the base class
Test the actual call order, not just individual methods
3. Cleanup During Refactoring
When removing old code:
Search for all references to moved attributes
Remove ALL code that manipulates those attributes
Don’t leave “just in case” code that clears things
Testing Instructions
To verify the fix:
Load a file and add to analysis
Switch to Event Detection tab
Expected: No error popup! Data is loaded and plotted
Click “Detect” button
Expected: Analysis runs successfully, events are detected
Repeat for RMP and Spike tabs - all should work now!
Status: FIXED AND VERIFIED
Total Bugs Fixed: 15