Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Nov 8, 2024
2 parents 58215d1 + 436d7cd commit 4724083
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 367 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ repos:
- id: codespell
args: ["--config=.codespellrc", "--dictionary=-", "--dictionary=.codespell_dict"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.13.0
hooks:
- id: mypy
# Sync with project.optional-dependencies.typing
Expand Down
348 changes: 14 additions & 334 deletions CONTRIBUTING.md

Large diffs are not rendered by default.

24 changes: 4 additions & 20 deletions macros_doc.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
render_macros: false
---

# Using MkDocs macros in the BIDS specification

We use [mkdocs-macros](https://mkdocs-macros-plugin.readthedocs.io/en/latest/)
Expand All @@ -9,23 +13,6 @@ in the specification.
Below you will find answers to frequently asked questions regarding using macros
in the BIDS specification.

- [Using MkDocs macros in the BIDS specification](#using-mkdocs-macros-in-the-bids-specification)
- [What are macros and why use them?](#what-are-macros-and-why-use-them)
- [What kind of input information are required by macros?](#what-kind-of-input-information-are-required-by-macros)
- [What macros are available?](#what-macros-are-available)
- [When should I use a macro?](#when-should-i-use-a-macro)
- [Do I need learn how to program to use those macros?](#do-i-need-learn-how-to-program-to-use-those-macros)
- [Anything else I need to know if I need to insert a new macro call?](#anything-else-i-need-to-know-if-i-need-to-insert-a-new-macro-call)
- [How-To and Examples](#how-to-and-examples)
- [Writing directory content examples](#writing-directory-content-examples)
- [Generating tables](#generating-tables)
- [Modifying a term in the table](#modifying-a-term-in-the-table)
- [Why would you NOT want to modify the content of the yml file directly ?](#why-would-you-not-want-to-modify-the-content-of-the-yml-file-directly-)
- [Adding a new term to the table](#adding-a-new-term-to-the-table)
- [Should I create a macro if I need a new kind of table?](#should-i-create-a-macro-if-i-need-a-new-kind-of-table)
- [Why use macros at all?](#why-use-macros-at-all)
- [Links and references](#links-and-references)

## What are macros and why use them?

A macro is a rule or pattern that specifies how an input should be mapped to
Expand Down Expand Up @@ -127,9 +114,6 @@ when you get back to the document you just edited) is to leave a comment before
the macro to quickly explain what it does and where to find more information
about it.

<!-- - [ ] TODO for maintainers: actually add those comments in the current
specification. -->

It could for example look like this:

```markdown
Expand Down
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ extra:
link: https://www.instagram.com/bidsstandard/
- icon: fontawesome/brands/youtube
link: https://www.youtube.com/channel/UCxZUcYfd_nvIVWAbzRB1tlw
analytics:
provider: google
property: G-SBWH6YNMPX

extra_javascript:
- js/jquery-3.6.0.min.js
Expand Down
8 changes: 7 additions & 1 deletion src/common-principles.md
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,11 @@ A guide for using macros can be found at
"sub-01_task-rest_acq-default_bold.nii.gz": "",
"sub-01_task-rest_acq-longtr_bold.nii.gz": "",
"sub-01_task-rest_acq-longtr_bold.json": "",
}
},
"sub-01_scans.tsv": "",
},
"task-rest_bold.json": "",
"scans.json": ""
}
) }}

Expand Down Expand Up @@ -773,6 +775,10 @@ the value for field "`RepetitionTime`" is therefore overridden to the value `3.0
The value for field "`EchoTime`" remains applicable to that image, and is not unset by its
absence in the metadata file at the lower level (rule 5.b; corollary 3).

A single `scans.json`, without any entity in the filename at the top level,
is applicable to describe columns of the `sub-01_scans.tsv`
and any other `_scans.tsv` potentially present in the dataset for other subjects.

Example 2: Impermissible use of multiple metadata files at one directory level (rule 4)

<!-- This block generates a file tree.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ stored in one of the following formats:
| [EEGLAB](https://sccn.ucsd.edu/eeglab/index.php) | `.set`, `.fdt` | The format used by the MATLAB toolbox [EEGLAB](https://sccn.ucsd.edu/eeglab/index.php). Each recording consists of a `.set` file with an OPTIONAL `.fdt` file. |
| [Neurodata Without Borders](https://nwb-schema.readthedocs.io/en/latest/) | `.nwb` | Each recording consists of a single `.nwb` file. |
| [MEF3](https://osf.io/e3sf9/) | `.mefd` | Each recording consists of a `.mefd` directory. |
| [MED](https://medformat.org/) | `.medd` | Each recording consists of a `.medd` directory. |

It is RECOMMENDED to use the European data format, or the BrainVision data
format. It is furthermore discouraged to use the other accepted formats over
Expand Down
2 changes: 2 additions & 0 deletions src/schema/objects/columns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ onset:
(for example, "dummy volumes" in BOLD fMRI),
a time of 0 corresponds to the first stored data point and not the first
acquired data point.
A value of `n/a` value indicates the onset time is unknown or unavailable.
type: number
unit: s
pathology:
Expand Down
8 changes: 8 additions & 0 deletions src/schema/objects/extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ md:
display_name: Markdown
description: |
A Markdown file.
medd:
value: .medd/
display_name: Multiscale Electrophysiology Data Format
description: |
A directory in the [MED](https://medformat.org/) format.
Successor to the MEF 3.0 format.
Each recording consists of a `.medd` directory.
mefd:
value: .mefd/
display_name: Multiscale Electrophysiology File Format Version 3.0
Expand Down
8 changes: 8 additions & 0 deletions src/schema/rules/checks/func.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ VolumeTimingRepetitionTimeMutex:
or 'VolumeTiming' when variable times are used.
level: error
selectors:
- type(nifti_header) != "null"
- intersects([suffix], ["asl", "bold"])
- type(sidecar.VolumeTiming) != "null"
checks:
- type(sidecar.RepetitionTime) == "null"
Expand All @@ -101,6 +103,8 @@ RepetitionTimeAcquisitionDurationMutex:
(RepetitionTime - AcquisitionDuration).
level: error
selectors:
- type(nifti_header) != "null"
- intersects([suffix], ["asl", "bold"])
- type(sidecar.AcquisitionDuration) != "null"
checks:
- type(sidecar.RepetitionTime) == "null"
Expand All @@ -113,6 +117,8 @@ VolumeTimingDelayTimeMutex:
To specify acquisition duration, use 'AcquisitionDuration' or 'SliceTiming'.
level: error
selectors:
- type(nifti_header) != "null"
- intersects([suffix], ["asl", "bold"])
- type(sidecar.VolumeTiming) != "null"
checks:
- type(sidecar.DelayTime) == "null"
Expand All @@ -124,6 +130,8 @@ VolumeTimingMissingAcquisitionDuration:
The field 'VolumeTiming' requires 'AcquisitionDuration' or 'SliceTiming' to be defined.
level: error
selectors:
- type(nifti_header) != "null"
- intersects([suffix], ["asl", "bold"])
- type(sidecar.VolumeTiming) != "null"
checks:
- '"SliceTiming" in sidecar || "AcquisitionDuration" in sidecar'
1 change: 1 addition & 0 deletions src/schema/rules/files/raw/ieeg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ieeg:
suffixes:
- ieeg
extensions:
- .medd/
- .mefd/
- .json
- .edf
Expand Down
6 changes: 1 addition & 5 deletions tools/schemacode/bidsschematools/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import logging
import tempfile
from importlib.resources import as_file, files
from subprocess import run

try:
from importlib.resources import as_file, files
except ImportError: # PY<3.9
from importlib_resources import as_file, files

import pytest

lgr = logging.getLogger()
Expand Down
15 changes: 14 additions & 1 deletion tools/schemacode/bidsschematools/data/tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def test_rule_objects(schema_obj):
is_list = False

for i_use, use in enumerate(instance):
assert isinstance(use, str)
if use == "derivatives":
# Skip derivatives dirs, because the dir is treated as a "use" instead.
continue
Expand All @@ -81,9 +82,21 @@ def test_rule_objects(schema_obj):
object_values = [
value["value"] for value in schema_obj["objects"][object_type].values()
]
else:
elif object_type in [
"columns",
"common_principles",
"datatypes",
"entities",
"enums",
"files",
"formats",
"metadata",
"modalities",
]:
# But other object types are referenced via their keys
object_values = list(schema_obj["objects"][object_type].keys())
else:
raise AssertionError(f"Object type {object_type} not implemented.")

# Build a list of items mentioned in rules, but not found in objects.
if use not in object_values:
Expand Down
6 changes: 1 addition & 5 deletions tools/schemacode/bidsschematools/tests/test_make_testdata.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import os
import shutil

try:
from importlib.resources import files
except ImportError: # PY<3.9
from importlib_resources import files
from importlib.resources import files

import pytest

Expand Down

0 comments on commit 4724083

Please sign in to comment.