開発版ドキュメント · 0.2.3 30c2f8ba · 入門例の検証対象 0.2.3 · 版情報 · 既知の制限

gwexpy.interop.mne_#

Functions

from_mne(cls, data, **kwargs)

Convert an MNE object to a gwexpy object.

from_mne_raw(cls, raw[, unit_map])

Create a TimeSeriesDict from mne.io.Raw.

to_mne(data[, info])

Convert a gwexpy object to an MNE object.

to_mne_rawarray(tsd[, info, picks])

Convert a TimeSeries-like object to an mne.io.RawArray.

gwexpy.interop.mne_.to_mne_rawarray(tsd, info=None, picks=None)#

Convert a TimeSeries-like object to an mne.io.RawArray.

パラメータ:
  • tsd -- TimeSeriesDict-like mapping (multi-channel) or a single TimeSeries.

  • info -- Optional MNE Info. If omitted, a minimal Info is created.

  • picks -- Optional channel selection (names or indices). Only supported for mapping inputs.

戻り値:

The converted MNE Raw object.

戻り値の型:

mne.io.RawArray

例外:
  • TypeError -- If picks is given for a single-channel input.

  • ValueError -- If info's channel count does not match the input; if mapping channels have mismatched sampling frequency, length, or (for same-length channels) epoch; or if t0 conflicts with an existing info["meas_date"].

  • LeapSecondConversionError -- If t0 falls on a leap second.

メモ

The input epoch (t0) is reconciled with info["meas_date"]: if info has no meas_date yet, it is set from t0 (unless t0 == 0, which leaves it unset); if info already has a meas_date, t0 -- including 0 -- is always compared against it, and a mismatch beyond ~1us raises ValueError instead of silently overwriting or ignoring it. A t0 that falls on a leap second raises LeapSecondConversionError.

For a mapping input, all channels must share the same sampling frequency; a mismatch always raises ValueError (previously stacked silently), even when channel lengths differ. Same-length channels are then stacked without resampling/alignment and must also share an exactly matching epoch; a mismatch raises ValueError (previously stacked silently). Only channels of differing length (with matching sampling frequency) are automatically aligned, via to_matrix() on a TimeSeriesDict input -- sampling-frequency or epoch mismatches are never auto-aligned and must be resolved by the caller beforehand.

A mixed exact/legacy mapping uses MNE's one shared official time axis for the legacy channels, while GWexpy retains exact epochs as private per-channel in-memory metadata. Exact channels must still agree exactly on epoch and sample interval; exact/exact conflicts are rejected.

gwexpy.interop.mne_.from_mne_raw(cls, raw, unit_map=None)#

Create a TimeSeriesDict from mne.io.Raw.

パラメータ:
  • cls -- The TimeSeriesDict-like class to construct and populate.

  • raw (mne.io.Raw) -- The MNE Raw object to convert.

  • unit_map (dict, optional) -- Optional mapping from channel name to unit, applied to the resulting TimeSeries entries. Channels absent from the mapping (or when unit_map is omitted) get unit=None.

戻り値:

A cls instance populated with one TimeSeries per channel.

戻り値の型:

TimeSeriesDict

メモ

The GPS epoch is reconstructed as datetime_utc_to_gps(raw.info["meas_date"]) + raw.first_samp / sfreq (or just the first_samp offset if meas_date is unset), so cropped or resumed Raw objects (first_samp > 0) get the correct absolute epoch instead of always starting at meas_date (or 0).

gwexpy.interop.mne_.to_mne(data, info=None, **kwargs)#

Convert a gwexpy object to an MNE object.

パラメータ:
  • data (FrequencySeries, Spectrogram, or TimeSeries (or dicts)) -- The data object to convert.

  • info (mne.Info, optional) -- Measurement info to use. If None, one is created.

  • **kwargs -- Additional arguments passed to MNE constructors.

戻り値:

The converted MNE object (e.g. RawArray, SpectrumArray, EpochsTFRArray).

戻り値の型:

mne_object

gwexpy.interop.mne_.from_mne(cls, data, **kwargs)#

Convert an MNE object to a gwexpy object.

パラメータ:
  • cls (type) -- The target class (e.g. FrequencySeries, Spectrogram, TimeSeries).

  • data (mne object) -- The MNE object to convert.

  • **kwargs -- Additional arguments passed to from_mne_* helpers.

戻り値の型:

gwexpy object