@@ -16,28 +16,28 @@ module.exports = {
1616 * Check if a given path is valid within the
1717 * bids spec.
1818 */
19- isBIDS : function ( path ) {
19+ isBIDS : function ( path ) {
2020 return (
21- this . isTopLevel ( path ) ||
21+ this . isTopLevel ( path ) ||
2222 this . isAssociatedData ( path ) ||
23- this . isSessionLevel ( path ) ||
24- this . isSubjectLevel ( path ) ||
25- this . isAnat ( path ) ||
26- this . isDWI ( path ) ||
27- this . isFunc ( path ) ||
28- this . isBehavioral ( path ) ||
29- this . isCont ( path ) ||
30- this . isFieldMap ( path ) ||
23+ this . isSessionLevel ( path ) ||
24+ this . isSubjectLevel ( path ) ||
25+ this . isAnat ( path ) ||
26+ this . isDWI ( path ) ||
27+ this . isFunc ( path ) ||
28+ this . isBehavioral ( path ) ||
29+ this . isCont ( path ) ||
30+ this . isFieldMap ( path ) ||
3131 this . isPhenotypic ( path )
3232 ) ;
3333 } ,
3434
3535 /**
3636 * Check if the file has appropriate name for a top level file
3737 */
38- isTopLevel : function ( path ) {
38+ isTopLevel : function ( path ) {
3939 var fixedTopLevelNames = [ "/README" , "/CHANGES" , "/dataset_description.json" , "/participants.tsv" ,
40- "/participants.json" , "/phasediff.json" , "/phase1.json" , "/phase2.json" , "/fieldmap.json" ] ;
40+ "/participants.json" , "/phasediff.json" , "/phase1.json" , "/phase2.json" , "/fieldmap.json" ] ;
4141
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)$' ) ;
@@ -60,23 +60,23 @@ module.exports = {
6060 /**
6161 * Check if file is appropriate associated data.
6262 */
63- isAssociatedData : function ( path ) {
63+ isAssociatedData : function ( path ) {
6464 var associatedData = new RegExp ( '^\\/(?:code|derivatives|sourcedata|stimuli|[.]git)\\/(?:.*)$' ) ;
6565 return associatedData . test ( path ) ;
6666 } ,
6767
6868 /**
6969 * Check if file is phenotypic data.
7070 */
71- isPhenotypic : function ( path ) {
71+ isPhenotypic : function ( path ) {
7272 var phenotypicData = new RegExp ( '^\\/(?:phenotype)\\/(?:.*.tsv|.*.json)$' ) ;
7373 return phenotypicData . test ( path ) ;
7474 } ,
7575
7676 /**
7777 * Check if the file has appropriate name for a session level
7878 */
79- isSessionLevel : function ( path ) {
79+ isSessionLevel : function ( path ) {
8080 var scansRe = new RegExp ( '^\\/(sub-[a-zA-Z0-9]+)' +
8181 '\\/(?:(ses-[a-zA-Z0-9]+)' +
8282 '\\/)?\\1(_\\2)?(_scans.tsv|_scans.json)$' ) ;
@@ -103,7 +103,7 @@ module.exports = {
103103 /**
104104 * Check if the file has appropriate name for a subject level
105105 */
106- isSubjectLevel : function ( path ) {
106+ isSubjectLevel : function ( path ) {
107107 var scansRe = new RegExp ( '^\\/(sub-[a-zA-Z0-9]+)' +
108108 '\\/\\1(_sessions.tsv|_sessions.json)$' ) ;
109109 return scansRe . test ( path ) ;
@@ -112,7 +112,7 @@ module.exports = {
112112 /**
113113 * Check if the file has a name appropriate for an anatomical scan
114114 */
115- isAnat : function ( path ) {
115+ isAnat : function ( path ) {
116116 var anatRe = new RegExp ( '^\\/(sub-[a-zA-Z0-9]+)' +
117117 '\\/(?:(ses-[a-zA-Z0-9]+)' +
118118 '\\/)?anat' +
@@ -125,7 +125,7 @@ module.exports = {
125125 /**
126126 * Check if the file has a name appropriate for a diffusion scan
127127 */
128- isDWI : function ( path ) {
128+ isDWI : function ( path ) {
129129 var suffixes = [ "dwi" , "sbref" ] ;
130130 var anatRe = new RegExp ( '^\\/(sub-[a-zA-Z0-9]+)' +
131131 '\\/(?:(ses-[a-zA-Z0-9]+)' +
@@ -139,7 +139,7 @@ module.exports = {
139139 /**
140140 * Check if the file has a name appropriate for a fieldmap scan
141141 */
142- isFieldMap : function ( path ) {
142+ isFieldMap : function ( path ) {
143143 var suffixes = [ "phasediff" , "phase1" , "phase2" , "magnitude1" , "magnitude2" , "magnitude" , "fieldmap" , "epi" ] ;
144144 var anatRe = new RegExp ( '^\\/(sub-[a-zA-Z0-9]+)' +
145145 '\\/(?:(ses-[a-zA-Z0-9]+)' +
@@ -153,7 +153,7 @@ module.exports = {
153153 /**
154154 * Check if the file has a name appropriate for a functional scan
155155 */
156- isFunc : function ( path ) {
156+ isFunc : function ( path ) {
157157 var funcRe = new RegExp ( '^\\/(sub-[a-zA-Z0-9]+)' +
158158 '\\/(?:(ses-[a-zA-Z0-9]+)' +
159159 '\\/)?func' +
@@ -162,7 +162,7 @@ module.exports = {
162162 return conditionalMatch ( funcRe , path ) ;
163163 } ,
164164
165- isBehavioral : function ( path ) {
165+ isBehavioral : function ( path ) {
166166 var funcBeh = new RegExp ( '^\\/(sub-[a-zA-Z0-9]+)' +
167167 '\\/(?:(ses-[a-zA-Z0-9]+)' +
168168 '\\/)?beh' +
@@ -171,7 +171,7 @@ module.exports = {
171171 return conditionalMatch ( funcBeh , path ) ;
172172 } ,
173173
174- isFuncBold : function ( path ) {
174+ isFuncBold : function ( path ) {
175175 var funcRe = new RegExp ( '^\\/(sub-[a-zA-Z0-9]+)' +
176176 '\\/(?:(ses-[a-zA-Z0-9]+)' +
177177 '\\/)?func' +
@@ -180,7 +180,7 @@ module.exports = {
180180 return conditionalMatch ( funcRe , path ) ;
181181 } ,
182182
183- isCont : function ( path ) {
183+ isCont : function ( path ) {
184184 var contRe = new RegExp ( '^\\/(sub-[a-zA-Z0-9]+)' +
185185 '\\/(?:(ses-[a-zA-Z0-9]+)' +
186186 '\\/)?(?:func|beh)' +
@@ -190,7 +190,7 @@ module.exports = {
190190 return conditionalMatch ( contRe , path ) ;
191191 } ,
192192
193- isNumber : function ( n ) {
193+ isNumber : function ( n ) {
194194 return ! isNaN ( parseFloat ( n ) ) && isFinite ( n ) ;
195195 } ,
196196
@@ -229,3 +229,6 @@ function conditionalMatch (expression, path) {
229229 }
230230 return false ;
231231}
232+
233+
234+
0 commit comments