OPM sensor direction set

For OPM MEG, raw.info[‘chs’][ ‘ num ’ ][‘loc’] [3:12] give the OPM sensor direction,called rotation matrix. But if the normal direction of meg sensor is know (n1,n2,n3) only,How can we get the rotation matrix (e11,e12,e13;e21,e22,e23;e31,e32,e33)?

  • MNE version: 1.3
  • operating system: Windows 10

Hello!

I had the same problem, I had to calculate the rotation matrix which transforms the unit vector (0,0,1) to normal direction of meg sensor (n1,n2,n3). You can try this function create_rot_matrix(v1, v2) which can be found in my package megtools inside vector_functions.py (see megtools/vector_functions.py at master · UrbanM/megtools · GitHub)

I used this as following, where holders[i,0:6] is my array of sensor locations and directions.

	unit_v = np.array([0.0, 0.0, 1.0])
	for i in range(len(raw.ch_names)):
		rot_mat = vfun.create_rot_matrix(holders[i, 3:6], unit_v)
		raw.info['chs'][i]['loc'] = np.array(
			[holders[i, 0], holders[i, 1], holders[i, 2], rot_mat[0, 0], rot_mat[0, 1], rot_mat[0, 2],
			rot_mat[1, 0], rot_mat[1, 1], rot_mat[1, 2], rot_mat[2, 0], rot_mat[2, 1], rot_mat[2, 2]])