Skip to content

Commit

Permalink
Merge pull request #2176 from effigies/fix/blacklist-inputs
Browse files Browse the repository at this point in the history
fix(cli): Allow blacklisting any modality from schema.rules.modalities
  • Loading branch information
rwblair authored Oct 28, 2024
2 parents f40d4de + 525163b commit d2c9fbb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bids-validator/src/setup/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { LevelName } from '@std/log'
import { Command, EnumType } from '@cliffy/command'
import { getVersion } from '../version.ts'
import type { Issue, Severity } from '../types/issues.ts'
import { schema } from '@bids/schema'

/**
* BIDS Validator config file object definition
Expand Down Expand Up @@ -31,7 +32,7 @@ export type ValidatorOptions = {
}

const modalityType = new EnumType<string>(
['MRI', 'PET', 'MEG', 'EEG', 'iEEG', 'Microscopy', 'NIRS', 'MRS'],
Object.keys(schema.rules.modalities)
)

/** Extendable Cliffy Command with built in BIDS validator options */
Expand Down
9 changes: 7 additions & 2 deletions bids-validator/src/validators/bids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { type BIDSContext, BIDSContextDataset } from '../schema/context.ts'
import type { parseOptions } from '../setup/options.ts'
import { hedValidate } from './hed.ts'
import { citationValidate } from './citation.ts'
import { logger } from '../utils/logger.ts'

/**
* Ordering of checks to apply
Expand Down Expand Up @@ -121,8 +122,12 @@ export async function validate(
// Map blacklisted datatypes back to the modality that generated them
for (const modality of options.blacklistModalities) {
const datatypes = modalitiesRule[modality.toLowerCase()]?.datatypes as string[]
for (const datatype of datatypes) {
blacklistedDatatypes.set(datatype, modality)
if (datatypes) {
for (const datatype of datatypes) {
blacklistedDatatypes.set(datatype, modality)
}
} else {
logger.warn(`Attempted to blacklist unknown modality: ${modality}`)
}
}
}
Expand Down

0 comments on commit d2c9fbb

Please sign in to comment.