Repository: physiopy/phys2bids

Issue:
Add test to pass a BIDS validator
<!--- Provide a general summary of the issue in the Title above -->

## Detailed Description
<!--- Provide a detailed description of the change or addition you are proposing -->
I run a BIDS validator on a dataset that I BIDSified with an older version of phys2bids. Fun fact, after a while that the validator worked out fine, now it returns an error on the (old) way to express frequencies.
I realised that we are not testing whether we make output BIDS compatible or not - I know we are, but it is risky. We should check it AT LEAST on one output.
We can use this [BIDS validator](https://github.com/bids-standard/bids-validator) and build a test that we run with the others.

Question for @vinferrer (cause I think you worked on it during HBMH2020 and you recently worked on I/O): do we always transform the sampling frequency into Hz? 

## Context / Motivation
<!--- Why is this change important to you? How would you use it? -->
<!--- How can it benefit other users? -->

Just to be sure that what we output when we want a BIDS format is 100% BIDS compatible.
Besides, if there's any change in the BIDS spec about physiological files, we need to know it and update phys2bids! 

## Possible Implementation
<!--- Not obligatory, but suggest an idea for implementing addition or change -->
<!--- If you already have worked on the idea, please share a link to the branch in your forked project -->
- Check [this repo](https://github.com/bids-standard/bids-validator) and its docker implementation
- Build a test for CircleCI or a GitHub action that, either cloning the repo or building the docker, runs phys2bids with heuristic rules on a test file and then runs the validator on the output.
- PS: It might not be python based?
- PPS: We need to understand how to return an error when we don't pass the validator
- PPPS: We might have to implement a lot of "ignore errors" and "ignore warnings" to actually pass the test
- PPPPS (and last): maybe some friends from the BIDS team and/or the BIDS validator team can help us setting this up.

Discussion:

Patch:
diff --git a/.all-contributorsrc b/.all-contributorsrc
index 3c9e275..b107af7 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -64,7 +64,8 @@
         "bug",
         "code",
         "doc",
-        "review"
+        "review",
+        "test"
       ]
     },
     {
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 75fc628..374e09a 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -202,6 +202,41 @@ jobs:
           path: /tmp/src/coverage
       - codecov/upload:
           file: /tmp/src/coverage/coverage.xml
+  
+  bids_validate:
+    docker:
+      - image: continuumio/miniconda3
+    working_directory: /tmp/src/phys2bids
+    steps:
+      - checkout
+      - restore_cache:
+          key: conda-py37-v1-{{ checksum "setup.cfg" }}
+      - run:
+          name: Generate enviroment
+          command: |
+            apt-get install -yqq curl wget tree
+            curl -sL https://deb.nodesource.com/setup_15.x | bash -
+            pip install -e ".[test]"
+            apt-get install -yqq nodejs
+            npm install -g bids-validator
+      - run:
+          name: dowload data and execute pipeline
+          command: |
+            wget -O Test1_multifreq_onescan.txt https://osf.io/7se4t/download
+            wget -O heur_test_multifreq.py https://osf.io/ehx6j/download
+            phys2bids -in Test1_multifreq_onescan.txt -chtrig 1 -ntp 30 -tr 1.2 -outdir physio_bids -heur heur_test_multifreq.py -sub 006 -ses 01
+      - run:
+          name: run_validator
+          command: |
+            wget -O sub-006_ses-01_task-test_rec-biopac_run-01_bold.json https://osf.io/6j8f7/download
+            wget -O sub-006_ses-01_task-test_rec-biopac_run-01_bold.nii.gz https://osf.io/wus2p/download
+            mv sub-006_ses-01_task-test_rec-biopac_run-01_bold* physio_bids/sub-006/ses-01/func
+            tree physio_bids
+            bids-validator  physio_bids          
+      - persist_to_workspace:
+          root: /tmp
+          paths:
+              - src/phys2bids
 
 workflows:
   version: 2.1
@@ -209,6 +244,7 @@ workflows:
     jobs:
       - makeenv_37
       - unittest_36
+      - bids_validate
       - unittest_37:
           requires:
             - makeenv_37
diff --git a/README.md b/README.md
index 9dd5962..08e2e81 100644
--- a/README.md
+++ b/README.md
@@ -76,8 +76,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
     <td align="center"><a href="https://github.com/CesarCaballeroGaudes"><img src="https://avatars1.githubusercontent.com/u/7611340?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Cesar Caballero Gaudes</b></sub></a><br /><a href="#content-CesarCaballeroGaudes" title="Content">🖋</a> <a href="#data-CesarCaballeroGaudes" title="Data">🔣</a> <a href="#ideas-CesarCaballeroGaudes" title="Ideas, Planning, & Feedback">🤔</a></td>
   </tr>
   <tr>
-    <td align="center"><a href="https://github.com/vinferrer"><img src="https://avatars2.githubusercontent.com/u/38909338?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vicente Ferrer</b></sub></a><br /><a href="https://github.com/physiopy/phys2bids/issues?q=author%3Avinferrer" title="Bug reports">🐛</a> <a href="https://github.com/physiopy/phys2bids/commits?author=vinferrer" title="Code">💻</a> <a href="https://github.com/physiopy/phys2bids/commits?author=vinferrer" title="Documentation">📖</a> <a href="https://github.com/physiopy/phys2bids/pulls?q=is%3Apr+reviewed-by%3Avinferrer" title="Reviewed Pull Requests">👀</a></td>
-    <td align="center"><a href="http://soichi.us"><img src="https://avatars3.githubusercontent.com/u/923896?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Soichi Hayashi</b></sub></a><br /><a href="https://github.com/physiopy/phys2bids/issues?q=author%3Asoichih" title="Bug reports">🐛</a></td>
+    <td align="center"><a href="https://github.com/vinferrer"><img src="https://avatars2.githubusercontent.com/u/38909338?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vicente Ferrer</b></sub></a><br /><a href="https://github.com/physiopy/phys2bids/issues?q=author%3Avinferrer" title="Bug reports">🐛</a> <a href="https://github.com/physiopy/phys2bids/commits?author=vinferrer" title="Code">💻</a> <a href="https://github.com/physiopy/phys2bids/commits?author=vinferrer" title="Documentation">📖</a> <a href="https://github.com/physiopy/phys2bids/pulls?q=is%3Apr+reviewed-by%3Avinferrer" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/physiopy/phys2bids/commits?author=vinferrer" title="Tests">⚠️</a></td>
+    <td align="center"><a href="http://soichi.us"><img src="https://avatars3.githubusercontent.com/u/923896?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Soichi Hayashi</b></sub></a><br /><a href="https://github.com/physiopy/phys2bids/issues?q=author%3Asoichih" title="Bug reports">🐛</a> </td>
     <td align="center"><a href="https://github.com/sangfrois"><img src="https://avatars0.githubusercontent.com/u/38385719?v=4?s=100" width="100px;" alt=""/><br /><sub><b>François Lespinasse</b></sub></a><br /><a href="https://github.com/physiopy/phys2bids/commits?author=sangfrois" title="Code">💻</a> <a href="https://github.com/physiopy/phys2bids/commits?author=sangfrois" title="Tests">⚠️</a></td>
     <td align="center"><a href="http://rossmarkello.com"><img src="https://avatars0.githubusercontent.com/u/14265705?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ross Markello</b></sub></a><br /><a href="https://github.com/physiopy/phys2bids/issues?q=author%3Armarkello" title="Bug reports">🐛</a> <a href="https://github.com/physiopy/phys2bids/commits?author=rmarkello" title="Code">💻</a> <a href="#content-rmarkello" title="Content">🖋</a> <a href="#ideas-rmarkello" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-rmarkello" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/physiopy/phys2bids/pulls?q=is%3Apr+reviewed-by%3Armarkello" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/physiopy/phys2bids/commits?author=rmarkello" title="Tests">⚠️</a></td>
   </tr>
diff --git a/phys2bids/bids.py b/phys2bids/bids.py
index f0136e1..ccaa8d3 100644
--- a/phys2bids/bids.py
+++ b/phys2bids/bids.py
@@ -284,7 +284,7 @@ def readme_file(outdir):
         Full path to the output directory.
 
     """
-    file_path = os.path.join(outdir, 'README.md')
+    file_path = os.path.join(outdir, 'README')
     if not os.path.exists(file_path):
         text = 'Empty README, please fill in describing the dataset in more detail.'
         LGR.warning('phys2bids could not find README,'


Test patch:
diff --git a/phys2bids/tests/test_bids.py b/phys2bids/tests/test_bids.py
index 6c062ee..c6f3c8f 100644
--- a/phys2bids/tests/test_bids.py
+++ b/phys2bids/tests/test_bids.py
@@ -65,8 +65,8 @@ def test_use_heuristic(tmpdir, test_sub, test_ses):
 @pytest.mark.parametrize('outdir', '.')
 def test_README_file(outdir):
     bids.readme_file(outdir)
-    assert os.path.join(outdir, "README.md")
-    os.remove(os.path.join(outdir, "README.md"))
+    assert os.path.join(outdir, "README")
+    os.remove(os.path.join(outdir, "README"))
 
 
 @pytest.mark.parametrize('outdir', '.')