Skip to content

Commit

Permalink
[FIX] Add qMRI fmap filename rules and reorganize fmap patterns (#1183)
Browse files Browse the repository at this point in the history
* Model field map patterns on schema.

* Add nii versions.

* Update bids-validator/utils/type.js

Co-authored-by: Chris Markiewicz <effigies@gmail.com>

* Apply suggestions from code review

Co-authored-by: Chris Markiewicz <effigies@gmail.com>

* Update bids-validator/bids_validator/rules/file_level_rules.json

* Update bids-validator/utils/type.js

Co-authored-by: Chris Markiewicz <effigies@gmail.com>
  • Loading branch information
tsalo and effigies authored Feb 10, 2021
1 parent 49810ac commit c1ad282
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
39 changes: 27 additions & 12 deletions bids-validator/bids_validator/rules/file_level_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@
}
},

"field_map": {
"regexp": "^[\\/\\\\](sub-[a-zA-Z0-9]+)[\\/\\\\](?:(ses-[a-zA-Z0-9]+)[\\/\\\\])?fmap[\\/\\\\]\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_dir-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_field_map_type_@@@)\\.(@@@_field_map_ext_@@@)$",
"fmap_gre": {
"regexp": "^[\\/\\\\](sub-[a-zA-Z0-9]+)[\\/\\\\](?:(ses-[a-zA-Z0-9]+)[\\/\\\\])?fmap[\\/\\\\]\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_field_map_type_@@@)\\.(@@@_field_map_ext_@@@)$",
"tokens": {
"@@@_field_map_type_@@@": [
"phasediff",
Expand All @@ -208,25 +208,40 @@
"magnitude1",
"magnitude2",
"magnitude",
"fieldmap",
"epi",
"m0scan"
"fieldmap"
],
"@@@_field_map_ext_@@@": ["nii\\.gz", "nii", "json"]
}
},

"field_map_main_nii": {
"regexp": "^[\\/\\\\](sub-[a-zA-Z0-9]+)[\\/\\\\](?:(ses-[a-zA-Z0-9]+)[\\/\\\\])?fmap[\\/\\\\]\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)?(?:_dir-[a-zA-Z0-9]+)?(?:_run-[0-9]+)?_(?:@@@_field_map_type_@@@)\\.(@@@_field_map_ext_@@@)$",
"fmap_pepolar_asl": {
"regexp": "^[\\/\\\\](sub-[a-zA-Z0-9]+)[\\/\\\\](?:(ses-[a-zA-Z0-9]+)[\\/\\\\])?fmap[\\/\\\\]\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_ce-[a-zA-Z0-9]+)?_dir-[a-zA-Z0-9]+(?:_run-[0-9]+)?_(?:@@@_field_map_type_@@@)\\.(@@@_field_map_ext_@@@)$",
"tokens": {
"@@@_field_map_type_@@@": [
"phasediff",
"phase1",
"phase2",
"fieldmap",
"m0scan",
"epi"
],
"@@@_field_map_ext_@@@": ["nii\\.gz", "nii"]
"@@@_field_map_ext_@@@": ["nii\\.gz", "nii", "json"]
}
},

"fmap_TB1DAM": {
"regexp": "^[\\/\\\\](sub-[a-zA-Z0-9]+)[\\/\\\\](?:(ses-[a-zA-Z0-9]+)[\\/\\\\])?fmap[\\/\\\\]\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_ce-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)(?:_run-[0-9]+)?_flip-[0-9]+?(?:_part-(imag|mag|phase|real))?_(?:@@@_field_map_type_@@@)\\.(@@@_field_map_ext_@@@)$",
"tokens": {
"@@@_field_map_type_@@@": [
"TB1DAM"
],
"@@@_field_map_ext_@@@": ["nii\\.gz", "nii", "json"]
}
},

"fmap_TB1EPI": {
"regexp": "^[\\/\\\\](sub-[a-zA-Z0-9]+)[\\/\\\\](?:(ses-[a-zA-Z0-9]+)[\\/\\\\])?fmap[\\/\\\\]\\1(_\\2)?(?:_acq-[a-zA-Z0-9]+)?(?:_ce-[a-zA-Z0-9]+)?(?:_rec-[a-zA-Z0-9]+)(?:_run-[0-9]+)?_echo-[0-9]+?_flip-[0-9]+?(?:_part-(imag|mag|phase|real))?_(?:@@@_field_map_type_@@@)\\.(@@@_field_map_ext_@@@)$",
"tokens": {
"@@@_field_map_type_@@@": [
"TB1EPI"
],
"@@@_field_map_ext_@@@": ["nii\\.gz", "nii", "json"]
}
},

Expand Down
22 changes: 18 additions & 4 deletions bids-validator/utils/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ const anatMTR = buildRegExp(file_level_rules.anat_mtr)
const behavioralData = buildRegExp(file_level_rules.behavioral)
const dwiData = buildRegExp(file_level_rules.dwi)
const eegData = buildRegExp(file_level_rules.eeg)
const fieldmapData = buildRegExp(file_level_rules.field_map)
const fieldmapMainNiiData = buildRegExp(file_level_rules.field_map_main_nii)
const fmapGre = buildRegExp(file_level_rules.fmap_gre)
const fmapPepolarAsl = buildRegExp(file_level_rules.fmap_pepolar_asl)
const fmapTB1DAM = buildRegExp(file_level_rules.fmap_TB1DAM)
const fmapTB1EPI = buildRegExp(file_level_rules.fmap_TB1EPI)
const func = buildRegExp(file_level_rules.func)
const funcPhaseDeprecated = buildRegExp(file_level_rules.func_phase_deprecated)
const funcEvents = buildRegExp(file_level_rules.func_events)
Expand Down Expand Up @@ -206,11 +208,23 @@ export default {
* Check if the file has a name appropriate for a fieldmap scan
*/
isFieldMap: function(path) {
return conditionalMatch(fieldmapData, path)
return (
conditionalMatch(fmapGre, path) ||
conditionalMatch(fmapPepolarAsl, path) ||
conditionalMatch(fmapTB1DAM, path) ||
conditionalMatch(fmapTB1EPI, path)
)
},

isFieldMapMainNii: function(path) {
return conditionalMatch(fieldmapMainNiiData, path)
return (
!path.endsWith('.json') &&
/* isFieldMap */
(conditionalMatch(fmapGre, path) ||
conditionalMatch(fmapPepolarAsl, path) ||
conditionalMatch(fmapTB1DAM, path) ||
conditionalMatch(fmapTB1EPI, path))
)
},

/**
Expand Down

0 comments on commit c1ad282

Please sign in to comment.