Skip to content

Commit

Permalink
works when change physical units
Browse files Browse the repository at this point in the history
  • Loading branch information
nmarkowitz committed Jul 24, 2024
1 parent fbff9d6 commit 76a1456
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions mne_qt_browser/_pg_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1868,8 +1868,10 @@ def __init__(self, main, title="Settings", **kwargs):
# Create dropdown to choose units
self.physical_units_cmbx = QComboBox()
self.physical_units_cmbx.addItems(["/ mm", "/ cm", "/ inch"])
self.physical_units_cmbx.currentIndexChanged.connect(
self._update_sensitivity_spinbox_values
self.physical_units_cmbx.currentTextChanged.connect(
_methpartial(
self._update_spinbox_values, ch_type="all", source="unit_change"
)
)
current_units = self.physical_units_cmbx.currentText().split()[-1]

Expand Down Expand Up @@ -2005,6 +2007,18 @@ def _update_spinbox_values(self, *args, **kwargs):
)
self.ch_scaling_spinboxes[ch_type].blockSignals(False)

self.mne.scalebar_texts[ch_type].update_value()

elif source == "unit_change":
new_unit = new_value.split()[-1]
ch_types = self.ch_scaling_spinboxes.keys()
for ch_type in ch_types:
self.ch_sensitivity_spinboxes[ch_type].blockSignals(True)
self.ch_sensitivity_spinboxes[ch_type].setValue(
_calc_chan_type_to_physical(self, ch_type, units=new_unit)
)
self.ch_sensitivity_spinboxes[ch_type].blockSignals(False)

else:
raise ValueError(
f"Unknown source: {source}. "
Expand Down

0 comments on commit 76a1456

Please sign in to comment.