Skip to content

Commit

Permalink
transfer false tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Aug 15, 2024
1 parent df967fc commit ea53778
Showing 1 changed file with 254 additions and 0 deletions.
254 changes: 254 additions & 0 deletions src/bids_validator/test_bids_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,257 @@ def test_is_file(validator, fname):
"""Test that is_file returns true for file level files."""
assert validator.is_bids(fname)
assert validator.is_file(fname)


@pytest.mark.parametrize(
('fname'),
[
'/sub-01/anat/sub-1_T1w.json', # subject inconsistency
'/sub-01/anat/sub-01_dwi.nii.gz', # wrong modality suffix
'/sub-01/anat/sub-02_rec-CSD_T1w.json', # subject inconsistency
'/sub-01/anat/sub-01_rec-CS-D_T1w.nii.gz', # rec label wrong
'/sub-01/anat/sub-01_acq-23_T1W.json', # modality suffix wrong
'/sub-01/dwi/sub-01_acq-23_dwi.nii.gz', # wrong data type
'/sub-01/anat/sub-01_acq-23_rec-CSD_T1w.exe', # wrong extension
'/sub-01/anat/sub-01_acq-23_rec-CSD_T1w.niigz', # extension typo
'/sub-01/anat/sub-01_run-2-3_T1w.json', # run label typo
'/sub-01/anat/sub-01_rn-23_T1w.nii.gz', # run typo
# reconstruction label typo
'/sub-01/ant/sub-01_rec-CS-D_run-23_T1w.json',
'/sub-1/anat/sub-01_rec-CSD_run-23_t1w.nii.gz', # T1w suffix typo
'/sub-01/anat/sub-01_aq-23_run-23_T1w.json', # acq typo
'/sub-01/anat/sub-01_acq-23_run-23_dwi.nii.gz', # wrong data type
'/sub-01/anat/sub-01_acq-23_rc-CSD_run-23_T1w.json', # rec typo
# 2nd subject id typo
'/sub-01/anat/sub-O1_acq-23_rec-CSD_run-23_T1w.nii.gz',
# ses inconsistency
'/sub-01/ses-test/anat/sub-01_ses-retest_T1w.json',
# 2nd session typo
'/sub-01/ses-test/anat/sub-01_sestest_T1w.nii.gz',
# extension typo
'/sub-01/ses-test/anat/sub-01_ses_test_rec-CSD_dwi.jsn',
# wrong extension
'/sub-01/ses_test/anat/sub-01_ses_test_rec-CSD_T1w.bval',
# wrong extension
'/sub-01/ses-test/anat/sub-01_ses-test_acq-23_T1w.exe',
],
)
def test_is_anat_false(validator, fname):
"""Test that is_bids returns False for invalid anat files."""
assert not validator.is_bids(fname)


@pytest.mark.parametrize(
('fname'),
[
# redundant suffix
'/sub-01/dwi/sub-01_suffix-suff_acq-singleband_dwi.json',
'/sub-01/dwi/sub-01_acq-singleband__run-01_dwi.nii.gz', # wrong __
'/sub-01/dwi/sub-01_acq_run-01_dwi.bval', # missed -singleband in _acq
'/sub-01/dwi/sub-01_acq-singleband_run_01_dwi.bvec', # wrong run_01
# wrong acq_singleband_
'/sub-01/dwi/sub-01_acq_singleband_run-01_dwi.json',
'/sub_01/ses-test/dwi/sub-01_ses-test_dwi.nii.gz', # wrong sub_01 dir
'/sub-01/ses_test/dwi/sub-01_ses-test_dwi.bval', # wrong ses_test dir
# wrong session in the filename
'/sub-01/ses-retest/dwi/sub-01_ses-test_dwi.bvec',
# wrong session in the filename
'/sub-01/ses-test/dwi/sub-01_ses-retest_dwi.json',
# wrong modality
'/sub-01/ses-test/dwi/sub-01_ses-test_run-01_brain.nii.gz',
'/sub-01/ses-test/dwi/sub-01_ses-test_run-01.bval', # missed modality
# wrong extension
'/sub-01/ses-test/dwi/sub-01_ses-test_run-01_dwi.vec',
'/sub-01/ses-test/dwi/sub-01_ses-test_run-01_dwi.jon',
'/sub-01/ses-test/dwi/sub-01_ses-test_acq-singleband_dwi.ni.gz',
'/sub-01/ses-test/dwi/sub-01_ses-test_acq-singleband_dwi.val',
# wrong dirs order
'/ses-test/dwi/sub-01/sub-01_ses-test_acq-singleband_dwi.bvec',
'/sub-01/dwi/ses-test/sub-01_ses-test_acq-singleband_dwi.json',
# wrong dirs order
'/ses-test/sub-01/dwi/sub-01_ses-test_acq-singleband_run-01_dwi.nii.gz',
# missed data type dir
'/sub-01/ses-test/sub-01_ses-test_acq-singleband_run-01_dwi.bval',
# missed session id dir
'/sub-01/dwi/sub-01_ses-test_acq-singleband_run-01_dwi.bvec',
# missed sub id dir
'/ses-test/dwi/sub-01_ses-test_acq-singleband_run-01_dwi.json',
],
)
def test_is_dwi_false(validator, fname):
"""Test that is_bids returns False for invalid dwi files."""
assert not validator.is_bids(fname)


@pytest.mark.parametrize(
('fname'),
[
'/sub-01/ses-test/func/sub--01_ses-test_task-task_rec-rec_stim.tsv.gz', # wrong --
'/sub-01/ses-test/func/sub-01__ses-test_task-task_rec-rec_defacemask.nii.gz', # wrong __
'/sub-01/ses-test/func/sub-01_ses_test_task-task_rec-rec_defacemask.nii', # wrong ses_test
# missed session suffix and id in the filename
'/sub-01/ses-test/func/sub-01_task-task_rec-rec_run-01_bold.nii.gz',
# missed subject suffix and id in the filename
'/sub-01/ses-test/func/ses-test_task-task_rec-rec_run-01_bold.nii',
# wrong session id in the filename
'/sub-01/ses-retest/func/sub-01_ses-test_task-task_rec-rec_run-01_sbref.nii.gz',
# wrong subject id in the filename
'/sub-01/ses-test/func/sub-02_ses-test_task-task_rec-rec_run-01_sbref.json',
'/sub-01/ses-test/func/sub-01_ses-test_task-task_rec-rec_run-01.json', # missed modality
# missed extension
'/sub-01/ses-test/func/sub-01_ses-test_task-task_rec-rec_run-01_events',
# wrong dirs order
'/sub-01/func/ses-test/sub-01_ses-test_task-task_rec-rec_run-01_physio.json',
# wrong dirs order
'/ses-test/func/sub-01/sub-01_ses-test_task-task_rec-rec_run-01_physio.tsv.gz',
# wrong dirs order
'/ses-test/sub-01/func/sub-01_ses-test_task-task_rec-rec_run-01_stim.json',
# missed data type
'/sub-01/ses-test/sub-01_ses-test_task-task_rec-rec_run-01_stim.tsv.gz',
# missed session dir
'/sub-01/func/sub-01_ses-test_task-task_rec-rec_run-01_defacemask.nii.gz',
# missed subject dir
'/ses-test/func/sub-01_ses-test_task-task_rec-rec_run-01_defacemask.nii',
],
)
def test_is_func_false(validator, fname):
"""Test that is_bids returns False for invalid dwi files."""
assert not validator.is_bids(fname)


@pytest.mark.parametrize(
('fname'),
[
# func not bold
'/sub-01/ses-test/func/sub-01_ses-test_task-coding_acq-23_events.tsv',
'/sub-01/func/sub-01_task-coding_events.json',
'/sub-01/func/sub-01_task-coding_acq-23_run-23_events.json',
'/sub-01/ses-test/func/sub-01_ses-test_task-coding_bold.json',
'/sub-01/func/sub-01_task-coding_acq-23_run-23_bold.json',
'/sub-01/ses-test/func/sub-01_ses-test_task-coding_physio.json',
'/sub-01/ses-test/func/sub-01_ses-test_task-coding_acq-23_run-23_physio.json',
'/sub-01/func/sub-01_task-coding_run-23_events.tsv',
'/sub-01/func/sub-01_task-coding_events.tsv',
'/sub-01/func/sub-01_task-coding_acq-23_events.json',
'/sub-01/ses-test/func/sub-01_ses-test_task-coding_run-23_events.tsv',
'/sub-01/func/sub-01_task-coding_physio.json',
'/sub-01/func/sub-01_task-coding_acq-23_physio.json',
# various typos
'/sub-01/func/sub-01_task-coding_sbref.ni.gz', # ni
'/sub-01/func/sub-01_task-coding_acq_23_bold.nii.gz', # _23
'/sub-01/func/sub-01_task-coding_acq-23_sbrf.nii.gz', # sbrf
'/sub-01/func/sub-02_task-coding_run-23_bold.nii.gz', # sub-02
'/sub-01/func/sub-01_task-coding-run-23_sbref.nii.gz', # -run
'/sub-01/func/sub-01_task_coding_acq-23_run-23_bold.nii.gz', # _coding
'/sub-01/func/sub-01-task-coding_acq-23_run-23_sbref.nii.gz', # -task
'/sub-01/ses-test/func/sub-01_ses-retest_task-coding_bold.nii.gz', # ses-retest
'/sub-01/ses-test/func/sub-02_ses-test_task-coding_sbref.nii.gz', # sub-02
'/sub-01/ses-test/func/sub-01_ses-test_task-coding_acq-23_blad.nii.gz', # blad
'/sub-01/ses-test/func/sub-01_ses-test-task-coding_acq-23_sbref.nii.gz', # -task
'/sub-01/ses-test/anat/sub-01_ses-test_task-coding_run-23_bold.nii.gz', # anat
'/sub-01/ses-test/anat/sub-01_ses-test_task-coding_run-23_sbref.nii.gz', # anat
'/sub-01/ses-test/dwi/sub-01_ses-test_task-coding_acq-23_run-23_bold.nii.gz', # dwi
'/sub-01/ses-test/dwi/sub-01_ses-test_task-coding_acq-23_run-23_sbref.nii.gz', # dwi
],
)
def test_is_func_bold_false(validator, fname):
"""Test that is_bids returns False for invalid dwi files."""
assert not validator.is_bids(fname)


@pytest.mark.parametrize(
('fname'),
[
'/sub-01/beeh/sub-01_task-task_events.tsv', # wrong data type
'/sub-01/beh/sub-01_suff-suff_task-task_events.json', # wrong suffix
'/sub-01/beh/sub-02_task-task_beh.json', # wrong sub id in the filename
'/sub-01/beh/sub-01_task_task_physio.json', # wrong task_task
'/sub-01/beh/sub-01_task-task_phycoo.tsv.gz', # wrong modality
'/sub-01/beh/sub-01_task-task_stim.jsn', # wrong extension
'/sub-01/beh/sub-01_task-task.tsv.gz', # missed modality
'/sub-01/ses-test/beh/sub-01_ses-test_task-task_events', # missed extension
'/sub-01/beh/ses-test/sub-01_ses-test_task-task_events.json', # wrong dirs order
'/ses-test/beh/sub-01/sub-01_ses-test_task-task_beh.json', # wrong dirs order
'/ses-test/sub-01/beh/sub-01_ses-test_task-task_physio.json', # wrong dirs order
'/sub-01/ses-test/sub-01_ses-test_task-task_physio.tsv.gz', # missed data type dir
'/sub-01/beh/sub-01_ses-test_task-task_stim.json', # missed session id dir
'/ses-test/beh/sub-01_ses-test_task-task_stim.tsv.gz', # missed subject id dir
],
)
def test_is_behavioral_false(validator, fname):
"""Test that is_bids returns False for invalid dwi files."""
assert not validator.is_bids(fname)


@pytest.mark.parametrize(
('fname'),
[
'/sub-01/ses-test/func/sub--01_ses-test_task-nback_physio.tsv.gz', # wrong --
'/sub-01/ses-test/func/sub-01__ses-test_task-nback_physio.json', # wrong __
'/sb-01/ses-test/func/sub-01_ses-test_task-nback_stim.tsv.gz', # wrong subject dir
'/sub-01/ss-test/func/sub-01_ses-test_task-nback_stim.json', # wrong session dir
# wrong data type
'/sub-01/ses-test/dwi/sub-01_ses-test_task-nback_recording-saturation_physio.tsv.gz',
# wrong suffix tsk-
'/sub-01/ses-test/func/sub-01_ses-test_tsk-nback_recording-saturation_physio.json',
# wrong session id in the filename
'/sub-01/ses-test/func/sub-01_ses-retest_task-nback_recording-saturation_stim.tsv.gz',
# wrong subject id in the filename
'/sub_01/ses-test/func/sub-02_ses-test_task-nback_recording-saturation_stim.json',
'/sub-01/beh/ses-test/sub-01_ses-test_task-nback_physio.tsv.gz', # wrong dirs order
'/ses-test/beh/sub-01/sub-01_ses-test_task-nback_physio.json', # wrong dirs order
'/ses-test/sub-01/beh/sub-01_ses-test_task-nback_stim.tsv.gz', # wrong dirs order
'/sub-01/ses-test/beh/sub-01_ses-test_task-nback.json', # missed modality
# missed extension
'/sub-01/ses-test/beh/sub-01_ses-test_task-nback_recording-saturation_physio.',
# missed data type dir
'/sub-01/ses-test/sub-01_ses-test_task-nback_recording-saturation_physio.json',
# missed session id dir
'/sub-01/beh/sub-01_ses-test_task-nback_recording-saturation_stim.tsv.gz',
# missed sub id dir
'/ses-test/beh/sub-01_ses-test_task-nback_recording-saturation_stim.json',
],
)
def test_is_cont_false(validator, fname):
"""Test that is_bids returns False for invalid dwi files."""
assert not validator.is_bids(fname)


@pytest.mark.parametrize(
('fname'),
[
'/sub-01/ses-test/fmap/sub--01_ses-test_acq-singleband_run-01_magnitude.json', # wrong --
'/sub-01/ses-test/fmap/sub-01_ses-test__acq-singleband_run-01_magnitude.nii', # wrong __
# wrong 01-ses
'/sub-01/ses-test/fmap/sub-01-ses-test_acq-singleband_run-01_magnitude1.nii.gz',
# wrong acq_singleband
'/sub-01/ses-test/fmap/sub-01_ses-test_acq_singleband_run-01_magnitude1.json',
# wrong extension
'/sub-01/ses-test/fmap/sub-01_ses-test_acq-singleband_run-01_magnitude1.ni',
# wrong modality
'/sub-01/ses-test/fmap/sub-01_ses-test_acq-singleband_run-01_magnitude3.nii.gz',
# wrong ssuffix ran
'/sub-01/ses-test/fmap/sub-01_ses-test_acq-singeband_ran-01_magnitude2.json',
# missed session id in the filename
'/sub-01/ses-test/fmap/sub-01_acq-singleband_run-01_magnitude2.nii',
# missed subject id in the filename
'/sub-01/ses-test/fmap/ses-test_acq-singleband_run-01_fieldmap.nii.gz',
'/sub-01/ses-test/fmap/sub-01_ses-test_acq-singleband_run-01.json', # missed modality
'/sub-01/ses-test/fmap/sub-01_ses-test_acq-singleband_run-01_fieldmap', # wrong extension
# wrong dirs order
'/sub-01/fmap/ses-test/sub-01_ses-test_acq-singleband_dir-dirlabel_epi.nii.gz',
# wrong dirs order
'/ses-test/fmap/sub-01/sub-01_ses-test_acq-singleband_dir-dirlabel_epi.json',
# wrong dirs order
'/ses-test/sub-01/fmap/sub-01_ses-test_acq-singleband_dir-dirlabel_epi.nii',
# missed data type dir
'/sub-01/ses-test/sub-01_ses-test_acq-singleband_dir-dirlabel_run-01_epi.nii.gz',
# missed session dir
'/sub-01/fmap/sub-01_ses-test_acq-singleband_dir-dirlabel_run-01_epi.json',
# missed subject dir
'/ses-test/fmap/sub-01_ses-test_acq-singleband_dir-dirlabel_run-01_epi.nii',
],
)
def test_is_field_map_false(validator, fname):
"""Test that is_bids returns False for invalid dwi files."""
assert not validator.is_bids(fname)

0 comments on commit ea53778

Please sign in to comment.