Skip to content

Commit

Permalink
transfer tests from pybids
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau authored and effigies committed Aug 14, 2024
1 parent 9acd81f commit ab40030
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions src/bids_validator/test_bids_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ def test_datasets(validator, fname):
('/T1w.json', True),
('/dataset_description.json', True),
('/README', True),
('/README.md', True),
('/README.rst', True),
('/CHANGES', True),
('/participants.tsv', True),
('/participants.json', True),
('/sub-01/anat/sub-01_T1w.nii.gz', False),
('/RADME', False), # typo
('/CANGES', False), # typo
],
)
def test_top_level(validator, fname, matches):
Expand All @@ -78,12 +83,21 @@ def test_top_level(validator, fname, matches):
@pytest.mark.parametrize(
('fname', 'matches'),
[
('/code/', True),
('/derivatives/', True),
('/sourcedata/', True),
('/stimuli/', True),
('/sourcedata/unstructured_data.nii.gz', True),
('/sourcedata/dicom_dir/xyz.dcm', True),
('/code/my_analysis/analysis.py', True),
('/derivatives/preproc/sub-01/anat/sub-01_desc-preproc_T1w.nii.gz', True),
('/stimuli/pic.jpg', True),
('/sub-01/anat/sub-01_T1w.nii.gz', False),
('/CODE/', False),
('/derivatves/', False),
('/source/', False),
('/stimli/', False),
('/.git/', False),
],
)
def test_associated_data(validator, fname, matches):
Expand Down Expand Up @@ -118,13 +132,64 @@ def test_associated_data(validator, fname, matches):
('/sub-01/sub-01_TEM.json', True),
('/sub-01/ses-1/sub-01_ses-1_nirs.json', True),
('/sub-01/sub-01_nirs.json', True),
('/sub-01/sub-01_dwi.bval', True),
('/sub-01/sub-01_dwi.bvec', True),
('/sub-01/sub-01_dwi.json', True),
('/sub-01/sub-01_run-01_dwi.bval', True),
('/sub-01/sub-01_run-01_dwi.bvec', True),
('/sub-01/sub-01_run-01_dwi.json', True),
('/sub-01/sub-01_acq-singleband_dwi.bval', True),
('/sub-01/sub-01_acq-singleband_dwi.bvec', True),
('/sub-01/sub-01_acq-singleband_dwi.json', True),
('/sub-01/sub-01_acq-singleband_run-01_dwi.bval', True),
('/sub-01/sub-01_acq-singleband_run-01_dwi.bvec', True),
('/sub-01/sub-01_acq-singleband_run-01_dwi.json', True),
('/sub-01/ses-test/sub-01_ses-test_dwi.bval', True),
('/sub-01/ses-test/sub-01_ses-test_dwi.bvec', True),
('/sub-01/ses-test/sub-01_ses-test_dwi.json', True),
('/sub-01/ses-test/sub-01_ses-test_run-01_dwi.bval', True),
('/sub-01/ses-test/sub-01_ses-test_run-01_dwi.bvec', True),
('/sub-01/ses-test/sub-01_ses-test_run-01_dwi.json', True),
('/sub-01/ses-test/sub-01_ses-test_acq-singleband_dwi.bval', True),
('/sub-01/ses-test/sub-01_ses-test_acq-singleband_dwi.bvec', True),
('/sub-01/ses-test/sub-01_ses-test_acq-singleband_dwi.json', True),
('/sub-01/ses-test/sub-01_ses-test_acq-singleband_run-01_dwi.bval', True),
('/sub-01/ses-test/sub-01_ses-test_acq-singleband_run-01_dwi.bvec', True),
('/sub-01/ses-test/sub-01_ses-test_acq-singleband_run-01_dwi.json', True),
# Mismatch sessions
('/sub-01/sub-01_ses-1_scans.tsv', False),
('/sub-01/sub-01_ses-1_scans.json', False),
('/sub-01/ses-1/sub-01_ses-2_scans.tsv', False),
# File-level
('/sub-01/ses-1/func/sub-01_ses-1_task-rest_bold.nii.gz', False),
('/sub-01/anat/sub-01_T1w.nii.gz', False),
('/sub-01/01_dwi.bvec', False), # missed subject suffix
('/sub-01/sub_dwi.json', False), # missed subject id
('/sub-01/sub-01_23_run-01_dwi.bval', False), # wrong _23_
('/sub-01/sub-01_run-01_dwi.vec', False), # wrong extension
('/sub-01/sub-01_run-01_dwi.jsn', False), # wrong extension
('/sub-01/sub-01_acq_dwi.bval', False), # missed suffix value
('/sub-01/sub-01_acq-23-singleband_dwi.bvec', False), # redundant -23-
('/sub-01/anat/sub-01_acq-singleband_dwi.json', False), # redundant /anat/
(
'/sub-01/sub-01_recrod-record_acq-singleband_run-01_dwi.bval',
False,
), # redundant record-record_
('/sub_01/sub-01_acq-singleband_run-01_dwi.bvec', False), # wrong /sub_01/
('/sub-01/sub-01_acq-singleband__run-01_dwi.json', False), # wrong __
('/sub-01/ses-test/sub-01_ses_test_dwi.bval', False), # wrong ses_test
('/sub-01/ses-test/sb-01_ses-test_dwi.bvec', False), # wrong sb-01
('/sub-01/ses-test/sub-01_ses-test_dw.json', False), # wrong modality
('/sub-01/ses-test/sub-01_ses-test_run-01_dwi.val', False), # wrong extension
('/sub-01/ses-test/sub-01_ses-test_acq-singleband.bval', False), # missed modality
('/sub-01/ses-test/sub-01_ses-test_acq-singleband_dwi', False), # missed extension
('/ses-test/sub-01/sub-01_ses-test_acq-singleband_dwi.json', False), # wrong dirs order
(
'/sub-01/ses-test/sub-02_ses-test_acq-singleband_run-01_dwi.bval',
False,
), # wrong sub id in the filename
('/sub-01/sub-01_ses-test_acq-singleband_run-01_dwi.bvec', False), # ses dir missed
('/ses-test/sub-01_ses-test_acq-singleband_run-01_dwi.json', False), # sub id dir missed
],
)
def test_session_level(validator, fname, matches):
Expand All @@ -138,6 +203,11 @@ def test_session_level(validator, fname, matches):
('/sub-01/sub-01_sessions.tsv', True),
('/sub-01/sub-01_sessions.json', True),
('/sub-01/anat/sub-01_T1w.nii.gz', False),
('/sub-02/sub-01_sessions.tsv', False), # wrong sub id in the filename
('/sub-01_sessions.tsv', False), # missed subject id dir
('/sub-01/sub-01_sesions.tsv', False), # wrong modality
('/sub-01/sub-01_sesions.ext', False), # wrong extension
('/sub-01/sub-01_sessions.jon', False), # wrong extension
],
)
def test_subject_level(validator, fname, matches):
Expand All @@ -151,6 +221,9 @@ def test_subject_level(validator, fname, matches):
('/phenotype/measure.tsv', True),
('/phenotype/measure.json', True),
('/sub-01/anat/sub-01_T1w.nii.gz', False),
('/measurement_tool_name.tsv', False), # missed phenotype dir
('/phentype/measurement_tool_name.josn', False), # wrong phenotype dir
('/phenotype/measurement_tool_name.jsn', False), # wrong extension
],
)
def test_phenotpic(validator, fname, matches):
Expand Down

0 comments on commit ab40030

Please sign in to comment.