Hello,
I’m trying to visualize the directions of my gradiometers in my fif file,
I don’t understand the 12 values in infos.ch[loc].
normally the first 3 are the position of my sensor, I don’t understand what the other 9 values correspond to.
for the moment i’m using the 3:6 values to do it but i think it s wrong…
if anyone can help me i’d be really grateful.
import numpy as np
import matplotlib.pyplot as plt
import mne
from mpl_toolkits.mplot3d import Axes3D
raw_path=my_path
raw=mne.io.read_raw_fif(raw_path, preload=True)
Get sensor locations
sensor_locs = np.array([ch[‘loc’][:3] for ch in raw.info[‘chs’]])
sensor_orientations = np.array([ch[‘loc’][3:6] for ch in raw.info[‘chs’]])
Create a 3D scatter plot of sensor locations
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection=‘3d’)
Plot sensor locations
ax.scatter(sensor_locs[:, 0], sensor_locs[:, 1], sensor_locs[:, 2], c=‘blue’, marker=‘o’, label=‘Sensor Locations’)
Plot sensor orientations as arrows
scale_factor = 0.01 # Adjust the scale factor as needed
for loc, orientation in zip(sensor_locs, sensor_orientations):
ax.quiver(loc[0], loc[1], loc[2], orientation[0], orientation[1], orientation[2],
length=scale_factor, normalize=True, color=‘red’, label=‘Sensor Orientations’)
Label axes
ax.set_xlabel(‘X’)
ax.set_ylabel(‘Y’)
ax.set_zlabel(‘Z’)
Show the plot
ax.legend()
plt.show()
thank you very much …