Skip to content

[electrophysiology_browser] Dynamic channel metadata and visualization#10470

Draft
MaximeBICMTL wants to merge 6 commits intoaces:mainfrom
MaximeBICMTL:adaptative-channel-metadata
Draft

[electrophysiology_browser] Dynamic channel metadata and visualization#10470
MaximeBICMTL wants to merge 6 commits intoaces:mainfrom
MaximeBICMTL:adaptative-channel-metadata

Conversation

@MaximeBICMTL
Copy link
Copy Markdown
Contributor

@MaximeBICMTL MaximeBICMTL commented Apr 26, 2026

Builds on #10403

Description

This PR adds support for usable MEG display in the electrophysiology browser by replacing hard-coded EEG values with dynamic values based on the channel metadata and signal.

Features

  • Get the raw signal unit (V, T, T/m, s, ...) from the channel metadata instead of hard-coding V.
  • Derive the display channel unit (µV, fT...) and multiplication factor from that unit.
  • Compute the default channel amplitude from the signal values instead of using a hard-coded range for EEG.

Design choices

  • The channel units are obtained form the BIDS channels.tsv fields, read through the LORIS API (just like the type in the channel types).
  • The default channel amplitudes are computed per channel, not per channel type, this is because in the case of MEG, some channels can have largely different amplitudes than others.

Architecture

This PR also moves the channel metadata and BIDS channel information from the Redux-based state management to React contexts, which reduces prop drilling and makes them easier to use throughout the electrophysiology browser.

Backward-compatibility

This PR is backward-compatible with existing EEG acquisitions. If some metadata is not found, this PR falls back to assuming the acquisition is an EEG acquisition.

Performance:

This PR adds a O(n) scan on the signal values of visible channels to get the signal range. This did not cause noticeable lags in my tests even with 64 displayed channels.

Potential improvements

  • I think it would be preferable to get all the channel metadata from the acquisition file rather than the BIDS metadata files, but doing so is non-trivial so I prefer to hold off for now.
  • Maybe the electrophysiology browser should provide several channel amplitude strategies based on the user needs?
  • Maybe use the extracted signal range for the whole channel rather than only the displayed range? This is more performant but results in significantly flatter curves when the display range is too small.
  • Instead of absolute signal range, it might be preferable to use percentile-based signal range for the signal range in order to be more resistant to outliers, although I did not notice issues in my tests.

All these improvements can be added later IMO (although more metadata extract requires re-running the electrophysiology chunker script) and are easier to implement after this PR rather than before.

Screenshots

For the MPN MEG dataset:

[TODO]

For the EEG Face13 dataset:

[TODO]

add raisinbread sql

[SQL/MEG] Add the MEG CTF head shape tables (aces#10412)

The MEG CTF format uses a `headshape.pos` file to register the head
shape of the participant. This file is CTF-specific but BIDS-standard
(the BIDS MEG specification basically allows to use native files of all
specific data types), and is usually shared across all the MEG
acquisitions of a session.

This adds some tables to register this data in the LORIS
physiological database and link it to the relevant MEG files.

The `headshape.pos` file format is unfortunately very sparsely
documented. It is a textual file format whose contents looks like this:

```
85
1		5.60644227	-6.38055462	0.79194871
2		8.06310971	-4.72750212	0.59046631
3		7.58675759	-5.78050209	3.05185917
...
NAS	8.57169649	-0.14219376	-3.33998151
LPA	-0.58286578	7.02263278	0.27529669
RPA	-1.40471662	-7.10183109	0.57320080
```

The first line is the number of points. The coordinates are in
centimeters. It might be useful to use a proper
`physiological_coord_system` in the future, but this can easily be added
later IMO, so I'd like to start by merging this minimal implementation.
@github-actions github-actions Bot added Language: SQL PR or issue that update SQL code RaisinBread PR or issue introducing/requiring improvements to the Raidinbread dataset Language: PHP PR or issue that update PHP code Language: Javascript PR or issue that update Javascript code Module: electrophysiology_browser PR or issue related to electrophysiology_browser module Multilingual Any tasks related to making LORIS multilingual labels Apr 26, 2026
@MaximeBICMTL MaximeBICMTL marked this pull request as draft April 26, 2026 10:11
@MaximeBICMTL MaximeBICMTL changed the title [electrophysiology_browser] Adaptative channel metadata [electrophysiology_browser] Dynamic channel metadata and visualization Apr 26, 2026
@MaximeBICMTL MaximeBICMTL force-pushed the adaptative-channel-metadata branch from dc1fc25 to 55eccc5 Compare April 27, 2026 07:58
@MaximeBICMTL MaximeBICMTL force-pushed the adaptative-channel-metadata branch from 0b778c6 to 15b85a9 Compare April 27, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: Javascript PR or issue that update Javascript code Language: PHP PR or issue that update PHP code Language: SQL PR or issue that update SQL code Module: electrophysiology_browser PR or issue related to electrophysiology_browser module Multilingual Any tasks related to making LORIS multilingual RaisinBread PR or issue introducing/requiring improvements to the Raidinbread dataset

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant