Skip to content

Commit

Permalink
feat: Accept phenotype as a pseudo-datatype
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed May 23, 2024
1 parent 722ecad commit 2e84f81
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions bids-validator/src/validators/filenameIdentify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,18 @@ export function _findRuleMatches(node, path, context) {

export async function datatypeFromDirectory(schema, context) {
const subEntity = schema.objects.entities.subject.name
const subFormat = schema.objects.formats[subEntity.format]
const sesEntity = schema.objects.entities.session.name
const sesFormat = schema.objects.formats[sesEntity.format]
const parts = context.file.path.split(SEPARATOR)
let datatypeIndex = 2
if (parts[0] !== '') {
// we assume paths have leading '/'
}
// Ignoring associated data for now
const subParts = parts[1].split('-')
if (!(subParts.length === 2 && subParts[0] === subEntity)) {
// first directory must be subject
}
if (parts.length < 3) {
let datatypeIndex = parts.length - 2
if (datatypeIndex < 1) {
return Promise.resolve()
}
const sesParts = parts[2].split('-')
if (sesParts.length === 2 && sesParts[0] === sesEntity) {
datatypeIndex = 3
}
const dirDatatype = parts[datatypeIndex]
if (dirDatatype === 'phenotype') {
// Phenotype is a pseudo-datatype for now.
context.datatype = dirDatatype
return Promise.resolve()
}
for (let key in schema.rules.modalities) {
if (schema.rules.modalities[key].datatypes.includes(dirDatatype)) {
context.modality = key
Expand Down

0 comments on commit 2e84f81

Please sign in to comment.