forked from bids-standard/bids-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bids-standard#114 from effigies/test/bidsignore_scans
test: Check that bidsignored files are accepted in scans.tsv
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) |