Repository navigation
Closed
Labels
Description
Description of the problem
Birthday can be set as a pd.Timestamp object but will throw an error when saving to FIFF.
Steps to reproduce
import mne
import numpy as np
import pandas as pd
info = mne.create_info(ch_names=["F7-F8"], sfreq=1000, ch_types='eeg')
info['subject_info'] = {'birthday': pd.Timestamp('1990-01-01'),}
raw = mne.io.RawArray(np.array([[1, 2, 3]]), info)
raw.save('test-raw.fif', overwrite=True)Link to data
No response
Expected results
Either:
Birthday input gets converted to date and user is able to save raw.fiff file
or:
TypeError when assigning birthday in a non datetime.date object.
Actual results
TypeError caused by conversion to julian date when attempting to save fiff file.
Additional information
Platform Windows-10-10.0.19045-SP0
Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
Executable c:\Users\Laurent\AppData\Local\Programs\Python\Python311\python.exe
CPU Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (8 cores)
Memory 15.9 GiB
Core
- mne 1.9.0 (latest release)
- numpy 2.2.6 (OpenBLAS 0.3.29 with 8 threads)
- scipy 1.15.3
- matplotlib 3.10.3 (backend=module://matplotlib_inline.backend_inline)
Numerical (optional)
- sklearn 1.5.0
- nibabel 5.3.2
- pandas 2.2.3
- h5py 3.11.0
- unavailable numba, nilearn, dipy, openmeeg, cupy, h5io
Visualization (optional)
- pyvista 0.45.0 (OpenGL 4.5.0 NVIDIA 560.94 via NVIDIA GeForce GTX 960/PCIe/SSE2)
- pyvistaqt 0.11.2
- vtk 9.4.2
- qtpy 2.4.1 (PyQt5=5.15.2)
- pyqtgraph 0.13.7
- ipywidgets 8.1.3
- unavailable ipympl, mne-qt-browser, trame_client, trame_server, trame_vtk, trame_vuetify
Ecosystem (optional)
- edfio 0.4.8
- unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo, eeglabio, mffpy, pybv
Activity
welcome commentedon Jun 6, 2025
Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴
drammock commentedon Jun 9, 2025
I think we should detect if it's
pd.Timestampand if so call its.date()method to convert to standarddatetime.date. Ideally do it usinghasattrso we can avoid importing pandas just for anisinstancecheck. @LaurentLM are you up for making a PR to fix it?LaurentLM commentedon Jun 10, 2025
No problem, I wasn't sure if this had deeper implications in the way date inputs are checked, or if there was a more elegant way to address edge cases like that.
I wrote a custom
_check_bdayfunction that solves this, will create a PR.