Skip to content

Commit

Permalink
test: Check that bidsignored files are accepted in scans.tsv
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Nov 14, 2024
1 parent d4f133c commit 45101a0
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/tests/regression.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { assert } from '@std/assert'
import { pathsToTree } from '../files/filetree.ts'
import { validate } from '../validators/bids.ts'
import type { BIDSFile } from '../types/filetree.ts'


Deno.test('Regression tests', async (t) => {
await t.step('Verify ignored files in scans.tsv do not trigger error', async () => {
const paths = [
'/dataset_description.json',
'/sub-01/anat/sub-01_T1w.nii.gz',
'/sub-01/anat/sub-01_CT.nii.gz', // unknown file
'/sub-01/sub-01_scans.tsv',
]
const ignore = ['*_CT.nii.gz']
const scans_content = 'filename\nanat/sub-01_T1w.nii.gz\nanat/sub-01_CT.nii.gz\n'

// Without ignore, NOT_INCLUDED is triggered for CT, but the scans file is happy
let ds = pathsToTree(paths)
let scans_tsv = ds.get('sub-01/sub-01_scans.tsv') as BIDSFile
scans_tsv.text = () => Promise.resolve(scans_content)
let result = await validate(ds, {
datasetPath: '/dataset',
debug: 'ERROR',
ignoreNiftiHeaders: true,
blacklistModalities: [],
})
assert(result.issues.get({ code: 'NOT_INCLUDED' }).length == 1)
assert(result.issues.get({ code: 'SCANS_FILENAME_NOT_MATCH_DATASET' }).length == 0)

// With ignore, NOT_INCLUDED is not triggered for CT, and the scans file is still happy
ds = pathsToTree(paths, ignore)
scans_tsv = ds.get('sub-01/sub-01_scans.tsv') as BIDSFile
scans_tsv.text = () => Promise.resolve(scans_content)
result = await validate(ds, {
datasetPath: '/dataset',
debug: 'ERROR',
ignoreNiftiHeaders: true,
blacklistModalities: [],
})
assert(result.issues.get({ code: 'NOT_INCLUDED' }).length == 0)
assert(result.issues.get({ code: 'SCANS_FILENAME_NOT_MATCH_DATASET' }).length == 0)
})
})

0 comments on commit 45101a0

Please sign in to comment.