Skip to content

Conversation

@SveaMeyer13
Copy link
Contributor

Reference issue

WIth regards to #7124 .

What does this implement/fix?

While importing a GDF 2.x file with

from mne import io
io.read_raw_gdf(fname, preload=True)

we encountered the following error:

Extracting EDF parameters from /home/svea/Desktop/mne_examples/sample_data/B0103T.gdf...
GDF file detected
Traceback (most recent call last):
  File "/home/svea/Desktop/mne_examples/online_linear_demo.py", line 17, in <module>
    raw = io.read_raw_gdf(raw_fname, preload=True)
  File "/home/svea/Desktop/mne_examples/venv/lib/python3.7/site-packages/mne/io/edf/edf.py", line 1327, in read_raw_gdf
    verbose=verbose)
  File "<decorator-gen-164>", line 21, in __init__
  File "/home/svea/Desktop/mne_examples/venv/lib/python3.7/site-packages/mne/io/edf/edf.py", line 189, in __init__
    exclude, preload)
  File "/home/svea/Desktop/mne_examples/venv/lib/python3.7/site-packages/mne/io/edf/edf.py", line 377, in _get_info
    edf_info, orig_units = _read_header(fname, exclude)
  File "/home/svea/Desktop/mne_examples/venv/lib/python3.7/site-packages/mne/io/edf/edf.py", line 366, in _read_header
    return _read_gdf_header(fname, exclude), None
  File "/home/svea/Desktop/mne_examples/venv/lib/python3.7/site-packages/mne/io/edf/edf.py", line 865, in _read_gdf_header
    today = datetime.today(tzinfo=timezone.utc)
TypeError: today() takes no keyword arguments

After closer investigation, we suspect that it was caused by the changes introduced by #7124 and released in v0.20.0.

As stated in the Python docs for datetime,
datetime.now(tz=timezone.utc) should be the syntactically correct functional equivalent.

To then make today and patient['birthday'] comparable, we add tzinfo to birthday (in line 860).

@codecov
Copy link

codecov bot commented Apr 8, 2020

Codecov Report

Merging #7581 into master will decrease coverage by 0.08%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #7581      +/-   ##
==========================================
- Coverage   90.20%   90.12%   -0.09%     
==========================================
  Files         452      452              
  Lines       82104    82941     +837     
  Branches    13109    13110       +1     
==========================================
+ Hits        74064    74752     +688     
- Misses       5206     5356     +150     
+ Partials     2834     2833       -1     

@cbrnr
Copy link
Contributor

cbrnr commented Apr 8, 2020

#7582 duplicate?

@larsoner
Copy link
Member

larsoner commented Apr 8, 2020

Indeed, @SveaMeyer13 can you see if #7582 also works? I slightly prefer that one since it includes a test

@larsoner
Copy link
Member

larsoner commented Apr 9, 2020

@SveaMeyer13 actually, instead can you update latest.inc with an update about the bugfix (you can take the wording from my PR if you want -- plus change to your name and add yourself to names.inc if not there already) and we can merge this, then I can rebase my PR to get the test in

@larsoner larsoner mentioned this pull request Apr 9, 2020
@larsoner larsoner added the backport-candidate on-merge: backport to maint/1.11 label Apr 9, 2020
@SveaMeyer13
Copy link
Contributor Author

Done!

.. _Ramiro Gatti: https://github.com/ragatti No newline at end of file
.. _Ramiro Gatti: https://github.com/ragatti

.. _Svea Marie Meyer: https://github.com/SveaMeyer13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name here and above need to match, it's what CircleCI complains about (search "warning" in the log and you'll see it)

https://app.circleci.com/pipelines/github/mne-tools/mne-python/897/workflows/179f9067-911b-4472-b7eb-20702ffa91f8/jobs/19252

And the broken link is visible here

https://19252-1301584-gh.circle-artifacts.com/0/dev/whats_new.html

@larsoner larsoner changed the title FIX: Datetime call in gdf 2.x age calculation MRG, FIX: Datetime call in gdf 2.x age calculation Apr 9, 2020
@larsoner larsoner merged commit 8801dcb into mne-tools:master Apr 9, 2020
@larsoner
Copy link
Member

larsoner commented Apr 9, 2020

Thanks @SveaMeyer13 !

@larsoner larsoner added backported and removed backport-candidate on-merge: backport to maint/1.11 labels Apr 9, 2020
larsoner pushed a commit that referenced this pull request Apr 9, 2020
* FIX: Datetime call in gdf 2.x age calculation

* DOC: Update latest and names
larsoner added a commit to larsoner/mne-python that referenced this pull request Apr 10, 2020
* upstream/master: (1522 commits)
  FIX: Show bug
  MRG, FIX: Datetime call in gdf 2.x age calculation (mne-tools#7581)
  DOC: Simplify Darwin installation (mne-tools#7584)
  MRG, ENH: Allow picking without preload (mne-tools#7507)
  DOC: Document anonymization better (mne-tools#7587)
  Rework _Brain show (mne-tools#7580)
  DOC: Fixes in tutorial (mne-tools#7579)
  ENH: muscle artifact detection (mne-tools#7407)
  MRG: Remove toolbars in PyVista plotter (mne-tools#7572)
  WIP: Deregister plotter from the figure list in close() (mne-tools#7573)
  MRG: Fix mouse wheel event in _TimeViewer (mne-tools#7563)
  FIX: Fix toggle all (mne-tools#7567)
  MRG, FIX: parallel n_jobs check (mne-tools#7566)
  Rename artifact detection to movement detection (mne-tools#7569)
  ENH: Update spelling check [ci skip] (mne-tools#7565)
  MRG, ENH: Dont require preload for raw resample (mne-tools#7508)
  MRG: Add interpolation for NIRS signals (mne-tools#7428)
  WIP: Add temporal derivative distribution repair algorithm (mne-tools#7556)
  DOC: fix link in docstr [skip ci] (mne-tools#7562)
  ENH: Custom figure title when plotting Dipole locations (mne-tools#7558)
  ...
larsoner added a commit to larsoner/mne-python that referenced this pull request Apr 25, 2023
* upstream/master: (1522 commits)
  FIX: Show bug
  MRG, FIX: Datetime call in gdf 2.x age calculation (mne-tools#7581)
  DOC: Simplify Darwin installation (mne-tools#7584)
  MRG, ENH: Allow picking without preload (mne-tools#7507)
  DOC: Document anonymization better (mne-tools#7587)
  Rework _Brain show (mne-tools#7580)
  DOC: Fixes in tutorial (mne-tools#7579)
  ENH: muscle artifact detection (mne-tools#7407)
  MRG: Remove toolbars in PyVista plotter (mne-tools#7572)
  WIP: Deregister plotter from the figure list in close() (mne-tools#7573)
  MRG: Fix mouse wheel event in _TimeViewer (mne-tools#7563)
  FIX: Fix toggle all (mne-tools#7567)
  MRG, FIX: parallel n_jobs check (mne-tools#7566)
  Rename artifact detection to movement detection (mne-tools#7569)
  ENH: Update spelling check [ci skip] (mne-tools#7565)
  MRG, ENH: Dont require preload for raw resample (mne-tools#7508)
  MRG: Add interpolation for NIRS signals (mne-tools#7428)
  WIP: Add temporal derivative distribution repair algorithm (mne-tools#7556)
  DOC: fix link in docstr [skip ci] (mne-tools#7562)
  ENH: Custom figure title when plotting Dipole locations (mne-tools#7558)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants