Incorrect scaling of complex multitaper coefficients with `normalization="full"`

Đã đóng Phù hợp với người mới
#14,493 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #14497 của @iis-MarkKuang — đã merge

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
data

Hướng nghiên cứu

Bắt đầu từ mne.time_frequency.psd_array_multitaper() và theo dõi cách chuẩn hóa được áp dụng cho output="complex"; so sánh hệ số tỷ lệ đó với đầu ra công suất và _psd_from_mt(). Dùng ví dụ tái hiện trong issue để kiểm tra rằng cả hai đường xử lý đều tạo ra các PSD khớp nhau với normalization="full" và "length"; hoàn thành khi cả hai tỷ số đều bằng 1.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

BUG
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.

Ngôn ngữ chính
Python
Star
3.6k
Fork
1.6k
Merge trung bình
1 ngày 18 giờ
Pull request đã merge (30 ngày)
71

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của mne-tools/mne-python

Tất cả issue của mne-tools/mne-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.