Skip to content

Commit a0fac97

Browse files
committed
test: Check that bidsignored files are accepted in scans.tsv
1 parent 5b5c2e2 commit a0fac97

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/tests/regression.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { assert } from '@std/assert'
2+
import { pathsToTree } from '../files/filetree.ts'
3+
import { validate } from '../validators/bids.ts'
4+
import type { BIDSFile } from '../types/filetree.ts'
5+
6+
7+
Deno.test('Regression tests', async (t) => {
8+
await t.step('Verify ignored files in scans.tsv do not trigger error', async () => {
9+
const paths = [
10+
'/dataset_description.json',
11+
'/sub-01/anat/sub-01_T1w.nii.gz',
12+
'/sub-01/anat/sub-01_CT.nii.gz', // unknown file
13+
'/sub-01/sub-01_scans.tsv',
14+
]
15+
const ignore = ['*_CT.nii.gz']
16+
const scans_content = 'filename\nanat/sub-01_T1w.nii.gz\nanat/sub-01_CT.nii.gz\n'
17+
18+
// Without ignore, NOT_INCLUDED is triggered for CT, but the scans file is happy
19+
let ds = pathsToTree(paths)
20+
let scans_tsv = ds.get('sub-01/sub-01_scans.tsv') as BIDSFile
21+
scans_tsv.text = () => Promise.resolve(scans_content)
22+
let result = await validate(ds, {
23+
datasetPath: '/dataset',
24+
debug: 'ERROR',
25+
ignoreNiftiHeaders: true,
26+
blacklistModalities: [],
27+
})
28+
assert(result.issues.get({ code: 'NOT_INCLUDED' }).length == 1)
29+
assert(result.issues.get({ code: 'SCANS_FILENAME_NOT_MATCH_DATASET' }).length == 0)
30+
31+
// With ignore, NOT_INCLUDED is not triggered for CT, and the scans file is still happy
32+
ds = pathsToTree(paths, ignore)
33+
scans_tsv = ds.get('sub-01/sub-01_scans.tsv') as BIDSFile
34+
scans_tsv.text = () => Promise.resolve(scans_content)
35+
result = await validate(ds, {
36+
datasetPath: '/dataset',
37+
debug: 'ERROR',
38+
ignoreNiftiHeaders: true,
39+
blacklistModalities: [],
40+
})
41+
assert(result.issues.get({ code: 'NOT_INCLUDED' }).length == 0)
42+
assert(result.issues.get({ code: 'SCANS_FILENAME_NOT_MATCH_DATASET' }).length == 0)
43+
})
44+
})

0 commit comments

Comments
 (0)