Repository navigation
Description
Hi @neuromechanist π
First, congratulations on the new data.nemar.org stack β nemar-cli,
neuroschema, nemar-citations, the central manifest epic (#559).
The metadata.json contract is already in beautiful shape, and reading
through dataset-metadata-columns.ts, llm-enrich.ts, and
emit_manifest.py made it obvious how much of what we need is
already computed on your side.
This issue is a small feature request to surface two pieces of data
the system already produces internally, so EEGDash (and any other
consumer β the nemar.org frontend would benefit too) can stop
re-deriving them. Happy to send PRs and/or co-design any part of it.
Companion technical write-up with the EEGDash-side cleanup that
this unblocks (~1,300 lines of NEMAR-specific code we'd retire):
08-NEMAR-API-SIMPLIFICATION.md.
What we'd love to see
Two additions, both small relative to the central manifest pattern
you already shipped:
GET /<id>/<version>/records.jsonβ array of per-data-file
neuroschema record documents (one per.edf/.bdf/.vhdr/
.set/.fif/.snirf). Conforms to
nemarOrg/neuroschema:schema/core/record.schema.jsonv0.3.0.bytes_urlfield on everymanifest.jsonfile entry β a
stable HTTPS URL that returns the actual data bytes (the S3
public URL resolved from the annex key, or the raw GitHub URL
for git-tracked files). Today consumers resolves3://nemar/<key>
by convention; the field would make that contract.
records.json example
[
{
"schema_version": "0.3.0",
"doc_type": "record",
"dataset": "nm000110",
"bids_relpath": "sub-chb01/eeg/sub-chb01_task-rest_run-01_eeg.edf",
"modality": "EEG",
"datatype": "eeg",
"suffix": "eeg",
"file_extension": ".edf",
"entities": { "subject": "chb01", "task": "rest", "run": "01" },
"signal_summary": {
"nchans": 23,
"ntimes": 921600,
"recording_duration": 3600.0,
"channel_type_counts": { "EEG": 21, "EOG": 2 }
},
"provenance": {
"extracted_at": "2026-05-24T06:14:00Z",
"extractor_version": "0.1.0"
}
}
]signal_properties is intentionally absent when nothing diverges
from dataset.signal_defaults β BIDS inheritance applies
(see neuroschema/docs/inheritance.md).
Per-channel arrays (full ch_names, sidecar JSON, TSV content)
belong in the rawDetail extension and a separate endpoint β out
of scope here.
manifest.json addition
One backward-compatible field per file entry:
{
"path": "sub-chb01/eeg/sub-chb01_task-rest_run-01_eeg.edf",
"size": 124573612,
"checksum_algorithm": "git",
"checksum": "abc123...",
"url": "https://raw.githubusercontent.com/nemarDatasets/nm000110/v1.0.1/...",
"bytes_url": "https://nemar.s3.us-east-2.amazonaws.com/SHA256E-s124573612--abc123.edf"
}For git-tracked files (checksum_algorithm: "git"), bytes_url
equals the existing url. For annex-keyed files it resolves to the
S3 public URL.
Architecture (mirrors #559)
No new infra needed. Same repository_dispatch β central workflow on
nemarDatasets/.github β S3 β webhook callback pattern that #559
established for manifest.json:
[Tag pushed on nemarDatasets/<id>]
β (existing GH App webhook, #559)
[POST /webhooks/dataset-release]
β
[triggerManifestGeneration()] β already exists; adds bytes_url
[triggerRecordsGeneration()] β new dispatch, parallel
β
[generate-manifest.yml + generate-records.yml on nemarDatasets/.github]
β
[s3://nemar/<id>/version/v<X.Y.Z>.json β manifest + bytes_url]
[s3://nemar/<id>/version/v<X.Y.Z>-records.json β new]
β
[POST /webhooks/manifest-ready]
[POST /webhooks/records-ready] β new
β
[GET /<id>/<version>/records.json] β new route on data.ts
Stability β open to your guidance here
Drafted following the patterns from epic #559 / #557. None of this
is novel; flagging the bits where a stricter or looser default would
help you.
- Feature flag
RECORDS_VIA_CENTRAL_WORKFLOW(defaultfalse),
mirrorsMANIFEST_VIA_CENTRAL_WORKFLOW. Per-env flip; dev first,
prod after a week of clean runs. - Idempotency:
records_jobs (dataset_id, version)UNIQUE.
Re-dispatching reuses the row when artifact exists + status is
uploaded, replaces it whenfailedor older than a 7-day TTL. - Callback HMAC: same one-shot HMAC as
/webhooks/manifest-ready. Storesha256(callback_token)in
records_jobs.callback_token_hash; never the secret. - S3 liveness probe: HEAD before serving. 502 with
reason: "artifact_unreachable"on HEAD failure. 404 with
reason: "records_pending"+Retry-After: 60for versions
whose dispatch is still in-flight. - Schema validation in CI: one workflow step running
python -m neuroschema.validate --doc-type record --array β¦
against the emitter's test-fixture output. Pinned neuroschema
version; un-pinned upgrades land as a separate PR. - Graceful degradation: records emission is fire-and-forget.
The publish flow does not block on it β DOI + manifest succeed
independently. Anemar admin records replay --since 24h
command re-dispatches failed rows. - Rate limits:
repository_dispatchis 5,000/hour per token, so
the dispatch rate is safe. CF cache ondata.nemar.orgcarries
the read load (Cache-Control: public, max-age=300+ ETag would
be ideal β happy to bundle ETag in this issue or split). - Observability: three structured log events per dispatch
(records.dispatch,records.ready,records.served); one
dashboard panel βcount(records.ready) / count(records.dispatch)
over 24h. - Rollback: flip the flag off β route 404, dispatch no-op, no
data lost.bytes_urlis a purely additive field β removable
with a one-line revert.
Suggested rollout
| Week | Records endpoint | Manifest bytes_url |
|---|---|---|
| 1 | flag on in dev | added in dev manifests |
| 2 | dev only, monitoring | dev only |
| 3 | flag on in prod for new versions | added in prod for new versions |
| 4β6 | backfill old prod versions via re-dispatch | backfill via same script |
| 7+ | EEGDash + frontend cut over | EEGDash + frontend cut over |
Old consumers see new fields appear; nothing requires immediate action.
No coordinated cutover.
Out of scope (separate issues, happy to file if useful)
- LLM enrichment of records (already covered by your
llm-enrich.ts). dataQualityextension (frame retention, ICA stats) β owned by
nemar-pipeline; separate issue.- Per-subject demographics (age, sex, handedness, pathology dict).
rawDetailextension β per-channel arrays, full sidecar JSON;
needs its own endpoint and access policy.- MEF3 and CTF (
.dsdirectory) header parsers β propose v0.2 of
the emitter; v1 covers EDF / BDF / BrainVision / EEGLAB / FIF /
SNIRF.
Two tiny companion PRs on nemarOrg/neuroschema
Both one-line fixes against v0.3.0 that block EEGDash adoption.
Happy to send these against neuroschema directly if you'd like:
schema/core/record.schema.jsonline 20:
"pattern": "^ds[0-9]+$"rejects everynm*andon*record.
Change to"^[a-z]{2}[0-9]+$"(matchesdataset_idin
dataset.schema.json).schema/extensions/eegdash.schema.jsonline 14:
storage.backendenum is missing"nemar". EEGDash uses it
for the git-annex key resolution backend.
Open questions for you
- Header readers in the central workflow vs. SDSC. The QA
pipeline already reads every file with EEGLAB and writes MAT
files. Re-reading with MNE in the new workflow duplicates that.
Would you prefer (a) parsing the MAT files (no MNE dependency in
the workflow, but cross-system coupling), or (b) re-reading with
MNE (simpler, more isolated)? My draft assumes (b); easy to
pivot. on*(OpenNeuro mirror) coverage. Should records emission
fire foron*datasets too, or staynm*-only initially? EEGDash
would benefit from parity but understands ifon*BIDS
validation differs.- ETag /
If-None-Matchon the JSON endpoints. Cheap to add;
lets downstream consumers conditional-fetch. Bundle in this
epic, or split into a follow-up? - Webhook for third parties. EEGDash would happily subscribe
to arecords-readypush event instead of polling β the
backend/src/routes/webhooks.tsinfra already exists. In scope
here, or a separate ask?
What this unblocks
After this lands, EEGDash retires three helper scripts (patch_nemar_source.py,
patch_nemar_records_storage.py, inject_nemar_citations.py),
drops the MNE branch from its ingestion pipeline, and converges its
NEMAR path with the Zenodo/OSF path: trust the upstream JSON, fetch
incrementally, upsert. Net ~1,300 lines removed. The nemar.org
frontend gains the same JSON contract and can stop calling the
legacy PHP dataexplorer API.
Truly grateful for the work you've put into the neuroschema spec
and the central manifest pattern β this issue is small precisely
because the heavy design lifting is already done. Let me know what
shape works best for you and I'll send PRs as soon as the architecture
is locked.
Thanks again π
Activity
feat(ingestion): switch NEMAR source to data.nemar.org + extract injeβ¦
chore(ingestion): cut non-essential docs from PR + ruff noqa cleanup
neuromechanist commentedon Jun 5, 2026
Hi Bruno β thank you for the unusually well-scoped issue; the fact that it maps almost 1:1 onto the central-manifest pattern is exactly why it's easy to say yes. We've locked the design on our side. Summary of decisions so you can send PRs against a stable contract, plus answers to your four questions and a separate note on nemar-py.
records.json β yes, with one internal refinement
Your consumption contract is accepted as-is:
GET /<id>/<version>/records.jsonreturning an array of neuroschemarecorddocs, one per primary signal file.The only change is internal and invisible to consumers: records.json is the committed
.nemar/records.jsonin the dataset repo (git-versioned, captured by the version tag, offline in full clones β same pattern as.nemar/metadata.json), and theversion/v<X>-records.jsonS3 snapshot is the served copy behind the endpoint. So you fetch the exact URL you proposed; we just also keep a git-provenanced source of truth. Cache:s-maxage=86400(immutable per version).signal_summary source β sidecar-first, not an MNE re-read
We're not re-reading every file with MNE (your Q1 option b). Instead, a tiered cascade that resolves ~99% from the git tree alone:
*_eeg.json/*_meg.jsonsidecars (RecordingDuration,SamplingFrequency,*ChannelCount) +channels.tsv(authoritative fornchansandchannel_type_counts) viagit cat-fileβ no header read, no annex fetch. This mirrors your own3_digest.pyprecedence, so we should land on identical numbers.RecordingDurationfield), we read the metadata our Zarr converter already produces with biosigIO (duration_s = n_samples/rate) β we read the computed mid-product, not a re-conversion..ds, KIT/4D,.snirf), we'll add importers upstream to biosigIO so it stays the single reader, rather than bolting MNE into the emitter. Until an importer lands, those rare recordings shiprecording_duration: null(graceful degradation).channel_type_countsalways comes fromchannels.tsvβ note the Zarr per-channelchannel_typeis EEGLAB-derived and not faithful, so please don't source it from the store. We'll set a per-recordprovenance.duration_source(sidecar|biosigio|null) so you can distinguish "pending" from "absent".bytes_url β yes, additive, but same-origin (not raw S3)
We'll add
bytes_urlto every manifest entry, but pointing at thedata.nemar.orgorigin (https://data.nemar.org/<id>/<version>/<bids_relpath>, which 302s to the bytes), not the raw S3 host. Two reasons:https://nemar.s3.us-east-2.amazonaws.com/SHA256E-...edfis actually wrong β blobs are content-addressed at<id>/objects/<annexKey>, not at a BIDS path, so that URL 404s. The correct stable raw form would behttps://nemar.s3.us-east-2.amazonaws.com/<id>/objects/<annexKey>.bytes_urlkeeps the official Python client'sassert_withinhonest.For EEGDash's anonymous-s3fs fast path you don't need a raw-S3
bytes_url: the manifest already exposes the annexkey, and<id>/objects/<key>is the stable public object URI (bucket is public-read post deny-list inversion). Forgit:filesbytes_url == url == raw.githubusercontent.com/....neuroschema
record.datasetFK pattern β fixed: fix: align record.dataset FK pattern to dataset_idΒ neuroschema#10 sets it to^[a-z]{2}[0-9]+$, bit-identical todataset_id. You were spot on that^ds[0-9]+$rejects everynm*/on*. We framed it as completing the half-applied v0.3.0 relaxation (the FK twin was missed inff27f7b). Noschema_versionbump.eegdash.storage.backendenum +"nemar"β this one we'd push back on:backendis a transport discriminator (s3/https/local), and"nemar"is a provider/host (data.nemar.org is plain HTTPS over S3 blobs, both already expressible). Suggest a separate optionalproviderfield rather than overloading the transport enum. It's your extension, so your call β happy either way, just flagging the semantics.Your four questions
on*coverage? In scope. biosigIO already readson*recordings (several are in our converted set), and records.json rides the same data plane that serveson*today.s-maxage=86400-immutable per version and the client verifies against body checksums, not HTTP ETag, so 304 buys little now.One thing to decide together: the
storageblockYour example record carries only
signal_summaryand omitsstorage. EEGDash's loader hard-requiresstorage{backend, base, raw_key, dep_keys}(esp.dep_keysto prefetchchannels.tsv/events/.fdtbefore the raw file). So records.json with onlysignal_summarywon't let EEGDash drop its dep-walk β the "~1,300 lines retired" is overstated without it. Proposal: v1 =signal_summary(ships now), v2 = optionalstorage/dep_keysblock once the core lands and validates. Want to co-design the v2storageshape? (Separately: I couldn't findpatch_nemar_source.py/patch_nemar_records_storage.pyin any EEGDash branch I fetched β the retireable code I see is3_digest.py:extract_record. Point me at the right branch if I'm looking in the wrong place.)The 429s (your earlier report)
Fixed in #699 β the data plane now gets a dedicated, much larger rate-limit bucket so a parallel
--jobs 16download doesn't trip the anonymous cap. (For context, the "many 302s" you saw are expected: the per-file route 302-redirects to the bytes; nothing's wrong there. And the earlier 403s were the pre-deny-list private/missing-object behavior, now resolved.)nemar-py β validated, recommend it with a short punch-list
I ran a full pass of nemar-py against the hardened contract. Net: safe to recommend for the standard
download()flow today. Solid parts: thechecksum_algorithm/checksumsplit parse, content-hash verification (incl. thegit:blob-SHA1 framing), version-tag normalization, path-traversal hardening, and the JSON control-plane same-origin check. Client items worth a small PR:_entry_to_filecan't parse the rawversion/v<X>.jsonshape ({key, size, checksum:"sha256:<hex>"}, nourl) thats3.version_urlpoints at β it falls back to size-only verification. Split a bare<algo>:<hex>checksum on the first:and recover algo+hash from the annexkey; or route all manifest reads throughmanifest.json(the split shape the parser already handles)._endpoint.py's "scoped to data.nemar.org" claim is a no-op for file bytes (per-fileassert_withinis intentionally not called, and every manifesturlis off-origin by design). Either re-enable the check against a trusted-netloc allow-list (data.nemar.org,nemar.s3.us-east-2.amazonaws.com,raw.githubusercontent.com) or soften the docstring to match reality.bytes_urlto_first_value's url-key list so a futurebytes_url-only entry doesn't synthesize a path-relative URL.Retry-Afteron 503/429; makeDatasetIndex.latestOptional[str](we return200 + latest:nullfor exists-but-unpublished).(One I initially over-weighted and am now standing down: expired-presign mid-download. The default
autopath is direct anonymous S3 with no presigned URL, and the data plane is public-only, so it doesn't bite the normal flow β not a blocker.)Confirming the structure you assumed (
objects/,version/<v>.json,version/<v>-summary.json,archives/<v>.zip) and the s3 β datalad β https order both match our roadmap, so you're building against the right contract.Thanks again β send the neuroschema follow-ups and nemar-py PRs whenever; we'll take the emitter + route + bytes_url on our side and ping you for the v2
storageco-design.feat: add stable same-origin bytes_url to manifest.json (#615) (#700)
Phase 2: serve GET /<id>/<version>/records.json (#615) (#706)
refactor: make bytes_url host-invariant (canonical data.nemar.org)
records.json serving (epic #615): data plane route (#707)
Add records.json pointers to data.nemar.org index pages (#722)
neuromechanist commentedon Jun 8, 2026
@bruAristimunha both parts of this are now implemented and live on production. π
1.
records.jsonEndpoint:
GET https://data.nemar.org/<id>/<version>/records.json<version>is thev-prefixed tag (v1.1.1) or the aliaslatest. Bare1.1.1(nov) returns 404.Shape: a JSON array of neuroschema v0.3.0
recorddocuments β one per primary signal file (.edf/.bdf/.set/.vhdr/.fif/...). Each record carries:{ "schema_version": "0.3.0", "doc_type": "record", "dataset": "nm000132", "modality": "EEG", "datatype": "eeg", "suffix": "eeg", "file_extension": ".set", "bids_relpath": "sub-01/eeg/sub-01_task-..._eeg.set", "entities": { ... }, "signal_summary": { "nchans": 33, "ntimes": 622592, "recording_duration": 608, "sampling_frequency": 1024, "channel_type_counts": { ... } } }Durations are resolved from the BIDS sidecar first, then via a biosigIO header read for files whose sidecar omits
RecordingDuration(so MEG/EEG without that field still get a value; the rare formats biosigIO can't read yet degrade torecording_duration: null).Coverage: the full backfill is done β every published version (latest + older) has a
records.jsonsnapshot, so nothing 404s. Going forward, it's emitted automatically on each version publish.2.
manifest.bytes_urlEvery entry in
GET /<id>/<version>/manifest.jsonnow has an additive, same-originbytes_url:raw.githubusercontent.com/...@<tag>https://data.nemar.org/<id>/<version>/<path>(302s to a fresh presigned S3 URL each request β no expiry to manage). Same-origin so nemar-py'sassert_withinaccepts it.Bonus
The
data.nemar.org/<id>/index pages now linkrecords.jsonnext tomanifest.json(version table + per-version footer), so it's discoverable by browsing.Known scope / possible v2
records.jsoncurrently carriessignal_summarybut not astorageblock (backend/base/raw_key/dep_keys). If EEGDash wants to drop its dep-walk entirely, let's decide together whether records.json should add that block. Also tracking a couple of follow-ups (biosigIO importers for CTF.ds/KIT MEG; asampling_frequencyedge case) β happy to coordinate.Released in nemar-cli v0.8.48 (route + bytes_url) and v0.8.49 (index links). Leaving this open for the v2
storage-block discussion β let me know how you'd like to proceed.feat(ingest): NEMAR records.json fast-path for exact signal_summary
feat(ingestion): switch NEMAR source to data.nemar.org + extract injeβ¦
chore(ingestion): cut non-essential docs from PR + ruff noqa cleanup