Skip to content

Commit

Permalink
Add events2bids datatypes and drop the template test for missing suff…
Browse files Browse the repository at this point in the history
…ixes (maybe fix this later)
  • Loading branch information
marcelzwiers committed Oct 30, 2024
1 parent bd36733 commit aec8b47
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 45 deletions.
4 changes: 2 additions & 2 deletions bidscoin/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -1341,8 +1341,8 @@ def check_template(self) -> bool:
'[DEPRECATED]' in bidsschema.objects.suffixes[suffix].description or
'**Change:** Removed from' in bidsschema.objects.suffixes[suffix].description or
'**Change:** Replaced by' in bidsschema.objects.suffixes[suffix].description):
LOGGER.warning(f"Missing '{suffix}' run-item in: bidsmap[{dataformat}][{datatype}] (NB: this may perhaps be fine / a deprecated item)")
valid = False
LOGGER.info(f"Missing '{suffix}' run-item in: bidsmap[{dataformat}][{datatype}] (NB: this may perhaps be fine / a deprecated item)")
# valid = False # TODO: Fix this for sparse events2bids mappings

# Validate against the json schema
with (templatefolder/'schema.json').open('r') as stream:
Expand Down
81 changes: 42 additions & 39 deletions bidscoin/heuristics/bidsmap_dccn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,6 @@ DICOM:
<<: *func_dicoment_func
suffix: cbv
meta: *func_meta
- attributes: *func_dicomattr
bids: &func_dicoment_events # See: schema/rules/files/raw/func.yaml
task: <SeriesDescription> # NB: <ProtocolName> is consistent between SBREF and PHYSIO files but causes name clashes
acq:
ce:
dir:
rec:
run: <<>>
chunk:
suffix: events
meta:
TaskName: <SeriesDescription>
- attributes: *func_dicomattr
bids:
<<: *func_dicoment_timeseries
Expand Down Expand Up @@ -900,11 +888,6 @@ DICOM:
InjectionStart: <<ContrastBolusStartTime>>
FrameDuration: <<ActualFrameDuration>>
Units:
- attributes: *pet_dicomattr
bids:
<<: *pet_dicoment_pet
suffix: events
meta: *pet_meta
- attributes: *pet_dicomattr
bids:
<<: *pet_dicoment_pet
Expand Down Expand Up @@ -1026,20 +1009,14 @@ Presentation:
subject: <<filepath:/sub-(.*?)/>> # This filesystem property extracts the subject label from the source directory. NB: Any property or attribute can be used as subject-label, e.g. <PatientID>
session: <<filepath:/sub-.*?/ses-(.*?)/>> # This filesystem property extracts the subject label from the source directory. NB: Any property or attribute can be used as session-label, e.g. <StudyID>

func: # ----------------------- All functional runs --------------------
beh: # ----------------------- All behavioural runs -------------------
- attributes: &presentationent_attr
Scenario:
bids: &presentationent_func # See: schema/rules/files/raw/func.yaml
task: <Scenario>
acq:
ce:
dir:
rec:
run: <<>>
echo:
part: ['', mag, phase, real, imag, 0]
chunk:
suffix: bold
suffix: events
meta: &presentation_func_meta
TaskName:
TaskDescription:
Expand All @@ -1061,13 +1038,51 @@ Presentation:
cols: ['Time', 'TTime', 'Uncertainty', 'Duration', 'ReqTime', 'ReqDur']
unit: 10000
start:
Code: 10 # Code with which the first (or any) pulse is logged
Code: 10 # Code with which the first (or any) pulse is logged

eeg: # ----------------------- All EEG runs ---------------------------
- attributes: *presentationent_attr
bids: *presentationent_func
meta: *presentation_func_meta
events: *presentation_events

ieeg: # ----------------------- All iEEG runs --------------------------
- attributes: *presentationent_attr
bids: *presentationent_func
meta: *presentation_func_meta
events: *presentation_events

meg: # ----------------------- All MEG runs ---------------------------
- attributes: *presentationent_attr
bids: *presentationent_func
meta: *presentation_func_meta
events: *presentation_events

nirs: # ----------------------- All nirs runs --------------------------
- attributes: *presentationent_attr
bids: *presentationent_func
meta: *presentation_func_meta
events: *presentation_events

func: # ----------------------- All functional runs --------------------
- attributes: *presentationent_attr
bids:
<<: *presentationent_func
ce:
dir:
rec:
meta: *presentation_func_meta
events: *presentation_events
- properties:
filename: (?i).*(f.?MRI|task|BOLD|func|rest|task|RSN|CMRR.*_TR).*
attributes:
<<: *presentationent_attr
Scenario: .*
bids: *presentationent_func
bids:
<<: *presentationent_func
ce:
dir:
rec:
meta: *presentation_func_meta
events: *presentation_events

Expand Down Expand Up @@ -1435,18 +1450,6 @@ PAR:
<<: *func_parent_func
mod:
suffix: noRF
- attributes: *func_parattr
bids: &func_parent_events # See: schema/rules/files/raw/func.yaml
task: <exam_name>
acq: <protocol_name>
ce:
dir:
rec:
run: <<>>
chunk:
suffix: events
meta:
TaskName: <exam_name>
- attributes: *func_parattr
bids: &func_parent_timeseries # See: schema/rules/files/raw/func.yaml
task: <exam_name>
Expand Down
8 changes: 4 additions & 4 deletions tests/test_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ def test_check_templates(self):
bidsmap.dataformats[0].remove_datatype('foo')
assert bidsmap.check_template() is True

# Remove a valid suffix (BIDS-entity)
valid_run = bidsmap.dataformats[0].datatype('anat').runitems[-2].provenance # NB: [-2] -> The first item(s) can be non-unique, the last item can be a non-BIDS entity, i.e. CT
bidsmap.dataformats[0].datatype('anat').delete_run(valid_run)
assert bidsmap.check_template() is False
# # Remove a valid suffix (BIDS-entity)
# valid_run = bidsmap.dataformats[0].datatype('anat').runitems[-2].provenance # NB: [-2] -> The first item(s) can be non-unique, the last item can be a non-BIDS entity, i.e. CT
# bidsmap.dataformats[0].datatype('anat').delete_run(valid_run)
# assert bidsmap.check_template() is False

def test_dataformat(self):
pass
Expand Down

0 comments on commit aec8b47

Please sign in to comment.