Skip to content

Commit

Permalink
Add fNIRS support
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-luke committed Jan 31, 2022
1 parent 4feb91b commit 1c9e6e3
Show file tree
Hide file tree
Showing 12 changed files with 1,518 additions and 1,273 deletions.
18 changes: 18 additions & 0 deletions bids-validator/bids_validator/rules/file_level_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,24 @@
"regexp": "^[\\/\\\\](?:stimuli)[\\/\\\\](?:.*)$"
},

"nirs": {
"regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?nirs\\/\\1(_\\2)?(?:_task-[a-zA-Z0-9]+)?(?:_acq-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:_part-[0-9]+)?(_nirs\\.(@@@_nirs_type_@@@)|(@@@_nirs_ext_@@@))$",
"tokens": {
"@@@_nirs_type_@@@": ["snirf"],
"@@@_nirs_ext_@@@": [
"_events\\.json",
"_events\\.tsv",
"_optodes\\.json",
"_optodes\\.tsv",
"_channels\\.json",
"_channels\\.tsv",
"_nirs\\.json",
"_coordsystem\\.json",
"_photo\\.jpg"
]
}
},

"pet": {
"regexp": "^[\\/\\\\](sub-[a-zA-Z0-9]+)[\\/\\\\](?:(ses-[a-zA-Z0-9]+)[\\/\\\\])?pet[\\/\\\\](sub-[a-zA-Z0-9]+)(?:(_ses-[a-zA-Z0-9]+))?(?:_task-[a-zA-Z0-9]+)?(?:_trc-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(@@@_pet_ext_@@@)$",
"tokens": {
Expand Down
14 changes: 14 additions & 0 deletions bids-validator/bids_validator/rules/session_level_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,19 @@
"_SPIM.json"
]
}
},

"nirs_ses": {
"regexp": "^\\/(sub-[a-zA-Z0-9]+)\\/(?:(ses-[a-zA-Z0-9]+)\\/)?\\1(_\\2)?(?:_task-[a-zA-Z0-9]+)?(?:_acq-[a-zA-Z0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(@@@_nirs_ses_type_@@@)$",
"tokens": {
"@@@_nirs_ses_type_@@@": [
"_events.tsv",
"_channels.tsv",
"_optodes.tsv",
"_nirs.json",
"_coordsystem.json",
"_photo.jpg"
]
}
}
}
5 changes: 4 additions & 1 deletion bids-validator/bids_validator/rules/subject_level_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"subject_level": {
"regexp": "^[\\/\\\\](sub-[a-zA-Z0-9]+)[\\/\\\\]\\1(@@@_subject_level_ext_@@@)$",
"tokens": {
"@@@_subject_level_ext_@@@": ["_sessions\\.tsv", "_sessions\\.json"]
"@@@_subject_level_ext_@@@": [
"_sessions\\.tsv",
"_sessions\\.json"
]
}
}
}
17 changes: 17 additions & 0 deletions bids-validator/bids_validator/rules/top_level_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,23 @@
]
}
},
"nirs_top": {
"regexp": "^\\/(?:ses-[a-zA-Z0-9]+_)?task-[a-zA-Z0-9]+(?:_acq-[a-zA-Z0-9]+)?(?:_proc-[a-zA-Z0-9]+)?(?:@@@_nirs_top_ext_@@@)$",
"tokens": {
"@@@_nirs_top_ext_@@@": [
"_nirs\\.json",
"_channels\\.tsv",
"_optodes\\.tsv",
"_photo\\.jpg",
"_coordsystem\\.json"
]
}
"meg_calibration_top": {
"regexp": "^[\\/\\\\](?:(ses-[a-zA-Z0-9]+_)?)acq-calibration_meg\\.fif$"
},
"meg_crosstalk_top": {
"regexp": "^[\\/\\\\](?:(ses-[a-zA-Z0-9]+_)?)acq-crosstalk_meg\\.dat$"
},
"multi_dir_fieldmap": {
"regexp": "^[\\/\\\\](?:acq-[a-zA-Z0-9]+_)?(?:dir-[a-zA-Z0-9]+_)epi\\.json$"
},
Expand Down
37 changes: 36 additions & 1 deletion bids-validator/bids_validator/tsv/non_custom_columns.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"low_cutoff",
"name",
"notch",
"source",
"detector",
"wavelength_actual",
"wavelength_nominal",
"wavelength_emission_actual",
"orientation_component",
"short_channel",
"sampling_frequency",
"software_filters",
"status",
Expand All @@ -28,6 +35,18 @@
"impedance",
"dimension"
],
"optodes": [
"name",
"type",
"x",
"y",
"z",
"template_x",
"template_y",
"template_z",
"source_type",
"detector_type"
],
"events": [
"duration",
"HED",
Expand All @@ -44,5 +63,21 @@
"scans": ["acq_time", "filename"],
"sessions": ["acq_time", "session_id"],
"aslcontext": ["volume_type"],
"blood": ["time", "plasma_radioactivity", "whole_blood_radioactivity", "metabolite_parent_fraction", "hplc_recovery_fractions"]
"blood": ["time", "plasma_radioactivity", "whole_blood_radioactivity", "metabolite_parent_fraction", "hplc_recovery_fractions"],
"nirs": [
"name",
"type",
"source",
"detector",
"wavelength_nominal",
"units",
"sampling_frequency",
"orientation_component",
"wavelength_actual",
"description",
"wavelength_emission_actual",
"short_channel",
"status",
"status_description"
]
}
15 changes: 15 additions & 0 deletions bids-validator/utils/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const petBlood = buildRegExp(file_level_rules.pet_blood)
const microscopyData = buildRegExp(file_level_rules.microscopy)
const microscopyPhotoData = buildRegExp(file_level_rules.microscopy_photo)
const microscopyJSON = buildRegExp(file_level_rules.microscopy_json)
const nirsData = buildRegExp(file_level_rules.nirs)
// Phenotypic data
const phenotypicData = buildRegExp(phenotypic_rules.phenotypic_data)
// Session level
Expand All @@ -75,6 +76,7 @@ const megSes = buildRegExp(session_level_rules.meg_ses)
const scansSes = buildRegExp(session_level_rules.scans)
const petSes = buildRegExp(session_level_rules.pet_ses)
const microscopySes = buildRegExp(session_level_rules.microscopy_ses)
const nirsSes = buildRegExp(session_level_rules.nirs_ses)
// Subject level
const subjectLevel = buildRegExp(subject_level_rules.subject_level)
// Top level
Expand All @@ -90,6 +92,7 @@ const otherTopFiles = buildRegExp(top_level_rules.other_top_files)
const megTop = buildRegExp(top_level_rules.meg_top)
const petTop = buildRegExp(top_level_rules.pet_top)
const microscopyTop = buildRegExp(top_level_rules.microscopy_top)
const nirsTop = buildRegExp(top_level_rules.nirs_top)

export default {
/**
Expand All @@ -109,6 +112,7 @@ export default {
this.file.isFunc(path) ||
this.file.isAsl(path) ||
this.file.isMeg(path) ||
this.file.isNIRS(path) ||
this.file.isIEEG(path) ||
this.file.isEEG(path) ||
this.file.isBehavioral(path) ||
Expand All @@ -118,6 +122,7 @@ export default {
this.file.isPETBlood(path) ||
this.file.isMicroscopy(path) ||
this.file.isMicroscopyJSON(path)

)
},

Expand All @@ -142,6 +147,7 @@ export default {
eegTop.test(path) ||
ieegTop.test(path) ||
petTop.test(path) ||
nirsTop.test(path) ||
microscopyTop.test(path)
)
} else {
Expand All @@ -157,6 +163,7 @@ export default {
eegTop.test(path) ||
ieegTop.test(path) ||
petTop.test(path) ||
nirsTop.test(path) ||
microscopyTop.test(path)
)
}
Expand Down Expand Up @@ -210,6 +217,9 @@ export default {
conditionalMatch(anatSes, path) ||
conditionalMatch(dwiSes, path) ||
conditionalMatch(megSes, path) ||
conditionalMatch(nirsSes, path) ||
conditionalMatch(megCalibrationSes, path) ||
conditionalMatch(megCrosstalkSes, path) ||
conditionalMatch(eegSes, path) ||
conditionalMatch(ieegSes, path) ||
conditionalMatch(petSes, path) ||
Expand Down Expand Up @@ -333,6 +343,10 @@ export default {
}
},

isNIRS: function(path) {
return conditionalMatch(nirsData, path)
},

isEEG: function(path) {
if (bids_schema) {
return bids_schema.datatypes['eeg'].some(regex => regex.exec(path))
Expand Down Expand Up @@ -381,6 +395,7 @@ export default {
this.isFunc(path) ||
this.isAsl(path) ||
this.isMeg(path) ||
this.isNIRS(path) ||
this.isEEG(path) ||
this.isIEEG(path) ||
this.isBehavioral(path) ||
Expand Down
6 changes: 6 additions & 0 deletions bids-validator/validators/json/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ const selectSchema = file => {
schema = require('./schemas/asl.json')
} else if (file.name.endsWith('pet.json')) {
schema = require('./schemas/pet.json')
} else if (file.name.endsWith('nirs.json')) {
schema = require('./schemas/nirs.json')
} else if (file.relativePath === '/dataset_description.json') {
schema = require('./schemas/dataset_description.json')
} else if (file.name.endsWith('meg.json')) {
Expand Down Expand Up @@ -131,6 +133,10 @@ const selectSchema = file => {
file.name.endsWith('coordsystem.json')
) {
schema = require('./schemas/coordsystem_eeg.json')
} else if (file.name.endsWith('pet.json')) {
schema = require('./schemas/pet.json')
} else if (file.name.endsWith('genetic_info.json')) {
schema = require('./schemas/genetic_info.json')
} else if (
file.relativePath.includes('/pet/') &&
file.name.endsWith('blood.json')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
"DeviceSerialNumber": { "type": "string" },
"ECGChannelCount": { "type": "integer", "minimum": 0 },
"EEGChannelCount": { "type": "integer", "minimum": 0 },
"NIRSChannelCount": { "type": "integer", "minimum": 0 },
"NIRSSourceOptodeCount": { "type": "integer", "minimum": 0 },
"NIRSDetectorOptodeCount": { "type": "integer", "minimum": 0 },
"EMGChannelCount": { "type": "integer", "minimum": 0 },
"EOGChannelCount": { "type": "integer", "minimum": 0 },
"EpochLength": { "type": "number", "minimum": 0 },
Expand Down
105 changes: 105 additions & 0 deletions bids-validator/validators/json/schemas/nirs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"type": "object",
"properties": {
"TaskName": { "$ref": "common_definitions.json#/definitions/TaskName" },
"TaskDescription": {
"$ref": "common_definitions.json#/definitions/TaskDescription"
},
"Instructions": {
"$ref": "common_definitions.json#/definitions/Instructions"
},
"CogAtlasID": { "$ref": "common_definitions.json#/definitions/CogAtlasID" },
"CogPOID": { "$ref": "common_definitions.json#/definitions/CogPOID" },
"InstitutionName": {
"$ref": "common_definitions.json#/definitions/InstitutionName"
},
"InstitutionalDepartmentName": { "type": "string" },
"InstitutionAddress": {
"$ref": "common_definitions.json#/definitions/InstitutionAddress"
},
"Manufacturer": {
"$ref": "common_definitions.json#/definitions/Manufacturer"
},
"ManufacturersModelName": { "type": "string", "minLength": 1 },
"DeviceSerialNumber": {
"$ref": "common_definitions.json#/definitions/DeviceSerialNumber"
},
"SoftwareVersions": {
"$ref": "common_definitions.json#/definitions/SoftwareVersions"
},
"PowerLineFrequency": {
"$ref": "common_definitions.json#/definitions/PowerLineFrequency"
},
"SamplingFrequency": {
"anyOf": [
{ "$ref": "common_definitions.json#/definitions/SamplingFrequency" },
{ "enum": ["n/a"] }
]
},
"NIRSChannelCount": {
"$ref": "common_definitions.json#/definitions/NIRSChannelCount"
},
"NIRSSourceOptodeCount": {
"$ref": "common_definitions.json#/definitions/NIRSSourceOptodeCount"
},
"NIRSDetectorOptodeCount": {
"$ref": "common_definitions.json#/definitions/NIRSDetectorOptodeCount"
},
"EEGChannelCount": {
"$ref": "common_definitions.json#/definitions/EEGChannelCount"
},
"EOGChannelCount": {
"$ref": "common_definitions.json#/definitions/EOGChannelCount"
},
"ECGChannelCount": {
"$ref": "common_definitions.json#/definitions/ECGChannelCount"
},
"EMGChannelCount": {
"$ref": "common_definitions.json#/definitions/EMGChannelCount"
},
"MiscChannelCount": {
"$ref": "common_definitions.json#/definitions/MiscChannelCount"
},
"TriggerChannelCount": {
"$ref": "common_definitions.json#/definitions/TriggerChannelCount"
},
"NIRSPlacementScheme": { "type": "string" },
"CapManufacturer": { "type": "string" },
"CapManufacturersModelName": { "type": "string" },
"HeadCircumference": { "type": "number", "exclusiveMinimum": 0 },
"ShortChannelCount": {
"type": "number",
"exclusiveMinimum": 0,
"recommends_tsv_non_custom_columns": ["short_channel"]
},
"HardwareFilters": {
"$ref": "common_definitions.json#/definitions/HardwareFilters"
},
"SoftwareFilters": {
"$ref": "common_definitions.json#/definitions/SoftwareFilters"
},
"RecordingDuration": {
"$ref": "common_definitions.json#/definitions/RecordingDuration"
},
"RecordingType": {
"$ref": "common_definitions.json#/definitions/RecordingType"
},
"SubjectArtefactDescription": { "type": "string" },
"ACCELChannelCount": { "type": "number" },
"GYROChannelCount": { "type": "number" },
"MAGNChannelCount": { "type": "number" }
},
"required": [
"TaskName",
"SamplingFrequency",
"NIRSChannelCount",
"NIRSSourceOptodeCount",
"NIRSDetectorOptodeCount"
],
"required_if_tsv_value_present": {
"ACCELChannelCount": { "header": "type", "value": "ACC" },
"MAGNChannelCount": { "header": "type", "value": "MAGN" },
"GYROChannelCount": { "header": "type", "value": "GYRO" }
},
"additionalProperties": false
}
Loading

0 comments on commit 1c9e6e3

Please sign in to comment.