Skip to content

Commit 9d71585

Browse files
committed
chore: Remove outdated datatype/modality code
1 parent ebbaaa8 commit 9d71585

File tree

3 files changed

+1
-60
lines changed

3 files changed

+1
-60
lines changed

src/schema/modalities.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/validators/filenameIdentify.test.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { assertEquals } from '@std/assert'
22
import { SEPARATOR_PATTERN } from '@std/path'
33
import { BIDSContext } from '../schema/context.ts'
4-
import {
5-
_findRuleMatches,
6-
datatypeFromDirectory,
7-
findDirRuleMatches,
8-
hasMatch,
9-
} from './filenameIdentify.ts'
4+
import { _findRuleMatches, findDirRuleMatches, hasMatch } from './filenameIdentify.ts'
105
import { BIDSFileDeno } from '../files/deno.ts'
116
import { FileIgnoreRules } from '../files/ignore.ts'
127
import { loadSchema } from '../setup/loadSchema.ts'
@@ -50,19 +45,6 @@ Deno.test('test _findRuleMatches', async (t) => {
5045
)
5146
})
5247

53-
Deno.test('test datatypeFromDirectory', (t) => {
54-
const filesToTest = [
55-
['/sub-01/ses-01/func/sub-01_ses-01_task-nback_run-01_bold.nii', 'func'],
56-
['/sub-01/ses-01/anat/sub-01_ses-01_T1w.nii', 'anat'],
57-
]
58-
filesToTest.map((test) => {
59-
const file = new BIDSFileDeno(PATH, test[0], ignore)
60-
const context = new BIDSContext(file)
61-
datatypeFromDirectory(schema, context)
62-
assertEquals(context.datatype, test[1])
63-
})
64-
})
65-
6648
Deno.test('test hasMatch', async (t) => {
6749
await t.step('hasMatch', async () => {
6850
const fileName = '/sub-01/ses-01/func/sub-01_ses-01_task-nback_run-01_bold.nii'

src/validators/filenameIdentify.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
import { globToRegExp, SEPARATOR_PATTERN } from '@std/path'
1616
import type { GenericSchema, Schema } from '../types/schema.ts'
1717
import type { BIDSContext } from '../schema/context.ts'
18-
import type { lookupModality } from '../schema/modalities.ts'
1918
import type { CheckFunction } from '../types/check.ts'
2019
import { lookupEntityLiteral } from './filenameValidate.ts'
2120

2221
const CHECKS: CheckFunction[] = [
23-
datatypeFromDirectory,
2422
findRuleMatches,
2523
hasMatch,
2624
cleanContext,
@@ -126,29 +124,6 @@ function matchStemRule(node, context): boolean {
126124
return true
127125
}
128126

129-
export async function datatypeFromDirectory(schema, context) {
130-
const subEntity = schema.objects.entities.subject.name
131-
const sesEntity = schema.objects.entities.session.name
132-
const parts = context.file.path.split(SEPARATOR_PATTERN)
133-
const datatypeIndex = parts.length - 2
134-
if (datatypeIndex < 1) {
135-
return Promise.resolve()
136-
}
137-
const dirDatatype = parts[datatypeIndex]
138-
if (dirDatatype === 'phenotype') {
139-
// Phenotype is a pseudo-datatype for now.
140-
context.datatype = dirDatatype
141-
return Promise.resolve()
142-
}
143-
for (const key in schema.rules.modalities) {
144-
if (schema.rules.modalities[key].datatypes.includes(dirDatatype)) {
145-
context.modality = key
146-
context.datatype = dirDatatype
147-
return Promise.resolve()
148-
}
149-
}
150-
}
151-
152127
export function hasMatch(schema, context) {
153128
if (
154129
context.filenameRules.length === 0 &&

0 commit comments

Comments
 (0)