Skip to content

Commit eb4a96f

Browse files
authored
Merge pull request #354 from jbwexler/recognize-top-level-jsons
update type.js regex to recognize top-level jsons
2 parents 859aa55 + d3c078b commit eb4a96f

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

tests/type.spec.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ var suiteTop = describe('utils.type.isTopLevel', function(){
9898
"/dataset_description.json",
9999
"/ses-pre_task-rest_bold.json",
100100
"/dwi.bval",
101-
"/dwi.bvec"
101+
"/dwi.bvec",
102+
"/T1w.json",
103+
"/acq-test_dwi.json",
104+
"/rec-test_physio.json"
102105
];
103106

104107
goodFilenames.forEach(function (path) {
@@ -112,7 +115,10 @@ var suiteTop = describe('utils.type.isTopLevel', function(){
112115
"/readme.txt",
113116
"/changelog",
114117
"/dataset_description.yml",
115-
"/ses.json"
118+
"/ses.json",
119+
"/_T1w.json",
120+
"/_dwi.json",
121+
"/_task-test_physio.json"
116122
];
117123

118124
badFilenames.forEach(function (path) {

utils/type.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ module.exports = {
4242
var funcTopRe = new 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]+)?'
4343
+ '(_bold.json|_sbref.json|_events.json|_events.tsv|_physio.json|_stim.json|_beh.json)$');
4444

45-
var anatTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+_)?'
45+
var anatTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?'
4646
+ '(' + anatSuffixes.join("|") + ').json$');
4747

48-
var dwiTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_)?'
48+
var dwiTopRe = new RegExp('^\\/(?:ses-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?'
4949
+ 'dwi.(?:json|bval|bvec)$');
5050

5151
var multiDirFieldmapRe = new RegExp('^\\/(?:dir-[a-zA-Z0-9]+)_epi.json$');
5252

53-
var otherTopFiles = new 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]+)?'
54-
+ '(_physio.json|_stim.json)$');
53+
var otherTopFiles = new 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]+_)?'
54+
+ '(physio.json|stim.json)$');
5555

5656
return (fixedTopLevelNames.indexOf(path) != -1 || funcTopRe.test(path) || dwiTopRe.test(path) ||
5757
anatTopRe.test(path) || multiDirFieldmapRe.test(path) || otherTopFiles.test(path));
@@ -229,6 +229,3 @@ function conditionalMatch (expression, path) {
229229
}
230230
return false;
231231
}
232-
233-
234-

0 commit comments

Comments
 (0)