Skip to content

[electrophysiology_browser] Dynamic channel metadata and visualization#10470

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

[electrophysiology_browser] Dynamic channel metadata and visualization#10470
MaximeBICMTL wants to merge 3 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]

@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 2 times, most recently from 0b778c6 to 15b85a9 Compare April 27, 2026 12:12
@MaximeBICMTL MaximeBICMTL force-pushed the adaptative-channel-metadata branch from 15b85a9 to 1339962 Compare May 5, 2026 11:48
Comment on lines +36 to +37
lowerPercentile = 5,
upperPercentile = 95,
Copy link
Copy Markdown
Contributor Author

@MaximeBICMTL MaximeBICMTL May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably remove this rule from the Javascript linter IMO, I don't like not being able to specify the type of my parameters.

  33:3  error    Type number trivially inferred from a number literal, remove type annotation  @typescript-eslint/no-inferrable-types
  34:3  error    Type number trivially inferred from a number literal, remove type annotation  @typescript-eslint/no-inferrable-types

factorize get channel values

dynamic visible channel type range
@MaximeBICMTL MaximeBICMTL force-pushed the adaptative-channel-metadata branch from 1339962 to 9d3ca29 Compare May 5, 2026 11:55
@MaximeBICMTL MaximeBICMTL added Category: Feature PR or issue that aims to introduce a new feature Difficulty: Medium PR or issue that require a moderate effort or expertise to implement, review, or test and removed 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 Multilingual Any tasks related to making LORIS multilingual labels May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: Feature PR or issue that aims to introduce a new feature Difficulty: Medium PR or issue that require a moderate effort or expertise to implement, review, or test Language: Javascript PR or issue that update Javascript code Module: electrophysiology_browser PR or issue related to electrophysiology_browser module

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant