Skip to content

Commit

Permalink
Merge pull request #686 from chrisfilo/fix/escape_dots
Browse files Browse the repository at this point in the history
Escape dots in regural expressions
  • Loading branch information
chrisgorgo authored Jan 17, 2019
2 parents 69e8e35 + 6c55fe6 commit 39cec46
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 89 deletions.
124 changes: 62 additions & 62 deletions bids_validator/rules/file_level_rules.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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"
]
}
},
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -128,27 +128,27 @@
"fieldmap",
"epi"
],
"@@@_field_map_ext_@@@": ["nii.gz", "nii"]
"@@@_field_map_ext_@@@": ["nii\\.gz", "nii"]
}
},

"func": {
"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"
]
}
},
Expand All @@ -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",
Expand All @@ -179,29 +179,29 @@
"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"
]
}
},

"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"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion bids_validator/rules/phenotypic_rules.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"phenotypic_data": {
"regexp": "^\\/(?:phenotype)\\/(?:.*.tsv|.*.json)$"
"regexp": "^\\/(?:phenotype)\\/(?:.*\\.tsv|.*\\.json)$"
}
}
2 changes: 1 addition & 1 deletion bids_validator/rules/subject_level_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
}
}
50 changes: 25 additions & 25 deletions bids_validator/rules/top_level_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"]
}
Expand All @@ -48,45 +48,45 @@
"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"
]
}
},
"ieeg_top": {
"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"
]
}
},
"meg_top": {
"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"]
}
}
}

0 comments on commit 39cec46

Please sign in to comment.