# meas\_date datetime problem

**URL:** <https://mne.discourse.group/t/meas-date-datetime-problem/2176>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [April 30, 2020, 3:24pm UTC](https://mne.discourse.group/t/meas-date-datetime-problem/2176 "2020-04-30T15:24:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 30, 2020, 3:24pm UTC](https://mne.discourse.group/t/meas-date-datetime-problem/2176/1 "2020-04-30T15:24:17Z")

</div>

External Email - Use Caution

Hi friends,  
I have built a wrapper with mne to read and analyze data from the new Medtronic Percept implantable sensing enabled DBS device. The code is published here: [www.github.com/neuromodulation/icn\_perceive](http://www.github.com/neuromodulation/icn_perceive)\<[http://www.github.com/neuromodulation/icn\_perceive](http://www.github.com/neuromodulation/icn_perceive)\>

Unfortunately, handling correct dates is crucial for conversion into BIDS format. Everything was working fine in January. Now I have installed the code on a new machine and it creates the following issue:

raw = ephys.mne\_import\_raw(raw\_data.values.transpose() / 100000, list(raw\_data.keys()), sfreq=sfreq,  
&nbsp;&nbsp;&nbsp;...: ch\_types='seeg', meas\_date=(meas\_date.timestamp(), 0))

raw.info['meas\_date']  
Out[38]: (1580223097.0, 0)  
raw.plot()  
Traceback (most recent call last):  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\IPython\core\interactiveshell.py", line 3331, in run\_code  
&nbsp;&nbsp;&nbsp;&nbsp;exec(code\_obj, self.user\_global\_ns, self.user\_ns)  
&nbsp;&nbsp;File "\<ipython-input-39-f60196099aa7\>", line 1, in \<module\>  
&nbsp;&nbsp;&nbsp;&nbsp;raw.plot()  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\mne\io\base.py", line 1378, in plot  
&nbsp;&nbsp;&nbsp;&nbsp;show\_scalebars=show\_scalebars, verbose=verbose)  
&nbsp;&nbsp;File "\<decorator-gen-138\>", line 21, in plot\_raw  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\mne\viz\raw.py", line 336, in plot\_raw  
&nbsp;&nbsp;&nbsp;&nbsp;inds += [pick\_types(info, meg=t, ref\_meg=False, exclude=[])]  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\mne\io\pick.py", line 383, in pick\_types  
&nbsp;&nbsp;&nbsp;&nbsp;exclude = \_check\_info\_exclude(info, exclude)  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\mne\io\pick.py", line 295, in \_check\_info\_exclude  
&nbsp;&nbsp;&nbsp;&nbsp;info.\_check\_consistency()  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\mne\io\meas\_info.py", line 693, in \_check\_consistency  
&nbsp;&nbsp;&nbsp;&nbsp;% (prepend\_error, repr(self['meas\_date']),))  
RuntimeError: info["meas\_date"] must be a datetime object in UTC or None, got "'(1580223097.0, 0)'"

raw.info['meas\_date']=None  
raw.plot()  
Out[41]: \<Figure size 1600x825 with 4 Axes\>

Now if I try to use the datetime object, the following error occurs:

raw = ephys.mne\_import\_raw(raw\_data.values.transpose() / 100000, list(raw\_data.keys()), sfreq=sfreq,  
&nbsp;&nbsp;&nbsp;...: ch\_types='seeg', meas\_date=meas\_date)  
C:\Program Files\JetBrains\PyCharm Community Edition 2019.3\plugins\python-ce\helpers\pydev\_pydevd\_bundle\pydevd\_thrift.py:321: RuntimeWarning: Could not get size for self.info  
&nbsp;&nbsp;value = format % v  
raw.plot()  
Traceback (most recent call last):  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\IPython\core\interactiveshell.py", line 3331, in run\_code  
&nbsp;&nbsp;&nbsp;&nbsp;exec(code\_obj, self.user\_global\_ns, self.user\_ns)  
&nbsp;&nbsp;File "\<ipython-input-49-f60196099aa7\>", line 1, in \<module\>  
&nbsp;&nbsp;&nbsp;&nbsp;raw.plot()  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\mne\io\base.py", line 1378, in plot  
&nbsp;&nbsp;&nbsp;&nbsp;show\_scalebars=show\_scalebars, verbose=verbose)  
&nbsp;&nbsp;File "\<decorator-gen-138\>", line 21, in plot\_raw  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\mne\viz\raw.py", line 336, in plot\_raw  
&nbsp;&nbsp;&nbsp;&nbsp;inds += [pick\_types(info, meg=t, ref\_meg=False, exclude=[])]  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\mne\io\pick.py", line 383, in pick\_types  
&nbsp;&nbsp;&nbsp;&nbsp;exclude = \_check\_info\_exclude(info, exclude)  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\mne\io\pick.py", line 295, in \_check\_info\_exclude  
&nbsp;&nbsp;&nbsp;&nbsp;info.\_check\_consistency()  
&nbsp;&nbsp;File "C:\code\Miniconda3\envs\icn\lib\site-packages\mne\io\meas\_info.py", line 693, in \_check\_consistency  
&nbsp;&nbsp;&nbsp;&nbsp;% (prepend\_error, repr(self['meas\_date']),))  
RuntimeError: info["meas\_date"] must be a datetime object in UTC or None, got "'datetime.datetime(2020, 1, 28, 15, 51, 37)'"  
C:\Program Files\JetBrains\PyCharm Community Edition 2019.3\plugins\python-ce\helpers\pydev\_pydevd\_bundle\pydevd\_thrift.py:321: RuntimeWarning: Could not get size for self.info  
&nbsp;&nbsp;value = format % v

Any help is very much appreciated!

Best Julian from Berlin

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 30, 2020, 3:30pm UTC](https://mne.discourse.group/t/meas-date-datetime-problem/2176/2 "2020-04-30T15:30:17Z")

</div>

External Email - Use Caution

hi Julian,

can you make sure the meas\_date you pass as datetime object  
as a time zone defined and that it's UTC?

you use for a datetime something like tz=timezone.utc

HTH  
Alex  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20200430/2cb5368e/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200430/2cb5368e/attachment.html)
