Skip to content

Commit

Permalink
Merge pull request #1053 from sappelhoff/crosstalk
Browse files Browse the repository at this point in the history
Extend validator for crosstalk+finecalib for FIF
  • Loading branch information
rwblair authored Sep 8, 2020
2 parents 6d5f570 + e21d94d commit a6d9ada
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ bids-validator-web/.next/
# Only use global yarn.lock
bids-validator/yarn.lock
bids-validator-web/yarn.lock

.vscode/
8 changes: 8 additions & 0 deletions bids-validator/bids_validator/rules/file_level_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@
}
},

"meg_calbibration": {
"regexp": "^[\\/\\\\](sub-[a-zA-Z0-9]+)[\\/\\\\](?:(ses-[a-zA-Z0-9]+)[\\/\\\\])?meg[\\/]\\1(_\\2)?_acq-calibration_meg\\.fif$"
},

"meg_crosstalk": {
"regexp": "^[\\/\\\\](sub-[a-zA-Z0-9]+)[\\/\\\\](?:(ses-[a-zA-Z0-9]+)[\\/\\\\])?meg[\\/]\\1(_\\2)?_acq-crosstalk_meg\\.dat$"
},

"stimuli": {
"regexp": "^[\\/\\\\](?:stimuli)[\\/\\\\](?:.*)$"
}
Expand Down
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"
]
}
}
}
1 change: 0 additions & 1 deletion bids-validator/bids_validator/rules/top_level_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
"multi_dir_fieldmap": {
"regexp": "^[\\/\\\\](?:acq-[a-zA-Z0-9]+_)?(?:dir-[a-zA-Z0-9]+_)epi\\.json$"
},

"other_top_files": {
"regexp": "^[\\/\\\\](?:ses-[a-zA-Z0-9]+_)?(?:recording-[a-zA-Z0-9]+_)?(?:task-[a-zA-Z0-9]+_)?(?:acq-[a-zA-Z0-9]+_)?(?:rec-[a-zA-Z0-9]+_)?(?:run-[0-9]+_)?(@@@_other_top_files_ext_@@@)$",
"tokens": {
Expand Down
50 changes: 50 additions & 0 deletions bids-validator/tests/type.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ describe('utils.type.file.isTopLevel', function() {
'/_T1w.json',
'/_dwi.json',
'/_task-test_physio.json',
// cross-talk and fine-calibration files for Neuromag/Elekta/MEGIN data (.fif)
// must be defined at file level.
'/acq-calibration_meg.fif',
'/acq-crosstalk_meg.dat',
]

badFilenames.forEach(function(path) {
Expand All @@ -118,6 +122,37 @@ describe('utils.type.file.isTopLevel', function() {
})
})

describe('utils.type.file.isSubjectLevel', () => {
const goodFilenames = [] // to be extended in the future...

goodFilenames.forEach(path => {
it("isSubjectLevel('" + path + "') === true", function(isdone) {
assert.equal(utils.type.file.isSubjectLevel(path), true)
isdone()
})
})

const badFilenames = [
// cross-talk and fine-calibration files for Neuromag/Elekta/MEGIN data (.fif)
// must be placed on file level.
'/sub-12/sub-12_acq-calibration_meg.fif',
'/sub-12/sub-12_acq-crosstalk_meg.dat',
'/sub-12/sub-12_acq-calibration_meg.dat',
'/sub-12/sub-12_acq-crosstalk_meg.fif',
'/sub-12/acq-calibration_meg.fif',
'/sub-12/acq-crosstalk_meg.dat',
'/sub-12/acq-calibration.fif',
'/sub-12/acq-crosstalk.dat',
]

badFilenames.forEach(path => {
it("isSubjectLevel('" + path + "') === false", function(isdone) {
assert.equal(utils.type.file.isSubjectLevel(path), false)
isdone()
})
})
})

describe('utils.type.file.isSessionLevel', function() {
const goodFilenames = [
'/sub-12/sub-12_scans.tsv',
Expand All @@ -136,6 +171,12 @@ describe('utils.type.file.isSessionLevel', function() {
const badFilenames = [
'/sub-12/sub-12.tsv',
'/sub-12/ses-pre/sub-12_ses-pre_scan.tsv',
// cross-talk and fine-calibration files for Neuromag/Elekta/MEGIN data (.fif)
// must be placed at file level.
'/sub-12/sub-12_acq-calibration_meg.fif',
'/sub-12/sub-12_acq-crosstalk_meg.dat',
'/sub-12/ses-pre/sub-12_ses-pre_acq-calibration_meg.fif',
'/sub-12/ses-pre/sub-12_ses-pre_acq-crosstalk_meg.dat',
]

badFilenames.forEach(function(path) {
Expand Down Expand Up @@ -206,6 +247,11 @@ describe('utils.type.file.isMEG', function() {
// NO father dir: fif data
'/sub-01/ses-001/meg/sub-01_ses-001_task-rest_run-01_split-01_meg.fif',
'/sub-01/ses-001/meg/sub-01_ses-001_task-rest_acq-TEST_run-01_split-01_meg.fif',
// cross-talk and fine-calibration files for Neuromag/Elekta/MEGIN data (.fif)
'/sub-01/meg/sub-01_acq-calibration_meg.fif',
'/sub-01/meg/sub-01_acq-crosstalk_meg.dat',
'/sub-01/ses-001/meg/sub-01_ses-001_acq-calibration_meg.fif',
'/sub-01/ses-001/meg/sub-01_ses-001_acq-crosstalk_meg.dat',
]

goodFilenames.forEach(function(path) {
Expand Down Expand Up @@ -241,6 +287,10 @@ describe('utils.type.file.isMEG', function() {
'/sub-01/ses-001/meg/sub-01_ses-001_task-rest_run-01_meg/sub-01_ses-001_task-rest_run-01_meg.kdf',
'/sub-01/ses-001/meg/sub-01_ses-001_task-rest_run-01_meg/sub-01_ses-001_task-rest_run-01_meg.trg',
'/sub-01/ses-001/meg/sub-01_ses-001_task-rest_run-01_meg/sub-01_ses-001_task-rest_run-01_meg.chn',
// cross-talk and fine-calibration files for Neuromag/Elekta/MEGIN data (.fif)
// .dat in MEG only allowed for "acq-crosstalk"
'/acq-notcrosstalk_meg.dat',
'/sub-01/ses-001/meg/sub-01_ses-001_acq-notcrosstalk_meg.dat',
]

badFilenames.forEach(function(path) {
Expand Down
8 changes: 7 additions & 1 deletion bids-validator/utils/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const funcData = buildRegExp(file_level_rules.func)
const funcBoldData = buildRegExp(file_level_rules.func_bold)
const ieegData = buildRegExp(file_level_rules.ieeg)
const megData = buildRegExp(file_level_rules.meg)
const megCalibrationData = buildRegExp(file_level_rules.meg_calbibration)
const megCrosstalkData = buildRegExp(file_level_rules.meg_crosstalk)
const stimuliData = buildRegExp(file_level_rules.stimuli)
// Phenotypic data
const phenotypicData = buildRegExp(phenotypic_rules.phenotypic_data)
Expand Down Expand Up @@ -196,7 +198,11 @@ export default {
},

isMeg: function(path) {
return conditionalMatch(megData, path)
return (
conditionalMatch(megData, path) ||
conditionalMatch(megCalibrationData, path) ||
conditionalMatch(megCrosstalkData, path)
)
},

isEEG: function(path) {
Expand Down

0 comments on commit a6d9ada

Please sign in to comment.