-
Notifications
You must be signed in to change notification settings - Fork 181
[ENH] BEP044 - Stim-BIDS #2022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
neuromechanist
wants to merge
52
commits into
bids-standard:master
Choose a base branch
from
neuromechanist:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[ENH] BEP044 - Stim-BIDS #2022
Changes from 24 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
95ebf75
Add stimuli specifications to BIDS
neuromechanist 91df78b
edit stimuli description
neuromechanist 0167a41
Update task events to include stim-bids spec
neuromechanist 3c2357b
Add missing entities
neuromechanist b7b19df
handling GH Action errors
neuromechanist aa570ac
yaml-link issues
neuromechanist 162cd1c
remark validation
neuromechanist 1ef76bc
Move extensions to their own place.
neuromechanist e84cac4
Revise the extensions
neuromechanist 1dd9083
YAML lint
neuromechanist 50ad1dd
Merge pull request #2 from neuromechanist/add-stimuli-specifications
neuromechanist 77f33b0
Merge branch 'bids-standard:master' into master
neuromechanist 4978552
Sidecar description is only needed of rhte individual stimulus files.
neuromechanist 80d3077
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a335ebf
tabular information matching the spec.
neuromechanist f370c95
Edit stimuli.md to reflect the spec more completely
neuromechanist 330b69f
Implement Kay's comments for clarity
neuromechanist ad24800
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a5acd54
Revert adding BEP044 doc, implementing Kay's suggestions.
neuromechanist 238e645
Merge remote-tracking branch 'upstream/master' into pr/neuromechanist…
Remi-Gau 074f5fb
sty
Remi-Gau f197bba
remark
Remi-Gau 02c6f31
fix
Remi-Gau 3ae9fe1
fix
Remi-Gau e849646
Merge branch 'bids-standard:master' into master
neuromechanist 2793d75
Fix a couple of typos
neuromechanist 2e7ab2a
Remove the BIDS2.0 provision
neuromechanist 284dc7f
Revise the JSON metadata recommendation
neuromechanist f48e63f
remove uppercase audio extensions
neuromechanist 4f1a0b3
Remove uppercase audiovideo extensions
neuromechanist db7994b
Remove uppercase video extensions
neuromechanist 64ce56b
Remove uppercase image extensions
neuromechanist e7c0739
add `webp` for image
neuromechanist c8ffa63
Add guide for license and copyright fleds.
neuromechanist 8178a3f
update JSON sidecare description
neuromechanist eafdac9
revert the `part` def to only expand it for stimulus.
neuromechanist 4538a45
consolidate stim files under stim.yaml
neuromechanist 28d41ba
revise stim.yaml
neuromechanist 6f0d5d5
move stim.yaml to raw
neuromechanist 9d4225b
rename file name to maintain consistency
neuromechanist 74d1596
add checks
neuromechanist 8616e04
update tabular data
neuromechanist d6832b2
update file tree
neuromechanist 50437b4
add needed entities for stimuli and annotation
neuromechanist a4b20ad
clarify stimuli modality/datatype
neuromechanist 567148e
update datatypes and stim descriptions
neuromechanist f409097
add stimuli entity table
neuromechanist a064d83
add datatypes
neuromechanist ba5b89f
remove bidsschematools
neuromechanist cd53cd9
fix a typo
neuromechanist 451464f
add missing column defs
neuromechanist 178ea4e
fall back to filetree example for now
neuromechanist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
# Stimuli | ||
|
||
## Stimulus Files Organization | ||
|
||
Stimulus files MUST be stored in the `/stimuli` directory under the root directory of the dataset. | ||
The `/stimuli` directory can contain subdirectories to organize the stimulus files. | ||
Stimulus files MUST follow the BIDS naming conventions and are referenced in the `events.tsv` | ||
file using the `stim_id` column. | ||
|
||
The standardization of stimulus files and their annotations within BIDS offers several key benefits: | ||
|
||
1. **Consistency**: Ensures uniform storage and referencing across datasets | ||
1. **Reusability**: Enables stimulus reuse across studies through standardized structure | ||
1. **Efficiency**: Minimizes redundancy by centralizing annotations | ||
1. **Flexibility**: Facilitates dataset reuse with alternative annotations | ||
|
||
To preserve backward compatibility with existing datasets (see the Legacy section below), the use of these specifications for `/stimuli` directory and the `stim_id` column in the `events.tsv` files is RECOMMENDED but not required. Researchers are encouraged to follow these guidelines to enhance the interoperability and reproducibility of their studies. | ||
|
||
Following these guidelines will help ensure that stimulus files and their annotations are stored and referenced consistently across different datasets, facilitating data sharing, reuse, and reproducibility. | ||
|
||
## File Organization | ||
|
||
<!-- This block generates a file tree. | ||
A guide for using macros can be found at | ||
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md | ||
--> | ||
{{ MACROS___make_filetree_example({ | ||
"stimuli": { | ||
"stimuli.tsv": "", | ||
"stimuli.json": "", | ||
"[stim-<label>[_part-<label>]_<suffix>.<extension>]": "", | ||
"[stim-<label>[_part-<label>]_<suffix>.json]": "", | ||
"[[stim-<label>_]annotations.tsv]": "", | ||
"[[stim-<label>_]annotations.json]": "", | ||
"[stim-<label>[_part-<label>]_annot-<label>_events.tsv]": "", | ||
"[stim-<label>[_part-<label>]_annot-<label>_events.json]": "" | ||
} | ||
}) }} | ||
|
||
Note: The presence of `stimuli.tsv` file indicates that the content of the `/stimuli` directory follows this BIDS specification for stimulus organization. This structure is planned to become mandatory in BIDS 2.0. | ||
yarikoptic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Stimulus File Formats | ||
|
||
The following table lists the supported stimulus file formats and their corresponding suffixes. The suffixes are used to identify the type of stimulus file and are appended to the `stim-<label>` prefix in the file name. | ||
|
||
| suffix | extensions | description | | ||
| ----------- | ------------------------------- | ---------------------------- | | ||
| audio | `.wav`, `.mp3`, `.aac`, `.ogg` | Audio-only stimulus files | | ||
| image | `.jpg`, `.png`, `.svg` | Static visual stimulus files | | ||
neuromechanist marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| video | `.mp4`, `.avi`, `.mkv`, `.webm` | Video-only stimulus files | | ||
| audiovideo | `.mp4`, `.avi`, `.mkv`, `.webm` | Combined audio-visual files | | ||
|
||
## Stimulus description (`stim-<label>_<suffix>.json`) | ||
|
||
The `stim-<label>_<suffix>.json` file provides metadata about the _singular_ stimulus file. | ||
The following fields are defined to describe the stimulus file: | ||
|
||
<!-- This block generates a metadata table. | ||
These tables are defined in | ||
src/schema/rules/sidecars | ||
The definitions of the fields specified in these tables may be found in | ||
src/schema/objects/metadata.yaml | ||
A guide for using macros can be found at | ||
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md | ||
--> | ||
{{ MACROS___make_sidecar_table("stimuli.Stimuli") }} | ||
|
||
In some cases, such as observing the copyright of a stimulus file, the actual stimulus file may not be shared. In such cases, the `stim-<label>_<suffix>.json` file SHOULD be used to provide metadata about the stimulus file, including the license, copyright, URL, and description. | ||
neuromechanist marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Example `stim-<label>_<suffix>.json` | ||
|
||
```JSON | ||
{ | ||
"License": "CC-BY-4.0", | ||
"Copyright": "Lab 2023", | ||
neuromechanist marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"URL": "https://example.com/stimuli/", | ||
"Description": "Collection of face images, tones, and movie clips used in the experiment" | ||
} | ||
``` | ||
|
||
## Stimuli Description (`stimuli.tsv`) | ||
|
||
The `stimuli.tsv` files are used to provide information about the stimuli based on their `stim_id`. This file is similar in usage as `participants.tsv`, `scans.tsv` and `sessions.tsv`, which list descriptions about subjects, scans and sessions, respectively. The `stimluli.tsv` files MUST be placed in the `/stimuli` directory. | ||
neuromechanist marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The `stimuli.tsv` file contains information about each stimulus, including stimulus ID, type, URL, and other relevant details. The following table describes the REQUIRED, RECOMMENDED, and OPTIONAL columns for the `stimuli.tsv` file: | ||
|
||
<!-- This block generates a columns table. | ||
The definitions of these fields can be found in | ||
src/schema/rules/tabular_data/*.yaml | ||
and a guide for using macros can be found at | ||
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md | ||
--> | ||
{{ MACROS___make_columns_table("stimuli.Stimuli") }} | ||
|
||
### Example `stimuli.tsv` | ||
|
||
```Text | ||
stimulus_id type URL license copyright description present | ||
stim-face01 image https://example.com/faces/face01.jpg CC-BY-4.0 Lab 2023 A female face with neutral expression true | ||
stim-tone01 audio https://example.com/tones/tone01.wav CC-BY-4.0 Lab 2023 A 440Hz pure tone true | ||
stim-movie01 video https://example.com/movies/movie01.mp4 n/a Studio XYZ A clip from copyrighted movie false | ||
``` | ||
|
||
The `stimuli.json` file provides detailed descriptions of the columns in the `stimuli.tsv` file. There MAY be extra entries in the `stimuli.json` in addition to the columns in the `stimuli.tsv` to provide more details about the stimulus. | ||
|
||
In cases where the stimulus is not shared, the `stimuli.tsv` file can be used to provide metadata about the stimuli, including the license, copyright, URL, and description. This is similar to the use of `stim-<label>_<suffix>.json` files for individual stimuli files. In the case of conflict between the metadata in the `stimuli.tsv` and `stim-<label>_<suffix>.json` files, the metadata in the `stim-<label>_<suffix>.json` file takes precedence. | ||
|
||
## Stimulus Annotations | ||
|
||
Annotations of the still images or general description of the stimuli (such as frequency and duration of a beep sound) can be stored in the `stimuli.tsv` as an additional column or `stim-<label>_<suffix>.json` as described above. Here is an example of how annotations can be stored in the `stimuli.tsv` file for an image from the Natural Scene Dataset (NSD): | ||
|
||
| stimulus_id | type | description | HED | NSD_id | COCO_id | | ||
| ------------- | ----- | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------- | | ||
| stim-nsd02951 | image | an open market full of people and piles of vegetables | ((Item-count, High), Ingestible-object), (Background-view, ((Human, Body, Agent-trait/Adult), Outdoors, Furnishing, Natural-feature/Sky, Urban, Man-made-object)) | 2951 | 262145 | | ||
|
||
However, for time-varying stimuli, such as audio or video, it is RECOMMENDED to use specific annotations files in the form of `stim-<label>_annot-<label>_events.tsv` to store the annotations. These files have the same structure as the `events.tsv` files and are used to store annotations for the stimuli. There can be multiple annotation files for a single stimulus file, each with a unique annotation label. The annotation files MUST be stored in the `/stimuli` directory. | ||
|
||
## Annotation Description (`annotations.tsv`) | ||
|
||
The `annotations.tsv` file contains additional metadata about stimulus annotations. There MAY be a single `annotations.tsv` file for all the stimuli or separate `stim-<label>_annotations.tsv` files for each stimulus. | ||
The following columns are defined for the `annotations.tsv` file: | ||
|
||
<!-- This block generates a columns table. | ||
The definitions of these fields can be found in | ||
src/schema/rules/tabular_data/*.yaml | ||
and a guide for using macros can be found at | ||
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md | ||
--> | ||
{{ MACROS___make_columns_table("stimuli.Annotations") }} | ||
|
||
### Example `*_annotations.tsv` | ||
|
||
```Text | ||
annot_id description | ||
face01_emo Emotion annotation for face01 stimulus | ||
face01_gen Gender annotation for face01 stimulus | ||
face01_age Age group annotation for face01 stimulus | ||
``` | ||
|
||
## Referencing Stimulus Identifiers in `events.tsv` | ||
|
||
To reference stimulus identifiers in the `events.tsv` file, use the `stim_id` column. The values in the `stim_id` column should represent unique identifiers for the stimuli. Stimulus ID (`stim_id`) should correspond to the unique identifier of the stimulus file in the /stimuli directory and expands to all files (both stimulus and annotation files) that share the same stimulus ID. | ||
|
||
Example `events.tsv` file: | ||
|
||
| onset | duration | trial_type | response_time | stim_id | | ||
| ----- | -------- | ---------- | ------------- | -------------- | | ||
| 1.23 | 0.65 | start | 1.435 | `stim-<label>` | | ||
| 5.65 | 0.65 | stop | 1.739 | `stim-<label>` | | ||
| 12.1 | 2.35 | n/a | n/a | `stim-<label>` | | ||
|
||
In the accompanying JSON sidecar, the `stim_id` column might be described as follows: | ||
|
||
```JSON | ||
{ | ||
"stim_id": { | ||
"LongName": "Stimulus identifier", | ||
"Description": "Represents a unique identifier for the stimulus presented at the given onset time." | ||
} | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,3 +400,106 @@ A guide for using macros can be found at | |
Additional metadata may be included as in | ||
[any TSV file](../common-principles.md#tabular-files) to specify, for | ||
example, the units of the recorded time series for each column. | ||
|
||
## Standardization of Stimulus Files and Annotations | ||
|
||
To ensure consistency and facilitate reuse, the BIDS specifications provide guidelines for standardizing stimulus files and their annotations. This section outlines the recommended practices for storing and referencing stimulus files within a BIDS dataset. | ||
|
||
### Storing Stimulus Files | ||
|
||
Stimulus files should be stored in the `/stimuli` directory under the root directory of the dataset. The `/stimuli` directory can contain subdirectories to organize the stimulus files. There are no restrictions on the file formats of the stimulus files. | ||
|
||
Example directory structure: | ||
|
||
<!-- This block generates a file tree. | ||
A guide for using macros can be found at | ||
https://github.com/bids-standard/bids-specification/blob/master/macros_doc.md | ||
--> | ||
{{ MACROS___make_filetree_example({ | ||
"stimuli": { | ||
"images": { | ||
"cat01.jpg": "", | ||
"cat02.jpg": "", | ||
}, | ||
"videos": { | ||
"movie01.mp4": "", | ||
"movie02.mp4": "", | ||
}, | ||
}, | ||
}) }} | ||
|
||
### Referencing Stimulus Files in `events.tsv` | ||
|
||
To reference stimulus files in the `events.tsv` file, use the `stim_file` column. The values in the `stim_file` column should represent the relative path to the stimulus file within the `/stimuli` directory. | ||
|
||
Example `events.tsv` file: | ||
|
||
```Text | ||
onset duration trial_type response_time stim_file | ||
1.23 0.65 start 1.435 images/cat01.jpg | ||
5.65 0.65 stop 1.739 images/cat02.jpg | ||
12.1 2.35 n/a n/a videos/movie01.mp4 | ||
``` | ||
|
||
In the accompanying JSON sidecar, the `stim_file` column might be described as follows: | ||
|
||
```JSON | ||
{ | ||
"stim_file": { | ||
"LongName": "Stimulus file", | ||
"Description": "Represents the location of the stimulus file (such as an image, video, or audio file) presented at the given onset time. The values correspond to a path relative to the /stimuli directory." | ||
} | ||
} | ||
``` | ||
|
||
### Referencing Stimulus Identifiers in `events.tsv` | ||
|
||
To reference stimulus identifiers in the `events.tsv` file, use the `stim_id` column. The `stim_id` corresponds to the unique identifier of the stimulus files and their annotations stored under the `/stimuli` directory. This allows linking each event to multiple related files associated with that stimulus. | ||
|
||
Example `events.tsv` file: | ||
|
||
```Text | ||
onset duration trial_type response_time stim_id | ||
1.23 0.65 start 1.435 stim-face01 | ||
5.65 0.65 stop 1.739 stim-face02 | ||
12.1 2.35 n/a n/a stim-video01 | ||
``` | ||
|
||
In the accompanying JSON sidecar, the `stim_id` column might be described as follows: | ||
|
||
```JSON | ||
{ | ||
"stim_id": { | ||
"LongName": "Stimulus identifier", | ||
"Description": "Represents a unique identifier for the stimulus presented at the given onset time. Links to files and annotations in the /stimuli directory." | ||
} | ||
} | ||
``` | ||
|
||
The `stim_id` in the events file links to corresponding files: | ||
|
||
```Text | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs MACROS___make_filetree_example until someone smart implements parsing... ref: #2014 (comment) |
||
stimuli/ | ||
├── stim-face01_image.jpg | ||
├── stim-face01_image.json | ||
├── stim-face01_annotations.tsv | ||
├── stim-face02_image.jpg | ||
├── stim-face02_image.json | ||
├── stim-face02_annotations.tsv | ||
├── stim-face02_annotations.tsv | ||
├── stimuli.tsv | ||
└── stimuli.json | ||
``` | ||
|
||
By using `stim_id`, multiple annotations and stimulus files associated with the same identifier can be efficiently linked to events in the `events.tsv` file. The `stim_id` is a unique identifier for the stimulus that can be used to reference the stimulus files, annotations, and metadata stored in `stimuli.tsv` and `stimuli.json`. For more information on the structure of stimulus files and annotations, refer to the [Stimuli](./stimuli.md) BIDS specifications. | ||
|
||
### Advantages of Standardization | ||
|
||
Standardizing stimulus files and their annotations within the BIDS specifications offers several advantages: | ||
|
||
1. **Consistency**: Ensures that stimulus files are stored and referenced in a consistent manner across different datasets. | ||
1. **Reusability**: Facilitates the reuse of stimulus files and annotations in other studies by providing a standardized structure. | ||
1. **Efficiency**: Reduces redundancy by avoiding the need to replicate annotations across subjects, modalities, tasks, and runs. | ||
1. **Flexibility**: Allows for easy modification of annotations by updating a single file, enabling the reuse of datasets with alternative annotations. | ||
|
||
By following these guidelines, researchers can enhance the interoperability and reproducibility of their studies, making it easier to share and reuse data within the scientific community. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.