Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

- Descriptor: the license sentence gives the official name of the license with its short form.
- American spelling in generated text, messages and documentation.

## 0.1.3 (2026-11-20)

- A behavioural protocol's `described in` is a DOI and becomes a DOI node (protocol schema 1.2).
Expand Down
4 changes: 2 additions & 2 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ fairephys is licensed under the MIT License (see `LICENSE`). The package also sh
- Copyright (c) 2018, BIDS Contributors
- License: Creative Commons Attribution 4.0 International (CC-BY-4.0), https://creativecommons.org/licenses/by/4.0/

## Creative Commons licence texts
## Creative Commons license texts

`src/fairephys/_resources/licenses/*.txt` are the legal code of the Creative Commons licences, written as the `LICENSE` file of a curated dataset. Creative Commons dedicates the text of its public licences to the public domain under CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/).
`src/fairephys/_resources/licenses/*.txt` are the legal code of the Creative Commons licenses, written as the `LICENSE` file of a curated dataset. Creative Commons dedicates the text of its public licenses to the public domain under CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/).
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ YAML templates (the lab's description) raw recordings
(BEP032) README across all of them
```

1. **Capture the metadata.** The researcher or curator describes the experiment in YAML templates, one per concern: the dataset, the subject, the hardware, the behavioural protocol, the recording sessions, the electrode placements and the processing. What stays the same across sessions is written once; each session entry holds only what differs. JSON schemas check every template before it is used, so a missing required field or a value of the wrong type is caught at entry, not in a finished output.
1. **Capture the metadata.** The researcher or curator describes the experiment in YAML templates, one per concern: the dataset, the subject, the hardware, the behavioral protocol, the recording sessions, the electrode placements and the processing. What stays the same across sessions is written once; each session entry holds only what differs. JSON schemas check every template before it is used, so a missing required field or a value of the wrong type is caught at entry, not in a finished output.
2. **Build one canonical record.** The compiler merges the templates into a single odML document and adds what the recordings already say about themselves (channel names, sampling rates, durations, read with Neo), so that this information is not typed by hand. Plain-text terms such as species and brain regions are resolved to controlled terms (openMINDS, UBERON). Every value keeps its origin: the sources named in the template it was written in, or the file header it was read from.
3. **Translate it for each standard.** Declarative registries, written in YAML, state how the properties of the record appear in NWB, BIDS and openMINDS, including the change of unit, type, structure or vocabulary each standard needs; only the electrode structures of the NWB file are assembled in code, from the probes and their placements. From the record, fairephys converts the recordings to NWB (NeuroConv, with the probe geometry from ProbeInterface), writes the BIDS layout with its tables and sidecars, builds the openMINDS metadata for the EBRAINS Knowledge Graph (fairgraph) and adds a DataCite record and a dataset README.
4. **Check across all outputs.** fairephys compares the outputs with the raw data and with each other: raw samples against the NWB, the probe geometry of ProbeInterface against the BIDS electrodes table and the NWB electrode table, channel counts and names across BIDS and NWB. The BIDS validator, the NWB Inspector and fairgraph then check each output against its own standard.
Expand Down Expand Up @@ -68,7 +68,7 @@ How each of these steps works in the code (the modules behind it, the templates

## Scope

fairephys covers extracellular electrophysiology, both acute recordings with probes placed anew in each session and chronic recordings from implanted arrays. It converts the raw broadband recordings of Blackrock, SpikeGLX, TDT (tanks and SEV files) and Plexon (.pl2) systems; for other formats, the dataset's `curate.py` writes the NWB with the shared helpers of `fairephys.converters`. Beside the recording, the NWB can hold trials, time intervals, sorted units and behavioural series, and auxiliary signals (eye tracking, EMG, motion) become BIDS files of their own.
fairephys covers extracellular electrophysiology, both acute recordings with probes placed anew in each session and chronic recordings from implanted arrays. It converts the raw broadband recordings of Blackrock, SpikeGLX, TDT (tanks and SEV files) and Plexon (.pl2) systems; for other formats, the dataset's `curate.py` writes the NWB with the shared helpers of `fairephys.converters`. Beside the recording, the NWB can hold trials, time intervals, sorted units and behavioral series, and auxiliary signals (eye tracking, EMG, motion) become BIDS files of their own.

## Installation

Expand Down Expand Up @@ -109,7 +109,7 @@ uv run pytest

## License

MIT, see [LICENSE](LICENSE). Third-party files shipped with the package (the BIDS schema, the Creative Commons licence texts) are listed in [NOTICE.md](NOTICE.md).
MIT, see [LICENSE](LICENSE). Third-party files shipped with the package (the BIDS schema, the Creative Commons license texts) are listed in [NOTICE.md](NOTICE.md).

## Citation

Expand Down
14 changes: 7 additions & 7 deletions docs/pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ A dataset is described in YAML files under `metadata/curated/`, in the vocabular

| File | Describes |
|------|-----------|
| `dataset.yaml` | Name, description, licence, custodian, contributors, funding, related publications, related projects |
| `dataset.yaml` | Name, description, license, custodian, contributors, funding, related publications, related projects |
| `subject.yaml` | Species, sex, age, surgical preparation, and the implanted probes of a chronic recording |
| `hardware.yaml` | Recording system, hardware filters, probes, auxiliary devices (eye tracker, EMG, motion) |
| `protocol.yaml` | The behavioural protocol and stimulus presentation |
| `protocol.yaml` | The behavioral protocol and stimulus presentation |
| `recordings.yaml` | Per-session recording configuration of an acute recording: techniques and electrode placements |
| `sessions.yaml` | Session ids, dates, start times, tasks, subjects |
| `processing.yaml` | Processing steps actually performed (optional) |
Expand Down Expand Up @@ -214,22 +214,22 @@ Every script takes `--verbose` (debug logging), `--shared-metadata <dir>` (the c

## Adding Content to the NWB

Besides the recording, a dataset can write what it already holds (trials, time intervals, sorted units, sampled behavioural series) into the same NWB file. `run_conversion` takes a function that receives the NWB file after the recording is added and before it is written; nothing reopens a written file:
Besides the recording, a dataset can write what it already holds (trials, time intervals, sorted units, sampled behavioral series) into the same NWB file. `run_conversion` takes a function that receives the NWB file after the recording is added and before it is written; nothing reopens a written file:

```python
from fairephys.converters import add_trials, add_units

def add_behaviour(nwbfile):
def add_behavior(nwbfile):
add_trials(nwbfile, trials, TRIAL_COLUMNS, stub_test=stub_test) # DataFrame: start_time, stop_time, ...
add_units(nwbfile, units, UNIT_COLUMNS, description="Units sorted by the lab",
resolution=1 / sampling_rate, stub_test=stub_test)

converter.run_conversion(paths["nwb"], meta, stub_test=stub_test, add_to_nwbfile=add_behaviour)
converter.run_conversion(paths["nwb"], meta, stub_test=stub_test, add_to_nwbfile=add_behavior)
```

Each helper takes plain data and the dataset's own column descriptions. With `stub_test`, a helper cuts its content to the span of the stub recording (a table keeps the rows that overlap it, a unit its spikes inside it), so a stub stays a consistent short file.

`fairephys.events` reads the events these tables are built from: a Neo event channel, the epocs of a TDT tank, the trials of a MonkeyLogic BHV2 file, and `match_codes` to align two code sequences (for example the codes in the recording with those of the behaviour file). What the codes mean, and how a lab synchronizes its clocks, stays in the dataset's `curate.py`. The BIDS events files are written with `fairephys.bids.generate_events_tsv`.
`fairephys.events` reads the events these tables are built from: a Neo event channel, the epocs of a TDT tank, the trials of a MonkeyLogic BHV2 file, and `match_codes` to align two code sequences (for example the codes in the recording with those of the behavior file). What the codes mean, and how a lab synchronizes its clocks, stays in the dataset's `curate.py`. The BIDS events files are written with `fairephys.bids.generate_events_tsv`.

## Auxiliary Signals

Expand Down Expand Up @@ -275,7 +275,7 @@ The device channel indices of a session's `probe_group.json` are positions among

## ProbeInterface Integration

`probes/builder.py` creates ProbeInterface objects from odML (see `probes/README.md`): identity (name, manufacturer, model_name, serial_number), the other fields as annotations with their units, contact ids `01`, `02`, ... numbered from the tip, or from the top with `first contact: top` (library probes keep theirs), device channel indices from the placement or the channel mapping, and an `x_offset` annotation per probe for the side-by-side group layout. The PNG files, one per probe of more than one contact, show `contact id:device channel` per contact; `zoom=<um>` draws a dense probe whole beside its lowest `zoom` micrometers, labelled.
`probes/builder.py` creates ProbeInterface objects from odML (see `probes/README.md`): identity (name, manufacturer, model_name, serial_number), the other fields as annotations with their units, contact ids `01`, `02`, ... numbered from the tip, or from the top with `first contact: top` (library probes keep theirs), device channel indices from the placement or the channel mapping, and an `x_offset` annotation per probe for the side-by-side group layout. The PNG files, one per probe of more than one contact, show `contact id:device channel` per contact; `zoom=<um>` draws a dense probe whole beside its lowest `zoom` micrometers, labeled.

```python
from fairephys.probes import build_probe_group, build_session_probe_group, save_probe_group
Expand Down
2 changes: 1 addition & 1 deletion src/fairephys/_resources/registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Declarative mapping files that drive the metadata pipeline. Code reads these reg
| `openminds_schemas.yaml` | openMINDS entity definitions, odML type assignments | `export/collection.py`, `enrichment/openminds.py`, `metadata/compiler.py` |
| `bids_mappings.yaml` | odML property paths to BIDS sidecar fields and TSV columns, the target BIDS spec | `bids/builder.py`, `bids/aux.py`, `bids/ecephys.py`, `bids/dataset.py`, `converters/metadata.py`, `validation/bids.py`, `export/readme.py` |
| `nwb_mappings.yaml` | odML property paths to NWBFile and Subject fields, unit transforms | `converters/metadata.py` |
| `licenses.yaml` | licences by SPDX id: name and URL (texts in `_resources/licenses`) | `export/datacite.py`, `export/readme.py` |
| `licenses.yaml` | licenses by SPDX id: name and URL (texts in `_resources/licenses`) | `export/datacite.py`, `export/readme.py` |
| `readme.yaml` | text blocks of the generated dataset README | `export/readme.py` |

The anatomy atlas (brain region names and UBERON terms) is not a registry: a project names its own table in the collection YAML (`anatomy atlas`).
Expand Down
18 changes: 13 additions & 5 deletions src/fairephys/_resources/registry/licenses.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
# Licences a dataset can be shared under (the dataset template's "license"):
# SPDX id -> name and URL, as the DataCite record (datacite.yml), the LICENSE
# file and the data descriptor (README) write them. The names are those GIN's
# DOI service lists (it matches the datacite.yml name and the first line of
# LICENSE against them). The legal code of each id is _resources/licenses/<id>.txt.
# Licenses a dataset can be shared under (the dataset template's "license"):
# SPDX id -> name and URL, as the DataCite record (datacite.yml) and the LICENSE
# file write them. The names are those GIN's DOI service lists (it matches the
# datacite.yml name and the first line of LICENSE against them). The official
# name is the title of the legal code (_resources/licenses/<id>.txt), as the
# data descriptor (README) writes it.
CC-BY-4.0:
name: Creative Commons Attribution 4.0 International
official name: Creative Commons Attribution 4.0 International Public License
url: https://creativecommons.org/licenses/by/4.0/
CC-BY-SA-4.0:
name: Creative Commons Attribution-ShareAlike 4.0 International
official name: Creative Commons Attribution-ShareAlike 4.0 International Public License
url: https://creativecommons.org/licenses/by-sa/4.0/
CC-BY-NC-4.0:
name: Creative Commons Attribution-NonCommercial 4.0 International
official name: Creative Commons Attribution-NonCommercial 4.0 International Public License
url: https://creativecommons.org/licenses/by-nc/4.0/
CC-BY-NC-SA-4.0:
name: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
official name: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
url: https://creativecommons.org/licenses/by-nc-sa/4.0/
CC-BY-ND-4.0:
name: Creative Commons Attribution-NoDerivatives 4.0 International
official name: Creative Commons Attribution-NoDerivatives 4.0 International Public License
url: https://creativecommons.org/licenses/by-nd/4.0/
CC-BY-NC-ND-4.0:
name: Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
official name: Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License
url: https://creativecommons.org/licenses/by-nc-nd/4.0/
CC0-1.0:
name: Creative Commons CC0 1.0 Public Domain Dedication
official name: CC0 1.0 Universal
url: https://creativecommons.org/publicdomain/zero/1.0/
2 changes: 1 addition & 1 deletion src/fairephys/_resources/registry/openminds_schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ schemas:

# --- FileRepository (the repository of the curated data) ---
# Created per dataset from its repository url (the DOI archive URL when
# published, the repository URL during curation). The hosting organisation
# published, the repository URL during curation). The hosting organization
# and the kind of repository come from the collection metadata
# (collection.yaml: repository host, repository type), which a dataset
# deposited elsewhere overrides in its dataset.yaml.
Expand Down
16 changes: 8 additions & 8 deletions src/fairephys/_resources/registry/readme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ first use:
# {bids version}, bids_mappings.yaml spec), with ecephys files the sentence on
# where the content of the files is defined, and with a metadata folder the
# part beyond BIDS
layout standard: "The data are organised following the BIDS extension proposal {bids extension}, a draft extension of BIDS {bids version}."
layout standard without ecephys: "The data are organised following BIDS {bids version}."
layout standard: "The data are organized following the BIDS extension proposal {bids extension}, a draft extension of BIDS {bids version}."
layout standard without ecephys: "The data are organized following BIDS {bids version}."
layout definitions: "The content of the BIDS files is defined in the [BEP032 specification]({bids extension specification})."
layout metadata folder: >-
Beyond BIDS, the layout holds the folder `{metadata dir}/` with the odML record,
Expand All @@ -57,7 +57,7 @@ file name keys:
data type folders sentence: "The files of a session are in one folder per data type: {folders}."
data type folders:
ecephys: extracellular electrophysiology
beh: behaviour
beh: behavior
emg: electromyography
motion: motion tracking
anat: anatomical MRI
Expand Down Expand Up @@ -214,10 +214,10 @@ files:
content: Video recording
device type: video camera
- pattern: dataset_description.json
tree: "name, BIDS version, licence, authors, funding and references of the dataset"
tree: "name, BIDS version, license, authors, funding and references of the dataset"
format: JSON
content: >-
Name, BIDS version, licence, authors, funding, references and the
Name, BIDS version, license, authors, funding, references and the
software that generated the dataset
- pattern: participants.tsv
tree: "one row per subject"
Expand Down Expand Up @@ -278,11 +278,11 @@ files:
format: YAML
content: >-
Citation metadata for the DOI registration on GIN: title, authors,
description, keywords, licence, funding and references
description, keywords, license, funding and references
- pattern: LICENSE
tree: "licence of the dataset with its legal code"
tree: "license of the dataset with its legal code"
format: Text
content: Licence of the dataset with its legal code
content: License of the dataset with its legal code
- pattern: "probes/*.json"
tree: "contact geometry of one probe and the wiring of its contacts to the recording channels"
format: JSON (ProbeInterface)
Expand Down
2 changes: 1 addition & 1 deletion src/fairephys/_resources/templates/dataset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Dataset:
# Ethics details (documented in odML, not pushed to openMINDS entities)
ethics authority: "" # e.g., "IACUC" or local ethics committee
ethics approval id: "" # protocol/authorization number
licensed institution: "" # the licensed establishment: its name, its licence number, or both
licensed institution: "" # the licensed establishment: its name, its license number, or both
ethics directive: "" # e.g., "Directive 2010/63/EU"
authorizing body: "" # ministry or regulatory body
ethics statement: "" # full ethics declaration text
Expand Down
2 changes: 1 addition & 1 deletion src/fairephys/converters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NWB conversion using neuroconv with ProbeInterface integration.

## The hook: add_to_nwbfile

Both converters' `run_conversion(nwbfile_path, metadata, stub_test, add_to_nwbfile)` take the same hook: `add_to_nwbfile(nwbfile)` is called with the open `NWBFile` after neuroconv added the recording (its devices, electrode groups, electrode table and ElectricalSeries) and before the file is written, so a dataset's further content (trials, states, auxiliary and behavioural series, sorted units) goes into the same write. Nothing reopens a written file: a dataset never appends to an NWB. `EphysConverter.run_conversion` is neuroconv's sequence split open for the hook: `validate_metadata`, `create_nwbfile` (`make_nwbfile_from_metadata` and `add_to_nwbfile`), the hook, `write_nwbfile` (`configure_and_write_nwbfile`, neuroconv's chunking and compression). In a test file (`stub_test`) every recording stream is cut by `stub_recording` while it is written; the hook's content is cut by the helpers below.
Both converters' `run_conversion(nwbfile_path, metadata, stub_test, add_to_nwbfile)` take the same hook: `add_to_nwbfile(nwbfile)` is called with the open `NWBFile` after neuroconv added the recording (its devices, electrode groups, electrode table and ElectricalSeries) and before the file is written, so a dataset's further content (trials, states, auxiliary and behavioral series, sorted units) goes into the same write. Nothing reopens a written file: a dataset never appends to an NWB. `EphysConverter.run_conversion` is neuroconv's sequence split open for the hook: `validate_metadata`, `create_nwbfile` (`make_nwbfile_from_metadata` and `add_to_nwbfile`), the hook, `write_nwbfile` (`configure_and_write_nwbfile`, neuroconv's chunking and compression). In a test file (`stub_test`) every recording stream is cut by `stub_recording` while it is written; the hook's content is cut by the helpers below.

## The helpers: extras.py

Expand Down
Loading
Loading