@@ -51,13 +51,16 @@ function assertErrorCode(errors, expected_error_code) {
5151 assert ( matchingErrors . length > 0 )
5252}
5353
54+ // Default validate.BIDS options
55+ const options = { ignoreNiftiHeaders : true , json : true }
56+ const enableNiftiHeaders = { json : true }
57+
5458describe ( 'BIDS example datasets ' , function ( ) {
5559 describe ( 'basic example dataset tests' , ( ) => {
5660 getDirectories (
5761 dataDirectory + 'bids-examples-' + global . test_version + '/' ,
5862 ) . forEach ( function testDataset ( path ) {
5963 it ( path , isdone => {
60- const options = { ignoreNiftiHeaders : true }
6164 validate . BIDS ( createExampleFileList ( path ) , options , function ( issues ) {
6265 var warnings = issues . warnings
6366 var session_flag = false
@@ -80,7 +83,6 @@ describe('BIDS example datasets ', function() {
8083
8184 // we need to have at least one non-dynamic test
8285 it ( 'validates path without trailing backslash' , function ( isdone ) {
83- var options = { ignoreNiftiHeaders : true }
8486 validate . BIDS ( createExampleFileList ( 'ds001' ) , options , function (
8587 issues ,
8688 summary ,
@@ -106,67 +108,69 @@ describe('BIDS example datasets ', function() {
106108
107109 // we need to have at least one non-dynamic test
108110 it ( 'validates dataset with valid nifti headers' , function ( isdone ) {
109- var options = { ignoreNiftiHeaders : false }
110- validate . BIDS ( createDatasetFileList ( 'valid_headers' ) , options , function (
111- issues ,
112- summary ,
113- ) {
114- var errors = issues . errors
115- var warnings = issues . warnings
116- assert ( summary . sessions . length === 0 )
117- assert ( summary . subjects . length === 1 )
118- assert . deepEqual ( summary . tasks , [ 'rhyme judgment' ] )
119- assert ( summary . modalities . includes ( 'T1w ' ) )
120- assert ( summary . modalities . includes ( 'bold' ) )
121- assert ( summary . totalFiles === 8 )
122- assert (
123- errors . findIndex ( error => error . code === 60 ) > - 1 ,
124- 'errors do not contain a code 60' ,
125- )
126- assert . deepEqual ( warnings . length , 4 )
127- assert (
128- warnings . findIndex ( warning => warning . code === 13 ) > - 1 ,
129- 'warnings do not contain a code 13' ,
130- )
131- isdone ( )
132- } )
111+ validate . BIDS (
112+ createDatasetFileList ( 'valid_headers' ) ,
113+ enableNiftiHeaders ,
114+ function ( issues , summary ) {
115+ var errors = issues . errors
116+ var warnings = issues . warnings
117+ assert ( summary . sessions . length === 0 )
118+ assert ( summary . subjects . length === 1 )
119+ assert . deepEqual ( summary . tasks , [ 'rhyme judgment' ] )
120+ assert ( summary . modalities . includes ( 'T1w' ) )
121+ assert ( summary . modalities . includes ( 'bold ' ) )
122+ assert ( summary . totalFiles === 8 )
123+ assert (
124+ errors . findIndex ( error => error . code === 60 ) > - 1 ,
125+ ' errors do not contain a code 60' ,
126+ )
127+ assert . deepEqual ( warnings . length , 4 )
128+ assert (
129+ warnings . findIndex ( warning => warning . code === 13 ) > - 1 ,
130+ ' warnings do not contain a code 13' ,
131+ )
132+ isdone ( )
133+ } ,
134+ )
133135 } )
134136
135137 // test for duplicate files present with both .nii and .nii.gz extension
136138 it ( 'validates dataset for duplicate files present with both .nii and .nii.gz extension' , function ( isdone ) {
137- var options = { ignoreNiftiHeaders : false }
138- validate . BIDS ( createDatasetFileList ( 'valid_filenames' ) , options , function (
139- issues ,
140- ) {
141- assertErrorCode ( issues . errors , 74 )
142- isdone ( )
143- } )
139+ validate . BIDS (
140+ createDatasetFileList ( 'valid_filenames' ) ,
141+ enableNiftiHeaders ,
142+ function ( issues ) {
143+ assertErrorCode ( issues . errors , 74 )
144+ isdone ( )
145+ } ,
146+ )
144147 } )
145148
146149 // test for illegal characters used in acq and task name
147150 it ( 'validates dataset with illegal characters in task name' , function ( isdone ) {
148- var options = { ignoreNiftiHeaders : false }
149- validate . BIDS ( createDatasetFileList ( 'valid_filenames' ) , options , function (
150- issues ,
151- ) {
152- assertErrorCode ( issues . errors , 58 )
153- isdone ( )
154- } )
151+ validate . BIDS (
152+ createDatasetFileList ( 'valid_filenames' ) ,
153+ enableNiftiHeaders ,
154+ function ( issues ) {
155+ assertErrorCode ( issues . errors , 58 )
156+ isdone ( )
157+ } ,
158+ )
155159 } )
156160
157161 // test for illegal characters used in sub name
158162 it ( 'validates dataset with illegal characters in sub name' , function ( isdone ) {
159- var options = { ignoreNiftiHeaders : false }
160- validate . BIDS ( createDatasetFileList ( 'valid_filenames' ) , options , function (
161- issues ,
162- ) {
163- assertErrorCode ( issues . errors , 64 )
164- isdone ( )
165- } )
163+ validate . BIDS (
164+ createDatasetFileList ( 'valid_filenames' ) ,
165+ enableNiftiHeaders ,
166+ function ( issues ) {
167+ assertErrorCode ( issues . errors , 64 )
168+ isdone ( )
169+ } ,
170+ )
166171 } )
167172
168173 it ( 'checks for subjects with no valid data' , function ( isdone ) {
169- var options = { ignoreNiftiHeaders : true }
170174 validate . BIDS ( createDatasetFileList ( 'no_valid_data' ) , options , function (
171175 issues ,
172176 ) {
@@ -176,7 +180,6 @@ describe('BIDS example datasets ', function() {
176180 } )
177181
178182 it ( 'validates MRI modalities' , function ( isdone ) {
179- var options = { ignoreNiftiHeaders : true }
180183 validate . BIDS ( createExampleFileList ( 'ds001' ) , options , function (
181184 issues ,
182185 summary ,
@@ -201,7 +204,6 @@ describe('BIDS example datasets ', function() {
201204 } )
202205
203206 it ( 'checks for data dictionaries without corresponding data files' , function ( isdone ) {
204- var options = { ignoreNiftiHeaders : true }
205207 validate . BIDS ( createDatasetFileList ( 'unused_data_dict' ) , options , function (
206208 issues ,
207209 ) {
@@ -211,7 +213,6 @@ describe('BIDS example datasets ', function() {
211213 } )
212214
213215 it ( 'checks for fieldmaps with no _magnitude file' , function ( isdone ) {
214- var options = { ignoreNiftiHeaders : true }
215216 validate . BIDS (
216217 createDatasetFileList ( 'fieldmap_without_magnitude' ) ,
217218 options ,
@@ -223,7 +224,6 @@ describe('BIDS example datasets ', function() {
223224 } )
224225
225226 it ( 'should not throw a warning if all _phasediff.nii are associated with _magnitude1.nii' , function ( isdone ) {
226- var options = { ignoreNiftiHeaders : true }
227227 validate . BIDS ( createExampleFileList ( 'hcp_example_bids' ) , options , function (
228228 issues ,
229229 ) {
@@ -233,7 +233,6 @@ describe('BIDS example datasets ', function() {
233233 } )
234234
235235 it ( 'should throw a warning if there are _phasediff.nii without an associated _magnitude1.nii' , function ( isdone ) {
236- var options = { ignoreNiftiHeaders : true }
237236 validate . BIDS (
238237 createDatasetFileList ( 'phasediff_without_magnitude1' ) ,
239238 options ,
0 commit comments