From 3c720148eb9322f22255a872db4d2f713dc9cf6d Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 18 May 2023 16:29:53 -0400 Subject: [PATCH 01/22] group extension --- src/schema/rules/files/common/core.yaml | 5 +-- src/schema/rules/files/deriv/imaging.yaml | 12 +++---- src/schema/rules/files/raw/anat.yaml | 27 ++++++---------- src/schema/rules/files/raw/dwi.yaml | 6 ++-- src/schema/rules/files/raw/eeg.yaml | 5 +-- src/schema/rules/files/raw/fmap.yaml | 21 +++++-------- src/schema/rules/files/raw/func.yaml | 6 ++-- src/schema/rules/files/raw/ieeg.yaml | 8 ++--- src/schema/rules/files/raw/meg.yaml | 38 +++++++++++++++-------- src/schema/rules/files/raw/micr.yaml | 6 +--- src/schema/rules/files/raw/perf.yaml | 3 +- src/schema/rules/files/raw/pet.yaml | 3 +- src/schema/rules/files/raw/photo.yaml | 8 ++--- 13 files changed, 62 insertions(+), 86 deletions(-) diff --git a/src/schema/rules/files/common/core.yaml b/src/schema/rules/files/common/core.yaml index cacc3e0c41..54a37ca8e0 100644 --- a/src/schema/rules/files/common/core.yaml +++ b/src/schema/rules/files/common/core.yaml @@ -9,10 +9,7 @@ README: level: recommended stem: README extensions: - - '' - - .md - - .rst - - .txt + - ['', .md, .rst, .txt] CHANGES: level: optional path: CHANGES diff --git a/src/schema/rules/files/deriv/imaging.yaml b/src/schema/rules/files/deriv/imaging.yaml index e037dcc10c..d717c59ed0 100644 --- a/src/schema/rules/files/deriv/imaging.yaml +++ b/src/schema/rules/files/deriv/imaging.yaml @@ -94,8 +94,7 @@ anat_parametric_discrete_segmentation: density: optional description: optional extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json - .tsv @@ -110,8 +109,7 @@ anat_nonparametric_discrete_segmentation: density: optional description: optional extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json - .tsv @@ -190,8 +188,7 @@ anat_parametic_discrete_surface: suffixes: - dseg extensions: - - .label.gii - - .dlabel.nii + - [.label.gii, .dlabel.nii] - .json - .tsv entities: @@ -207,8 +204,7 @@ anat_nonparametic_discrete_surface: suffixes: - dseg extensions: - - .label.gii - - .dlabel.nii + - [.label.gii, .dlabel.nii] - .json - .tsv entities: diff --git a/src/schema/rules/files/raw/anat.yaml b/src/schema/rules/files/raw/anat.yaml index 2e534a2817..c2c7159d60 100644 --- a/src/schema/rules/files/raw/anat.yaml +++ b/src/schema/rules/files/raw/anat.yaml @@ -14,8 +14,7 @@ nonparametric: - FLASH # deprecated - PD # deprecated extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - anat @@ -48,8 +47,7 @@ parametric: - S0map - M0map extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - anat @@ -66,8 +64,7 @@ defacemask: suffixes: - defacemask extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - anat @@ -86,8 +83,7 @@ multiecho: - MESE - MEGRE extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - anat @@ -106,8 +102,7 @@ multiflip: suffixes: - VFA extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - anat @@ -127,8 +122,7 @@ multiinversion: suffixes: - IRT1 extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - anat @@ -147,8 +141,7 @@ mp2rage: suffixes: - MP2RAGE extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - anat @@ -170,8 +163,7 @@ vfamt: - MPM - MTS extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - anat @@ -192,8 +184,7 @@ mtr: suffixes: - MTR extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - anat diff --git a/src/schema/rules/files/raw/dwi.yaml b/src/schema/rules/files/raw/dwi.yaml index 98840ef6a1..ab36c60c8f 100644 --- a/src/schema/rules/files/raw/dwi.yaml +++ b/src/schema/rules/files/raw/dwi.yaml @@ -3,8 +3,7 @@ dwi: suffixes: - dwi extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json - .bvec - .bval @@ -23,8 +22,7 @@ sbref: suffixes: - sbref extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - dwi diff --git a/src/schema/rules/files/raw/eeg.yaml b/src/schema/rules/files/raw/eeg.yaml index 676d66dc1b..3262204536 100644 --- a/src/schema/rules/files/raw/eeg.yaml +++ b/src/schema/rules/files/raw/eeg.yaml @@ -4,13 +4,14 @@ eeg: - eeg extensions: - .json - - .edf + # .vhdr, .vmrk, .eeg must work as triplet - .vhdr - .vmrk - .eeg + # .set file with an OPTIONAL .fdt - .set - .fdt - - .bdf + - [.bdf, .edf] datatypes: - eeg entities: diff --git a/src/schema/rules/files/raw/fmap.yaml b/src/schema/rules/files/raw/fmap.yaml index 8f5e66a508..78a1c4d349 100644 --- a/src/schema/rules/files/raw/fmap.yaml +++ b/src/schema/rules/files/raw/fmap.yaml @@ -9,8 +9,7 @@ fieldmaps: - magnitude - fieldmap extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - fmap @@ -25,8 +24,7 @@ pepolar: - epi - m0scan extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - fmap @@ -42,8 +40,7 @@ TB1DAM: suffixes: - TB1DAM extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - fmap @@ -62,8 +59,7 @@ TB1EPI: suffixes: - TB1EPI extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - fmap @@ -86,8 +82,7 @@ RFFieldMaps: - TB1RFM - RB1COR extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - fmap @@ -107,8 +102,7 @@ TB1SRGE: suffixes: - TB1SRGE extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - fmap @@ -129,8 +123,7 @@ parametric: - TB1map - RB1map extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - fmap diff --git a/src/schema/rules/files/raw/func.yaml b/src/schema/rules/files/raw/func.yaml index 589d187444..11609e79e2 100644 --- a/src/schema/rules/files/raw/func.yaml +++ b/src/schema/rules/files/raw/func.yaml @@ -5,8 +5,7 @@ func: - cbv - sbref extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - func @@ -26,8 +25,7 @@ phase: suffixes: - phase # deprecated extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - func diff --git a/src/schema/rules/files/raw/ieeg.yaml b/src/schema/rules/files/raw/ieeg.yaml index 587f9bcbb8..61b0a6a4b7 100644 --- a/src/schema/rules/files/raw/ieeg.yaml +++ b/src/schema/rules/files/raw/ieeg.yaml @@ -3,15 +3,15 @@ ieeg: suffixes: - ieeg extensions: - - .mefd/ - .json - - .edf + # .vhdr, .vmrk, .eeg must work as triplet - .vhdr - - .eeg - .vmrk + - .eeg + # .set file with an OPTIONAL .fdt - .set - .fdt - - .nwb + - [.nwb, .edf, .mefd/] datatypes: - ieeg entities: diff --git a/src/schema/rules/files/raw/meg.yaml b/src/schema/rules/files/raw/meg.yaml index c308cd8b9b..50c321e0d8 100644 --- a/src/schema/rules/files/raw/meg.yaml +++ b/src/schema/rules/files/raw/meg.yaml @@ -3,19 +3,33 @@ meg: suffixes: - meg extensions: - - / # corresponds to BTi/4D data - - .ds/ + # / corresponds to BTi/4D data - .json - - .fif - - .sqd - - .con + - [/, .ds/, .fif] + - [.sqd, .con] + - .ave # mentioned once in the appendix - .raw - - .ave - - .mrk + - .raw.mhd + # .kdf with possible additional files .chn, .trg and _digitizer.txt (see other suffix group below) - .kdf - - .mhd - - .trg - .chn + - .trg + datatypes: + - meg + entities: + subject: required + session: optional + task: required + acquisition: optional + run: optional + processing: optional + split: optional + +headpoints: + suffixes: + - digitizer + extensions: + - .txt datatypes: - meg entities: @@ -61,8 +75,7 @@ headshape: suffixes: - headshape extensions: - - .* - - .pos + - [.*, .pos] datatypes: - meg entities: @@ -74,8 +87,7 @@ markers: suffixes: - markers extensions: - - .sqd - - .mrk + - [.sqd, .mrk] datatypes: - meg entities: diff --git a/src/schema/rules/files/raw/micr.yaml b/src/schema/rules/files/raw/micr.yaml index aba1b48352..b8423f3b27 100644 --- a/src/schema/rules/files/raw/micr.yaml +++ b/src/schema/rules/files/raw/micr.yaml @@ -19,11 +19,7 @@ microscopy: - OCT - SPIM extensions: - - .ome.tif - - .ome.btf - - .ome.zarr/ - - .png - - .tif + - [.ome.tif, .ome.btf, .ome.zarr/, .png, .tif] - .json datatypes: - micr diff --git a/src/schema/rules/files/raw/perf.yaml b/src/schema/rules/files/raw/perf.yaml index 61cbc24721..036f1f7969 100644 --- a/src/schema/rules/files/raw/perf.yaml +++ b/src/schema/rules/files/raw/perf.yaml @@ -4,8 +4,7 @@ asl: - asl - m0scan extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - perf diff --git a/src/schema/rules/files/raw/pet.yaml b/src/schema/rules/files/raw/pet.yaml index a94cb9addd..f88a9f78ce 100644 --- a/src/schema/rules/files/raw/pet.yaml +++ b/src/schema/rules/files/raw/pet.yaml @@ -3,8 +3,7 @@ pet: suffixes: - pet extensions: - - .nii.gz - - .nii + - [.nii.gz, .nii] - .json datatypes: - pet diff --git a/src/schema/rules/files/raw/photo.yaml b/src/schema/rules/files/raw/photo.yaml index f5969e2d0c..6529ed3c76 100644 --- a/src/schema/rules/files/raw/photo.yaml +++ b/src/schema/rules/files/raw/photo.yaml @@ -3,9 +3,7 @@ photo: suffixes: - photo extensions: - - .jpg - - .png - - .tif + - [.jpg, .png, .tif] datatypes: - eeg - ieeg @@ -19,9 +17,7 @@ photo: photo__micr: $ref: rules.files.raw.photo.photo extensions: - - .jpg - - .png - - .tif + - [.jpg, .png, .tif] - .json datatypes: - micr From 13eabdd33f082c2a29985fbed5f9a8d05f26e0dd Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 18 May 2023 16:30:52 -0400 Subject: [PATCH 02/22] add comment --- src/schema/rules/files/raw/meg.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/schema/rules/files/raw/meg.yaml b/src/schema/rules/files/raw/meg.yaml index 50c321e0d8..d4ee878702 100644 --- a/src/schema/rules/files/raw/meg.yaml +++ b/src/schema/rules/files/raw/meg.yaml @@ -8,6 +8,7 @@ meg: - [/, .ds/, .fif] - [.sqd, .con] - .ave # mentioned once in the appendix + # .raw and .raw.mhd work as a pair - .raw - .raw.mhd # .kdf with possible additional files .chn, .trg and _digitizer.txt (see other suffix group below) From d3594e7bcbc9f55ef91c5f9b7e80b0b14bd004f6 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 18 May 2023 16:44:02 -0400 Subject: [PATCH 03/22] put all extension for data in list --- src/schema/rules/files/raw/eeg.yaml | 4 +--- src/schema/rules/files/raw/ieeg.yaml | 4 +--- src/schema/rules/files/raw/meg.yaml | 5 +---- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/schema/rules/files/raw/eeg.yaml b/src/schema/rules/files/raw/eeg.yaml index 3262204536..396ce0835c 100644 --- a/src/schema/rules/files/raw/eeg.yaml +++ b/src/schema/rules/files/raw/eeg.yaml @@ -4,14 +4,12 @@ eeg: - eeg extensions: - .json + - [.bdf, .edf, .eeg, .set] # .vhdr, .vmrk, .eeg must work as triplet - .vhdr - .vmrk - - .eeg # .set file with an OPTIONAL .fdt - - .set - .fdt - - [.bdf, .edf] datatypes: - eeg entities: diff --git a/src/schema/rules/files/raw/ieeg.yaml b/src/schema/rules/files/raw/ieeg.yaml index 61b0a6a4b7..c267cf6d03 100644 --- a/src/schema/rules/files/raw/ieeg.yaml +++ b/src/schema/rules/files/raw/ieeg.yaml @@ -3,15 +3,13 @@ ieeg: suffixes: - ieeg extensions: + - [.nwb, .edf, .mefd/, .eeg, .set] - .json # .vhdr, .vmrk, .eeg must work as triplet - .vhdr - .vmrk - - .eeg # .set file with an OPTIONAL .fdt - - .set - .fdt - - [.nwb, .edf, .mefd/] datatypes: - ieeg entities: diff --git a/src/schema/rules/files/raw/meg.yaml b/src/schema/rules/files/raw/meg.yaml index d4ee878702..8198dd5c1d 100644 --- a/src/schema/rules/files/raw/meg.yaml +++ b/src/schema/rules/files/raw/meg.yaml @@ -5,14 +5,11 @@ meg: extensions: # / corresponds to BTi/4D data - .json - - [/, .ds/, .fif] - - [.sqd, .con] + - [/, .ds/, .fif, .sqd, .con, .raw, .kdf] - .ave # mentioned once in the appendix # .raw and .raw.mhd work as a pair - - .raw - .raw.mhd # .kdf with possible additional files .chn, .trg and _digitizer.txt (see other suffix group below) - - .kdf - .chn - .trg datatypes: From b0d5dd53fc1e0a4af70f904dfb9819931a1fe6fd Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sat, 20 May 2023 15:02:18 -0400 Subject: [PATCH 04/22] rename some funtions --- tools/schemacode/bidsschematools/render/text.py | 14 +++++++------- .../bidsschematools/tests/test_render_text.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/schemacode/bidsschematools/render/text.py b/tools/schemacode/bidsschematools/render/text.py index b43a33e617..4b9a1f5e31 100644 --- a/tools/schemacode/bidsschematools/render/text.py +++ b/tools/schemacode/bidsschematools/render/text.py @@ -54,14 +54,14 @@ def make_entity_definitions(schema, src_path=None): text = "" for entity in entity_order: entity_info = entity_definitions[entity] - entity_text = _make_entity_definition(entity, entity_info) + entity_text = _make_definition_for_entity(entity_info) text += "\n" + entity_text text = text.replace("SPEC_ROOT", utils.get_relpath(src_path)) return text -def _make_entity_definition(entity, entity_info): +def _make_definition_for_entity(entity_info): """Describe an entity.""" entity_shorthand = entity_info["name"] text = "" @@ -208,7 +208,7 @@ def _format_entity(entity, lt, gt): return f"{entity['name']}-{lt}{fmt}{gt}" -def value_key_table(namespace): +def _value_key_table(namespace): return {struct.value: key for key, struct in namespace.items()} @@ -272,8 +272,8 @@ def make_filename_template( lt, gt = "<", ">" schema = Namespace(filter_schema(schema.to_dict(), **kwargs)) - suffix_key_table = value_key_table(schema.objects.suffixes) - ext_key_table = value_key_table(schema.objects.extensions) + suffix_key_table = _value_key_table(schema.objects.suffixes) + ext_key_table = _value_key_table(schema.objects.extensions) # Parent directories sub_string = utils._link_with_html( @@ -411,13 +411,13 @@ def make_filename_template( ) codeblock = codeblock.expandtabs(4) - codeblock = append_filename_template_legend(codeblock, pdf_format) + codeblock = _append_filename_template_legend(codeblock, pdf_format) codeblock = codeblock.replace("SPEC_ROOT", utils.get_relpath(src_path)) return codeblock -def append_filename_template_legend(text, pdf_format=False): +def _append_filename_template_legend(text, pdf_format=False): """Append a legend to filename templates. Parameters diff --git a/tools/schemacode/bidsschematools/tests/test_render_text.py b/tools/schemacode/bidsschematools/tests/test_render_text.py index be9ceb132f..ed50e8ab78 100644 --- a/tools/schemacode/bidsschematools/tests/test_render_text.py +++ b/tools/schemacode/bidsschematools/tests/test_render_text.py @@ -117,11 +117,11 @@ def test_define_common_principles(schema_obj): def test_append_filename_template_legend(): """Check contents of generated string.""" - test_str = text.append_filename_template_legend("", pdf_format=False) + test_str = text._append_filename_template_legend("", pdf_format=False) assert isinstance(test_str, str) assert "follow the links" in test_str - test_str = text.append_filename_template_legend("", pdf_format=True) + test_str = text._append_filename_template_legend("", pdf_format=True) assert isinstance(test_str, str) assert "follow the links" not in test_str From 160b9c5c8875d935621b2b371ce3e7c431950d5d Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sat, 20 May 2023 15:06:38 -0400 Subject: [PATCH 05/22] minor fixes --- src/appendices/meg-file-formats.md | 4 ++-- src/schema/rules/files/raw/meg.yaml | 2 +- tools/schemacode/bidsschematools/render/text.py | 7 ++++++- tools/schemacode/bidsschematools/render/utils.py | 7 +++++++ .../schemacode/bidsschematools/tests/test_render_utils.py | 7 +++++++ 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/appendices/meg-file-formats.md b/src/appendices/meg-file-formats.md index 0465b67472..eed5972e62 100644 --- a/src/appendices/meg-file-formats.md +++ b/src/appendices/meg-file-formats.md @@ -329,8 +329,8 @@ A guide for using macros can be found at "sub-control01_ses-001_task-rest_run-01_meg": "", "sub-control01_ses-001_task-rest_run-01_meg.json": "", "sub-control01_ses-001_task-rest_run-01_channels.tsv": "", - "sub-control01_ses-001_task-rest[_acq-