From 6c55fe689f8e9a8f000107b21088266a4d0f3b9c Mon Sep 17 00:00:00 2001 From: Chris Gorgolewski Date: Fri, 11 Jan 2019 17:10:14 -0500 Subject: [PATCH] Escape dots in regural expressions --- bids_validator/rules/file_level_rules.json | 124 +++++++++--------- bids_validator/rules/phenotypic_rules.json | 2 +- bids_validator/rules/subject_level_rules.json | 2 +- bids_validator/rules/top_level_rules.json | 50 +++---- 4 files changed, 89 insertions(+), 89 deletions(-) diff --git a/bids_validator/rules/file_level_rules.json b/bids_validator/rules/file_level_rules.json index 0570f0f03..ffe5cc1e7 100644 --- a/bids_validator/rules/file_level_rules.json +++ b/bids_validator/rules/file_level_rules.json @@ -1,6 +1,6 @@ { "anat": { - "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?anat\\/\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_ce-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_anat_suffixes_@@@).(@@@_anat_ext_@@@)$", + "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?anat\\/\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_ce-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_anat_suffixes_@@@)\\.(@@@_anat_ext_@@@)$", "tokens": { "@@@_anat_suffixes_@@@": [ "T1w", @@ -20,12 +20,12 @@ "PDmap", "photo" ], - "@@@_anat_ext_@@@": ["nii.gz", "nii", "json"] + "@@@_anat_ext_@@@": ["nii\\.gz", "nii", "json"] } }, "anat_defacemask": { - "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?anat\\/\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_mod-(?:@@@_anat_suffixes_@@@))?defacemask.(@@@_anat_ext_@@@)$", + "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?anat\\/\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_mod-(?:@@@_anat_suffixes_@@@))?defacemask\\.(@@@_anat_ext_@@@)$", "tokens": { "@@@_anat_suffixes_@@@": [ "T1w", @@ -53,14 +53,14 @@ "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?beh\\/\\1(_\\2)?_task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:@@@_behavioral_ext_@@@)$", "tokens": { "@@@_behavioral_ext_@@@": [ - "_beh.json", - "_beh.tsv", - "_events.json", - "_events.tsv", - "_physio.tsv.gz", - "_stim.tsv.gz", - "_physio.json", - "_stim.json" + "_beh\\.json", + "_beh\\.tsv", + "_events\\.json", + "_events\\.tsv", + "_physio\\.tsv\\.gz", + "_stim\\.tsv\\.gz", + "_physio\\.json", + "_stim\\.json" ] } }, @@ -69,40 +69,40 @@ "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?(?:func|beh)\\/\\1(_\\2)?_task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_recording-[a-zA-Z0-9]+)?(?:@@@_cont_ext_@@@)$", "tokens": { "@@@_cont_ext_@@@": [ - "_physio.tsv.gz", - "_stim.tsv.gz", - "_physio.json", - "_stim.json" + "_physio\\.tsv\\.gz", + "_stim\\.tsv\\.gz", + "_physio\\.json", + "_stim\\.json" ] } }, "dwi": { - "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?dwi\\/\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_dwi_type_@@@).(@@@_dwi_ext_@@@)$", + "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?dwi\\/\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_dwi_type_@@@)\\.(@@@_dwi_ext_@@@)$", "tokens": { - "@@@_dwi_ext_@@@": ["nii.gz", "nii", "json", "bvec", "bval"], + "@@@_dwi_ext_@@@": ["nii\\.gz", "nii", "json", "bvec", "bval"], "@@@_dwi_type_@@@": ["dwi", "sbref"] } }, "eeg": { - "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?eeg\\/\\1(_\\2)?(?:_task-[a-zA-Z0-9]+)?(?:_acq-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:_part-[0-9]+)?(_eeg.(@@@_eeg_type_@@@)|(@@@_eeg_ext_@@@))$", + "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?eeg\\/\\1(_\\2)?(?:_task-[a-zA-Z0-9]+)?(?:_acq-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:_part-[0-9]+)?(_eeg\\.(@@@_eeg_type_@@@)|(@@@_eeg_ext_@@@))$", "tokens": { "@@@_eeg_type_@@@": ["vhdr", "vmrk", "eeg", "edf", "bdf", "set", "fdt"], "@@@_eeg_ext_@@@": [ - "_events.json", - "_events.tsv", - "_electrodes.tsv", - "_channels.tsv", - "_eeg.json", - "_coordsystem.json", - "_photo.jpg" + "_events\\.json", + "_events\\.tsv", + "_electrodes\\.tsv", + "_channels\\.tsv", + "_eeg\\.json", + "_coordsystem\\.json", + "_photo\\.jpg" ] } }, "field_map": { - "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?fmap\\/\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_dir-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_field_map_type_@@@).(@@@_field_map_ext_@@@)$", + "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?fmap\\/\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_dir-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_field_map_type_@@@)\\.(@@@_field_map_ext_@@@)$", "tokens": { "@@@_field_map_type_@@@": [ "phasediff", @@ -114,12 +114,12 @@ "fieldmap", "epi" ], - "@@@_field_map_ext_@@@": ["nii.gz", "nii", "json"] + "@@@_field_map_ext_@@@": ["nii\\.gz", "nii", "json"] } }, "field_map_main_nii": { - "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?fmap\\/\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_dir-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_field_map_type_@@@).(@@@_field_map_ext_@@@)$", + "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?fmap\\/\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_dir-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_field_map_type_@@@)\\.(@@@_field_map_ext_@@@)$", "tokens": { "@@@_field_map_type_@@@": [ "phasediff", @@ -128,7 +128,7 @@ "fieldmap", "epi" ], - "@@@_field_map_ext_@@@": ["nii.gz", "nii"] + "@@@_field_map_ext_@@@": ["nii\\.gz", "nii"] } }, @@ -136,19 +136,19 @@ "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?func\\/\\1(_\\2)?_task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_echo-[0-9]+)?(?:@@@_func_ext_@@@)$", "tokens": { "@@@_func_ext_@@@": [ - "_bold.nii.gz", - "_bold.nii", - "_bold.json", - "_sbref.nii.gz", - "_sbref.json", - "_events.json", - "_events.tsv", - "_physio.tsv.gz", - "_stim.tsv.gz", - "_physio.json", - "_stim.json", - "_defacemask.nii.gz", - "_defacemask.nii" + "_bold\\.nii\\.gz", + "_bold\\.nii", + "_bold\\.json", + "_sbref\\.nii\\.gz", + "_sbref\\.json", + "_events\\.json", + "_events\\.tsv", + "_physio\\.tsv\\.gz", + "_stim\\.tsv\\.gz", + "_physio\\.json", + "_stim\\.json", + "_defacemask\\.nii\\.gz", + "_defacemask\\.nii" ] } }, @@ -157,16 +157,16 @@ "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?func\\/\\1(_\\2)?_task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_echo-[0-9]+)?(?:@@@_func_bold_ext_@@@)$", "tokens": { "@@@_func_bold_ext_@@@": [ - "_bold.nii.gz", - "_bold.nii", - "_sbref.nii.gz", - "_sbref.nii" + "_bold\\.nii\\.gz", + "_bold\\.nii", + "_sbref\\.nii\\.gz", + "_sbref\\.nii" ] } }, "ieeg": { - "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?ieeg\\/\\1(_\\2)?(?:_task-[a-zA-Z0-9]+)?(?:_acq-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:_part-[0-9]+)?(?:_space-[a-zA-Z0-9]+)?(_ieeg.(@@@_ieeg_type_@@@)|(@@@_ieeg_ext_@@@))$", + "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?ieeg\\/\\1(_\\2)?(?:_task-[a-zA-Z0-9]+)?(?:_acq-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:_part-[0-9]+)?(?:_space-[a-zA-Z0-9]+)?(_ieeg\\.(@@@_ieeg_type_@@@)|(@@@_ieeg_ext_@@@))$", "tokens": { "@@@_ieeg_type_@@@": [ "edf", @@ -179,13 +179,13 @@ "mef" ], "@@@_ieeg_ext_@@@": [ - "_events.json", - "_events.tsv", - "_electrodes.tsv", - "_channels.tsv", - "_ieeg.json", - "_coordsystem.json", - "_photo.jpg" + "_events\\.json", + "_events\\.tsv", + "_electrodes\\.tsv", + "_channels\\.tsv", + "_ieeg\\.json", + "_coordsystem\\.json", + "_photo\\.jpg" ] } }, @@ -193,15 +193,15 @@ "meg": { "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?meg\\/\\1(_\\2)?(?:_task-[a-zA-Z0-9]+)?(?:_acq-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:_part-[0-9]+)?(_meg(@@@_meg_type_@@@\\/.*|\\/.*)|(@@@_meg_ext_@@@))$", "tokens": { - "@@@_meg_type_@@@": [".fif", ".ds"], + "@@@_meg_type_@@@": ["\\.fif", "\\.ds"], "@@@_meg_ext_@@@": [ - "_events.json", - "_events.tsv", - "_channels.tsv", - "_meg.json", - "_coordsystem.json", - "_photo.jpg", - "_headshape.pos" + "_events\\.json", + "_events\\.tsv", + "_channels\\.tsv", + "_meg\\.json", + "_coordsystem\\.json", + "_photo\\.jpg", + "_headshape\\.pos" ] } }, diff --git a/bids_validator/rules/phenotypic_rules.json b/bids_validator/rules/phenotypic_rules.json index f71a3e369..ce0b7c5be 100644 --- a/bids_validator/rules/phenotypic_rules.json +++ b/bids_validator/rules/phenotypic_rules.json @@ -1,5 +1,5 @@ { "phenotypic_data": { - "regexp": "^\\/(?:phenotype)\\/(?:.*.tsv|.*.json)$" + "regexp": "^\\/(?:phenotype)\\/(?:.*\\.tsv|.*\\.json)$" } } diff --git a/bids_validator/rules/subject_level_rules.json b/bids_validator/rules/subject_level_rules.json index 7277d00fc..9a3e32825 100644 --- a/bids_validator/rules/subject_level_rules.json +++ b/bids_validator/rules/subject_level_rules.json @@ -2,7 +2,7 @@ "subject_level": { "regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/\\1(@@@_subject_level_ext_@@@)$", "tokens": { - "@@@_subject_level_ext_@@@": ["_sessions.tsv", "_sessions.json"] + "@@@_subject_level_ext_@@@": ["_sessions\\.tsv", "_sessions\\.json"] } } } diff --git a/bids_validator/rules/top_level_rules.json b/bids_validator/rules/top_level_rules.json index b51ebf5f4..e4cad58be 100644 --- a/bids_validator/rules/top_level_rules.json +++ b/bids_validator/rules/top_level_rules.json @@ -3,19 +3,19 @@ "regexp": "^\\/(?:ses-[a-zA-Z0-9]+_)?(?:recording-[a-zA-Z0-9]+_)?task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_echo-[0-9]+)?(@@@_func_top_ext_@@@)$", "tokens": { "@@@_func_top_ext_@@@": [ - "_bold.json", - "_sbref.json", - "_events.json", - "_events.tsv", - "_physio.json", - "_stim.json", - "_beh.json" + "_bold\\.json", + "_sbref\\.json", + "_events\\.json", + "_events\\.tsv", + "_physio\\.json", + "_stim\\.json", + "_beh\\.json" ] } }, "anat_top": { - "regexp": "^\\/(?:ses-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?(@@@_anat_suffixes_@@@).json$", + "regexp": "^\\/(?:ses-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?(@@@_anat_suffixes_@@@)\\.json$", "tokens": { "@@@_anat_suffixes_@@@": [ "T1w", @@ -39,7 +39,7 @@ }, "dwi_top": { - "regexp": "^\\/(?:ses-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?dwi.(?:@@@_dwi_top_ext_@@@)$", + "regexp": "^\\/(?:ses-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?dwi\\.(?:@@@_dwi_top_ext_@@@)$", "tokens": { "@@@_dwi_top_ext_@@@": ["json", "bval", "bvec"] } @@ -48,11 +48,11 @@ "regexp": "^\\/(?:ses-[a-zA-Z0-9]+_)?task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:@@@_eeg_top_ext_@@@)$", "tokens": { "@@@_eeg_top_ext_@@@": [ - "_eeg.json", - "_channels.tsv", - "_electrodes.tsv", - "_photo.jpg", - "_coordsystem.json" + "_eeg\\.json", + "_channels\\.tsv", + "_electrodes\\.tsv", + "_photo\\.jpg", + "_coordsystem\\.json" ] } }, @@ -60,11 +60,11 @@ "regexp": "^\\/(?:ses-[a-zA-Z0-9]+_)?task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:@@@_ieeg_top_ext_@@@)$", "tokens": { "@@@_ieeg_top_ext_@@@": [ - "_ieeg.json", - "_channels.tsv", - "_electrodes.tsv", - "_photo.jpg", - "_coordsystem.json" + "_ieeg\\.json", + "_channels\\.tsv", + "_electrodes\\.tsv", + "_photo\\.jpg", + "_coordsystem\\.json" ] } }, @@ -72,21 +72,21 @@ "regexp": "^\\/(?:ses-[a-zA-Z0-9]+_)?task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:@@@_meg_top_ext_@@@)$", "tokens": { "@@@_meg_top_ext_@@@": [ - "_meg.json", - "_channels.tsv", - "_photo.jpg", - "_coordsystem.json" + "_meg\\.json", + "_channels\\.tsv", + "_photo\\.jpg", + "_coordsystem\\.json" ] } }, "multi_dir_fieldmap": { - "regexp": "^\\/(?:acq-[a-zA-Z0-9]+_)?(?:dir-[a-zA-Z0-9]+_)epi.json$" + "regexp": "^\\/(?:acq-[a-zA-Z0-9]+_)?(?:dir-[a-zA-Z0-9]+_)epi\\.json$" }, "other_top_files": { "regexp": "^\\/(?:ses-[a-zA-Z0-9]+_)?(?:recording-[a-zA-Z0-9]+_)?(?:task-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?(@@@_other_top_files_ext_@@@)$", "tokens": { - "@@@_other_top_files_ext_@@@": ["physio.json", "stim.json"] + "@@@_other_top_files_ext_@@@": ["physio\\.json", "stim\\.json"] } } }