Skip to content

Commit 3e2cf59

Browse files
cbrnrCopilot
andcommitted
Fix toggle time format if meas_date is None
Co-authored-by: Copilot <copilot@github.com>
1 parent ec7683f commit 3e2cf59

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

mne/viz/_mpl_figure.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,8 @@ def _xtick_formatter(self, x, pos=None, ax_type="main"):
20282028
return str(round(x, digits))
20292029
# format as timestamp
20302030
meas_date = self.mne.inst.info["meas_date"]
2031+
if meas_date is None:
2032+
return str(round(x, digits))
20312033
first_time = datetime.timedelta(seconds=self.mne.inst.first_time)
20322034
xtime = datetime.timedelta(seconds=x)
20332035
xdatetime = meas_date + first_time + xtime
@@ -2038,6 +2040,8 @@ def _xtick_formatter(self, x, pos=None, ax_type="main"):
20382040

20392041
def _toggle_time_format(self):
20402042
if self.mne.time_format == "float":
2043+
if self.mne.inst.info["meas_date"] is None:
2044+
return # can't show clock time without a measurement date
20412045
self.mne.time_format = "clock"
20422046
x_axis_label = "Time (HH:MM:SS)"
20432047
else:

0 commit comments

Comments
 (0)