Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove schema experiment from legacy validator #1932

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bids-validator/utils/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default {
remoteFiles: Boolean(options.remoteFiles),
gitRef: options.gitRef || 'HEAD',
config: options.config || {},
schema: options.schema !== 'disable' ? options.schema : false,
}
if (options.config && typeof options.config !== 'boolean') {
this.parseConfig(dir, options.config, function (issues, config) {
Expand Down
201 changes: 61 additions & 140 deletions bids-validator/utils/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ import session_level_rules from '../bids_validator/rules/session_level_rules.jso
import subject_level_rules from '../bids_validator/rules/subject_level_rules.json'
import top_level_rules from '../bids_validator/rules/top_level_rules.json'

let bids_schema

// Alternative method of loading from bids-specification schema
export function schemaSetup(schema) {
bids_schema = schema
}

// Associated data
const associatedData = buildRegExp(associated_data_rules.associated_data)
// File level
Expand Down Expand Up @@ -146,57 +139,30 @@ export default {
* Check if the file has appropriate name for a top level file
*/
isTopLevel: function (path) {
if (bids_schema) {
return (
bids_schema.top_level_files.some((regex) => regex.exec(path)) ||
funcTop.test(path) ||
aslTop.test(path) ||
dwiTop.test(path) ||
anatTop.test(path) ||
vfaTop.test(path) ||
megreTop.test(path) ||
irt1Top.test(path) ||
mpmTop.test(path) ||
mtsTop.test(path) ||
mtrTop.test(path) ||
mp2rageTop.test(path) ||
fmapEpiTop.test(path) ||
fmapGreTop.test(path) ||
otherTopFiles.test(path) ||
megTop.test(path) ||
eegTop.test(path) ||
ieegTop.test(path) ||
petTop.test(path) ||
motionTop.test(path) ||
nirsTop.test(path) ||
microscopyTop.test(path)
)
} else {
return (
rootTop.test(path) ||
funcTop.test(path) ||
aslTop.test(path) ||
dwiTop.test(path) ||
anatTop.test(path) ||
vfaTop.test(path) ||
megreTop.test(path) ||
irt1Top.test(path) ||
mpmTop.test(path) ||
mtsTop.test(path) ||
mtrTop.test(path) ||
mp2rageTop.test(path) ||
fmapEpiTop.test(path) ||
fmapGreTop.test(path) ||
otherTopFiles.test(path) ||
megTop.test(path) ||
eegTop.test(path) ||
ieegTop.test(path) ||
petTop.test(path) ||
motionTop.test(path) ||
nirsTop.test(path) ||
microscopyTop.test(path)
)
}
return (
rootTop.test(path) ||
funcTop.test(path) ||
aslTop.test(path) ||
dwiTop.test(path) ||
anatTop.test(path) ||
vfaTop.test(path) ||
megreTop.test(path) ||
irt1Top.test(path) ||
mpmTop.test(path) ||
mtsTop.test(path) ||
mtrTop.test(path) ||
mp2rageTop.test(path) ||
fmapEpiTop.test(path) ||
fmapGreTop.test(path) ||
otherTopFiles.test(path) ||
megTop.test(path) ||
eegTop.test(path) ||
ieegTop.test(path) ||
petTop.test(path) ||
motionTop.test(path) ||
nirsTop.test(path) ||
microscopyTop.test(path)
)
},

/**
Expand Down Expand Up @@ -267,51 +233,39 @@ export default {
* Check if the file has a name appropriate for an anatomical scan
*/
isAnat: function (path) {
if (bids_schema) {
return bids_schema.datatypes['anat'].some((regex) => regex.exec(path))
} else {
return (
conditionalMatch(anatNonparametric, path) ||
conditionalMatch(anatParametric, path) ||
conditionalMatch(anatDefacemask, path) ||
conditionalMatch(anatMultiEcho, path) ||
conditionalMatch(anatMultiFlip, path) ||
conditionalMatch(anatMultiInv, path) ||
conditionalMatch(anatMP2RAGE, path) ||
conditionalMatch(anatVFAMT, path) ||
conditionalMatch(anatMTR, path)
)
}
return (
conditionalMatch(anatNonparametric, path) ||
conditionalMatch(anatParametric, path) ||
conditionalMatch(anatDefacemask, path) ||
conditionalMatch(anatMultiEcho, path) ||
conditionalMatch(anatMultiFlip, path) ||
conditionalMatch(anatMultiInv, path) ||
conditionalMatch(anatMP2RAGE, path) ||
conditionalMatch(anatVFAMT, path) ||
conditionalMatch(anatMTR, path)
)
},

/**
* Check if the file has a name appropriate for a diffusion scan
*/
isDWI: function (path) {
if (bids_schema) {
return bids_schema.datatypes['dwi'].some((regex) => regex.exec(path))
} else {
return conditionalMatch(dwiData, path)
}
return conditionalMatch(dwiData, path)
},

/**
* Check if the file has a name appropriate for a fieldmap scan
*/
isFieldMap: function (path) {
if (bids_schema) {
return bids_schema.datatypes['fmap'].some((regex) => regex.exec(path))
} else {
return (
conditionalMatch(fmapGre, path) ||
conditionalMatch(fmapPepolarAsl, path) ||
conditionalMatch(fmapTB1DAM, path) ||
conditionalMatch(fmapTB1EPI, path) ||
conditionalMatch(fmapTB1SRGE, path) ||
conditionalMatch(fmapRF, path) ||
conditionalMatch(fmapParametric, path)
)
}
return (
conditionalMatch(fmapGre, path) ||
conditionalMatch(fmapPepolarAsl, path) ||
conditionalMatch(fmapTB1DAM, path) ||
conditionalMatch(fmapTB1EPI, path) ||
conditionalMatch(fmapTB1SRGE, path) ||
conditionalMatch(fmapRF, path) ||
conditionalMatch(fmapParametric, path)
)
},

isFieldMapMainNii: function (path) {
Expand All @@ -332,73 +286,47 @@ export default {
* Check if the file has a name appropriate for a functional scan
*/
isFunc: function (path) {
if (bids_schema) {
return bids_schema.datatypes['func'].some((regex) => regex.exec(path))
} else {
return (
conditionalMatch(func, path) ||
conditionalMatch(funcPhaseDeprecated, path) ||
conditionalMatch(funcEvents, path) ||
conditionalMatch(funcTimeseries, path)
)
}
return (
conditionalMatch(func, path) ||
conditionalMatch(funcPhaseDeprecated, path) ||
conditionalMatch(funcEvents, path) ||
conditionalMatch(funcTimeseries, path)
)
},

isAsl: function (path) {
return conditionalMatch(aslData, path)
},

isPET: function (path) {
if (bids_schema) {
return bids_schema.datatypes['pet'].some((regex) => regex.exec(path))
} else {
return conditionalMatch(petData, path)
}
return conditionalMatch(petData, path)
},

isPETBlood: function (path) {
return conditionalMatch(petBlood, path)
},

isMeg: function (path) {
if (bids_schema) {
return bids_schema.datatypes['meg'].some((regex) => regex.exec(path))
} else {
return (
conditionalMatch(megData, path) ||
conditionalMatch(megCalibrationData, path) ||
conditionalMatch(megCrosstalkData, path)
)
}
return (
conditionalMatch(megData, path) ||
conditionalMatch(megCalibrationData, path) ||
conditionalMatch(megCrosstalkData, path)
)
},
isNIRS: function (path) {
return conditionalMatch(nirsData, path)
},

isEEG: function (path) {
if (bids_schema) {
return bids_schema.datatypes['eeg'].some((regex) => regex.exec(path))
} else {
return conditionalMatch(eegData, path)
}
return conditionalMatch(eegData, path)
},

isIEEG: function (path) {
if (bids_schema) {
return bids_schema.datatypes['ieeg'].some((regex) => regex.exec(path))
} else {
return conditionalMatch(ieegData, path)
}
return conditionalMatch(ieegData, path)
},

isMOTION: function (path) {
if (bids_schema) {
// Motion not currently in schema
// return bids_schema.datatypes['motion'].some(regex => regex.exec(path))
return conditionalMatch(motion, path)
} else {
return conditionalMatch(motion, path)
}
return conditionalMatch(motion, path)
},

isMicroscopy: function (path) {
Expand All @@ -414,11 +342,7 @@ export default {
},

isBehavioral: function (path) {
if (bids_schema) {
return bids_schema.datatypes['beh'].some((regex) => regex.exec(path))
} else {
return conditionalMatch(behavioralData, path)
}
return conditionalMatch(behavioralData, path)
},

isFuncBold: function (path) {
Expand Down Expand Up @@ -479,9 +403,6 @@ export default {

return values
},

// CommonJS default export
schemaSetup,
}

function conditionalMatch(expression, path) {
Expand Down
4 changes: 2 additions & 2 deletions bids-validator/validators/bids/fullTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import collectModalities from '../../utils/summary/collectModalities'
* Takes on an array of files, callback, and boolean indicating if git-annex is used.
* Starts the validation process for a BIDS package.
*/
const fullTest = (fileList, options, annexed, dir, schema, callback) => {
const fullTest = (fileList, options, annexed, dir, callback) => {
const self = BIDS
self.options = options

Expand Down Expand Up @@ -64,7 +64,7 @@ const fullTest = (fileList, options, annexed, dir, schema, callback) => {
})
}

const summary = utils.collectSummary(fileList, self.options, schema)
const summary = utils.collectSummary(fileList, self.options)

// remove size redundancies
for (const key in fileList) {
Expand Down
10 changes: 1 addition & 9 deletions bids-validator/validators/bids/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import quickTest from './quickTest'
import quickTestError from './quickTestError'
import fullTest from './fullTest'
import utils from '../../utils'
import { schemaRegex } from '../../validators/schemaTypes'
import { schemaSetup } from '../../utils/type'

/**
* Start
Expand All @@ -31,17 +29,11 @@ const start = (dir, options, callback) => {
} else {
BIDS.options = options
reset(BIDS)
// Load the bids-spec schema ahead of any validation
let schema
if (options.schema) {
schema = await schemaRegex(options.schema)
schemaSetup(schema)
}
const files = await utils.files.readDir(dir, options)
if (quickTest(files)) {
// Is the dir using git-annex?
const annexed = utils.files.remoteFiles.isGitAnnex(dir)
fullTest(files, BIDS.options, annexed, dir, schema, callback)
fullTest(files, BIDS.options, annexed, dir, callback)
} else {
// Return an error immediately if quickTest fails
const issue = quickTestError(dir)
Expand Down
7 changes: 0 additions & 7 deletions bids-validator/validators/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ export function parseOptions(argumentOverride) {
'A less accurate check that reads filenames one per line from stdin.',
)
.hide('filenames')
.option('schema', {
alias: 's',
describe:
'BIDS specification schema version to use for validation, e.g. "v1.6.0" (beta)',
default: 'disable',
choices: ['disable', 'v1.6.0', 'v1.7.0', 'master'],
})
.epilogue(
'This tool checks if a dataset in a given directory is \
compatible with the Brain Imaging Data Structure specification. To learn \
Expand Down
Loading
Loading