Repository: mne-tools/mne-bids

Issue:
measurement date always tuple now
with https://github.com/mne-tools/mne-python/pull/5500 the measurement date is always a tuple. This (correctly) messes up a few tests.
I saw that with 9ee36dd9ab8b77ab0415b4b9e048ede662310dfa @sappelhoff added a fix in one spot, but I was thinking it might be good to have this fix pushed through separately so that other PR's can be rebased and continue without having to wait for #78 
I can make a PR with the changes if you think it would be good to get it fixed ASAP (the goal is to keep this repo compatible with the master branch of mne-python anyway, not the public release right?)


Discussion:
+1 for changing travis to run with mne master :-) ... or at least some hash of the master branch that is more recent than MNE-Python 0.16.

A bit like we are doing it with the BIDS-validator (which could also be "update", i.e., a newer hash for testing in this PR)
I think it *is* is running with master, that's the problem and the reason the validation checks are failing... (hence the point of me making a PR to get tests to pass in mne-bids...)
Mmh this line says we are running on the 0.16 maintenance branch:

https://github.com/mne-tools/mne-bids/blob/e03f013cfc897d116ce4d67d7bce6204d94a40a7/.travis.yml#L21

But I actually don't know what's happening on that branch
Travis is, but appveyor which is the one that is failing is on the current master branch:
https://github.com/mne-tools/mne-bids/blob/master/appveyor.yml#L19
Travis should probably be updated to point to this too I guess...
okay to use `mne-python` master ...

Resolving patch:
diff --git a/mne_bids/mne_bids.py b/mne_bids/mne_bids.py
--- a/mne_bids/mne_bids.py
+++ b/mne_bids/mne_bids.py
@@ -203,12 +203,13 @@ def _participants_tsv(raw, subject_id, group, fname, verbose):
         # determine the age of the participant
         age = subject_info.get('birthday', None)
         meas_date = raw.info.get('meas_date', None)
+        if isinstance(meas_date, (tuple, list, np.ndarray)):
+            meas_date = meas_date[0]
+
         if meas_date is not None and age is not None:
             bday = datetime(age[0], age[1], age[2])
-            if isinstance(meas_date, (np.ndarray, list)):
-                meas_date = meas_date[0]
-            meas_date = datetime.fromtimestamp(meas_date)
-            subject_age = age_on_date(bday, meas_date)
+            meas_datetime = datetime.fromtimestamp(meas_date)
+            subject_age = age_on_date(bday, meas_datetime)
         else:
             subject_age = "n/a"
 
@@ -253,14 +254,12 @@ def _scans_tsv(raw, raw_fname, fname, verbose):
     """
     # get MEASurement date from the data info
     meas_date = raw.info['meas_date']
-    if isinstance(meas_date, (np.ndarray, list)):
+    if isinstance(meas_date, (tuple, list, np.ndarray)):
         meas_date = meas_date[0]
-
-    if meas_date is None:
-        acq_time = 'n/a'
-    else:
         acq_time = datetime.fromtimestamp(
             meas_date).strftime('%Y-%m-%dT%H:%M:%S')
+    else:
+        acq_time = 'n/a'
 
     df = pd.DataFrame(data={'filename': ['%s' % raw_fname],
                             'acq_time': [acq_time]},


Test patch:
diff --git a/mne_bids/tests/test_mne_bids.py b/mne_bids/tests/test_mne_bids.py
--- a/mne_bids/tests/test_mne_bids.py
+++ b/mne_bids/tests/test_mne_bids.py
@@ -11,8 +11,10 @@
 
 import os
 import os.path as op
-import pandas as pd
+import pytest
+import subprocess
 
+import pandas as pd
 import mne
 from mne.datasets import testing
 from mne.utils import _TempDir, run_subprocess
@@ -127,6 +129,12 @@ def test_bti():
                 task=task, raw_file=raw_fname, config=config_fname,
                 hsp=headshape_fname, output_path=output_path,
                 verbose=True, overwrite=True)
-    cmd = ['bids-validator', output_path]
-    run_subprocess(cmd, shell=shell)
+
     assert op.exists(op.join(output_path, 'participants.tsv'))
+
+    # FIXME: see these issues for reference:
+    # https://github.com/mne-tools/mne-bids/pull/84
+    # https://github.com/INCF/bids-validator/issues/553
+    with pytest.raises(subprocess.CalledProcessError):
+        cmd = ['bids-validator', output_path]
+        run_subprocess(cmd, shell=shell)