我想使用 xarray 中的EEG数据。特别是,数据采用以下格式:通道x时间。通道维包含64个唯一的通道名称,这些名称又对应于头部的位置(因此具有3D坐标)。
我想创建一个DataArray
,我可以使用频道名称(例如“ Oz”)建立索引,但是它还以某种方式包含3D位置(例如,我可以在位置之间进行插值,或在3D空间中绘制它们。
在documentation中,提到了以下内容:
在此示例中,逻辑坐标为x和y,而物理坐标为xc和yc,它们代表数据的纬度和经度。
在我看来,这恰好适用于此:“逻辑”坐标是通道名称,而“物理”坐标是3d位置。
但是我如何创建它呢?
仅作为示例,这是一些虚拟数据:
import numpy as np
import xarray as xr
data = np.random.rand(64, 1024)
time = np.linspace(0, 1, 1024)
channel_names = [f"electrode {i}" for i in range(64)]
positions = np.random.randn(64, 3) # x, y and z for each channel
data_array = xr.DataArray(
data,
dims=['channel', 'time'],
coords={'channel': channel_names, 'time': time}
)
如何将位置作为逻辑坐标通道的物理坐标合并?
谢谢!