From 087b6a295cd1771061fefafcddbb775749637c5a Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 25 Apr 2024 21:11:40 -0400 Subject: [PATCH] feat: Accept phenotype as a pseudo-datatype --- .../src/validators/filenameIdentify.ts | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/bids-validator/src/validators/filenameIdentify.ts b/bids-validator/src/validators/filenameIdentify.ts index c3a0ac060..e19754205 100644 --- a/bids-validator/src/validators/filenameIdentify.ts +++ b/bids-validator/src/validators/filenameIdentify.ts @@ -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