Incorrect scaling of complex multitaper coefficients with `normalization="full"`
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #14497 @iis-MarkKuang による — マージ済み
評価
調査の方向性
mne.time_frequency.psd_array_multitaper()から始め、output="complex"に対して正規化がどのように適用されるかを追い、パワー出力および_psd_from_mt()のスケーリングと比較します。issueの再現コードを使って、両方の経路でnormalization="full"と"length"の場合に一致するPSDが得られることを確認します。両方の比が1なら完了です。
索引モデルが issue の本文から書いたものです。
説明
Description of the problem
normalization="full" in psd_array_multitaper() scales the data by 1/sfreq. This is fine for output="power", but for output="complex", the scaling should be 1/sqrt(sfreq).
Because of this, power subsequently computed from the coefficients (including in Spectrum.plot()) is of a much smaller scale than if output="power" was used.
Steps to reproduce
import numpy as np
from mne.time_frequency import psd_array_multitaper
from mne.time_frequency.multitaper import _psd_from_mt
sfreq = 100.0
x = np.random.default_rng(0).standard_normal((1, 1000))
for normalization in ("length", "full"):
psd, _ = psd_array_multitaper(
x, sfreq, normalization=normalization, output="power", verbose=False
)
coefs, _, weights = psd_array_multitaper(
x, sfreq, normalization=normalization, output="complex", verbose=False
)
psd_from_coefs = _psd_from_mt(coefs, weights)
print(f"{normalization}: ratio = {np.unique((psd_from_coefs / psd).round(6))}")
Link to data
No response
Expected results
The PSD constructed directly and subsequently computed from the complex coefficients are identical.
Actual results
With normalization="full", the PSD subsequently computed from the complex coefficients are scaled by 1/sfreq relative to the PSD constructed directly.
length: ratio = [1.]
full: ratio = [0.01]
Additional information
AI disclosure: was initially picked up by Claude Opus 5.5, and further investigated by myself.
- 主要言語
- Python
- スター
- 3.6k
- フォーク
- 1.6k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 71
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
mne-tools/mne-python のほかの issue
-
`mne.stats.f_oneway` returns wrong (even negative) F for small integer dtypes対応中かも @darshpatel1052 が 3 日前に担当しました。 オープンBUG
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
mne-tools/mne-python#14477 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
ENH: Add `description` filter parameter to `Raw.crop_by_annotations()`対応中かも @aman-coder03 が 214 日前に担当しました。 オープンENH
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mne-tools/mne-python#13743 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
BUG
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
mne-tools/mne-python#14502 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
cannot plot into matplotlib subfigure対応中かも @ishaaaan17 が 4 日前に担当しました。 オープンBUG
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
mne-tools/mne-python#14481 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
BUG: One layer BEM construction fails for current ANTS6-0Months3T template対応中かも @sruthisureshkumar-arch が 5 日前に担当しました。 オープンBUG
難易度 3/5 1〜2日 初心者へのやさしさ 57/100
mne-tools/mne-python#14468 · コメント 8 件 ·
メンテナーはふだん 1 日以内に返信
mne-tools/mne-python の issue をすべて見る
似ている issue
-
Remove the `pull_request_target` workflow before GitHub blocks it対応中かも @jat255 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
IBM/mcp-context-forge#7483 ·
メンテナーはふだん 2 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
[Bug Report]: OpenAI 辅助 API 连通性测试因输出上限仅 1 token 误报“未知错误”対応中かも @fjfanjian が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Project-N-E-K-O/N.E.K.O#3640 ·
メンテナーはふだん 1 日以内に返信
-
author-page correction
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
acl-org/acl-anthology#10808 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信