Note
Click here to download the full example code
Extracting and visualizing subject head movement¶
Continuous head movement can be encoded during MEG recordings by use of HPI coils that continuously emit sinusoidal signals. These signals can then be extracted from the recording and used to estimate head position as a function of time. Here we show an example of how to do this, and how to visualize the result.
HPI frequencies¶
First let’s load a short bit of raw data where the subject intentionally moved their head during the recording. Its power spectral density shows five peaks (most clearly visible in the gradiometers) corresponding to the HPI coil frequencies, plus other peaks related to power line interference (60 Hz and harmonics).
# Authors: Eric Larson <larson.eric.d@gmail.com>
#
# License: BSD (3-clause)
from os import path as op
import mne
print(__doc__)
data_path = op.join(mne.datasets.testing.data_path(verbose=True), 'SSS')
fname_raw = op.join(data_path, 'test_move_anon_raw.fif')
raw = mne.io.read_raw_fif(fname_raw, allow_maxshield='yes').load_data()
raw.plot_psd()
Out:
Opening raw data file /home/circleci/mne_data/MNE-testing-data/SSS/test_move_anon_raw.fif...
Read a total of 12 projection items:
mag.fif : PCA-v1 (1 x 306) idle
mag.fif : PCA-v2 (1 x 306) idle
mag.fif : PCA-v3 (1 x 306) idle
mag.fif : PCA-v4 (1 x 306) idle
mag.fif : PCA-v5 (1 x 306) idle
mag.fif : PCA-v6 (1 x 306) idle
mag.fif : PCA-v7 (1 x 306) idle
grad.fif : PCA-v1 (1 x 306) idle
grad.fif : PCA-v2 (1 x 306) idle
grad.fif : PCA-v3 (1 x 306) idle
grad.fif : PCA-v4 (1 x 306) idle
Average EEG reference (1 x 60) idle
Range : 10800 ... 31199 = 9.000 ... 25.999 secs
Ready.
Reading 0 ... 20399 = 0.000 ... 16.999 secs...
Effective window size : 1.707 (s)
Effective window size : 1.707 (s)
Effective window size : 1.707 (s)
Estimating continuous head position¶
First, let’s extract the HPI coil amplitudes as a function of time:
Out:
Using 5 HPI coils: 83 143 203 263 323 Hz
Line interference frequencies: 60 120 180 240 300 360 Hz
Using time window: 83.3 ms
Fitting 5 HPI coil locations at up to 1696 time points (17.0 sec duration)
0%| | cHPI amplitudes : 0/1696 [00:00<?, ?it/s]
0%| | cHPI amplitudes : 1/1696 [00:02<1:13:12, 2.59s/it]
1%|1 | cHPI amplitudes : 23/1696 [00:02<03:00, 9.26it/s]
3%|2 | cHPI amplitudes : 46/1696 [00:02<01:27, 18.90it/s]
3%|2 | cHPI amplitudes : 50/1696 [00:02<01:20, 20.46it/s]
4%|4 | cHPI amplitudes : 71/1696 [00:02<00:54, 29.96it/s]
5%|5 | cHPI amplitudes : 93/1696 [00:02<00:39, 40.27it/s]
7%|6 | cHPI amplitudes : 116/1696 [00:02<00:31, 50.18it/s]
8%|7 | cHPI amplitudes : 133/1696 [00:02<00:26, 58.43it/s]
9%|9 | cHPI amplitudes : 155/1696 [00:02<00:22, 69.62it/s]
10%|# | cHPI amplitudes : 178/1696 [00:02<00:18, 81.74it/s]
11%|# | cHPI amplitudes : 179/1696 [00:02<00:18, 79.94it/s]
12%|#1 | cHPI amplitudes : 200/1696 [00:02<00:16, 91.57it/s]
13%|#3 | cHPI amplitudes : 222/1696 [00:02<00:14, 104.19it/s]
14%|#4 | cHPI amplitudes : 244/1696 [00:02<00:12, 113.53it/s]
15%|#5 | cHPI amplitudes : 262/1696 [00:02<00:11, 124.00it/s]
16%|#6 | cHPI amplitudes : 276/1696 [00:02<00:10, 132.07it/s]
17%|#7 | cHPI amplitudes : 291/1696 [00:03<00:10, 136.16it/s]
18%|#7 | cHPI amplitudes : 305/1696 [00:03<00:09, 144.46it/s]
19%|#8 | cHPI amplitudes : 319/1696 [00:03<00:09, 152.97it/s]
20%|#9 | cHPI amplitudes : 334/1696 [00:03<00:08, 162.48it/s]
20%|#9 | cHPI amplitudes : 335/1696 [00:03<00:08, 156.88it/s]
21%|## | cHPI amplitudes : 349/1696 [00:03<00:08, 166.06it/s]
21%|##1 | cHPI amplitudes : 363/1696 [00:03<00:07, 175.40it/s]
22%|##2 | cHPI amplitudes : 379/1696 [00:03<00:07, 178.87it/s]
23%|##3 | cHPI amplitudes : 393/1696 [00:03<00:06, 188.41it/s]
24%|##3 | cHPI amplitudes : 407/1696 [00:03<00:06, 198.10it/s]
25%|##4 | cHPI amplitudes : 420/1696 [00:03<00:06, 197.82it/s]
26%|##5 | cHPI amplitudes : 435/1696 [00:03<00:06, 208.49it/s]
27%|##7 | cHPI amplitudes : 458/1696 [00:03<00:05, 227.06it/s]
28%|##8 | cHPI amplitudes : 482/1696 [00:03<00:04, 246.98it/s]
29%|##8 | cHPI amplitudes : 484/1696 [00:03<00:05, 236.55it/s]
30%|##9 | cHPI amplitudes : 506/1696 [00:03<00:04, 255.02it/s]
31%|###1 | cHPI amplitudes : 529/1696 [00:03<00:04, 274.81it/s]
33%|###2 | cHPI amplitudes : 553/1696 [00:03<00:03, 295.99it/s]
33%|###2 | cHPI amplitudes : 554/1696 [00:03<00:04, 280.67it/s]
34%|###3 | cHPI amplitudes : 576/1696 [00:03<00:03, 300.13it/s]
35%|###5 | cHPI amplitudes : 599/1696 [00:03<00:03, 320.94it/s]
37%|###6 | cHPI amplitudes : 622/1696 [00:03<00:03, 322.57it/s]
38%|###7 | cHPI amplitudes : 643/1696 [00:03<00:03, 340.82it/s]
39%|###9 | cHPI amplitudes : 665/1696 [00:03<00:02, 360.45it/s]
40%|#### | cHPI amplitudes : 686/1696 [00:03<00:02, 356.62it/s]
41%|####1 | cHPI amplitudes : 701/1696 [00:03<00:02, 367.41it/s]
43%|####2 | cHPI amplitudes : 723/1696 [00:03<00:02, 387.03it/s]
44%|####3 | cHPI amplitudes : 745/1696 [00:03<00:02, 382.53it/s]
45%|####4 | cHPI amplitudes : 759/1696 [00:03<00:02, 392.02it/s]
46%|####5 | cHPI amplitudes : 773/1696 [00:03<00:02, 401.51it/s]
46%|####6 | cHPI amplitudes : 788/1696 [00:03<00:02, 386.98it/s]
48%|####7 | cHPI amplitudes : 809/1696 [00:03<00:02, 405.68it/s]
49%|####8 | cHPI amplitudes : 831/1696 [00:03<00:02, 425.88it/s]
50%|##### | cHPI amplitudes : 854/1696 [00:03<00:01, 447.52it/s]
50%|##### | cHPI amplitudes : 855/1696 [00:04<00:02, 418.23it/s]
52%|#####1 | cHPI amplitudes : 877/1696 [00:04<00:01, 438.56it/s]
53%|#####3 | cHPI amplitudes : 899/1696 [00:04<00:01, 459.39it/s]
54%|#####4 | cHPI amplitudes : 921/1696 [00:04<00:01, 447.70it/s]
56%|#####5 | cHPI amplitudes : 943/1696 [00:04<00:01, 467.62it/s]
57%|#####6 | cHPI amplitudes : 965/1696 [00:04<00:01, 488.04it/s]
58%|#####8 | cHPI amplitudes : 988/1696 [00:04<00:01, 474.86it/s]
60%|#####9 | cHPI amplitudes : 1010/1696 [00:04<00:01, 494.46it/s]
61%|###### | cHPI amplitudes : 1032/1696 [00:04<00:01, 514.60it/s]
62%|######2 | cHPI amplitudes : 1054/1696 [00:04<00:01, 497.13it/s]
63%|######3 | cHPI amplitudes : 1075/1696 [00:04<00:01, 515.40it/s]
65%|######4 | cHPI amplitudes : 1097/1696 [00:04<00:01, 535.25it/s]
66%|######6 | cHPI amplitudes : 1120/1696 [00:04<00:01, 517.08it/s]
67%|######7 | cHPI amplitudes : 1142/1696 [00:04<00:01, 536.03it/s]
69%|######8 | cHPI amplitudes : 1164/1696 [00:04<00:00, 555.57it/s]
70%|######9 | cHPI amplitudes : 1187/1696 [00:04<00:00, 576.57it/s]
70%|####### | cHPI amplitudes : 1188/1696 [00:04<00:00, 534.93it/s]
71%|#######1 | cHPI amplitudes : 1210/1696 [00:04<00:00, 554.56it/s]
73%|#######2 | cHPI amplitudes : 1232/1696 [00:04<00:00, 574.70it/s]
74%|#######3 | cHPI amplitudes : 1255/1696 [00:04<00:00, 551.88it/s]
75%|#######5 | cHPI amplitudes : 1274/1696 [00:04<00:00, 566.86it/s]
76%|#######6 | cHPI amplitudes : 1296/1696 [00:04<00:00, 586.66it/s]
78%|#######7 | cHPI amplitudes : 1319/1696 [00:04<00:00, 607.96it/s]
78%|#######7 | cHPI amplitudes : 1320/1696 [00:04<00:00, 561.53it/s]
79%|#######9 | cHPI amplitudes : 1342/1696 [00:04<00:00, 581.43it/s]
80%|######## | cHPI amplitudes : 1365/1696 [00:04<00:00, 602.84it/s]
82%|########1 | cHPI amplitudes : 1387/1696 [00:04<00:00, 575.32it/s]
83%|########3 | cHPI amplitudes : 1409/1696 [00:04<00:00, 594.80it/s]
84%|########4 | cHPI amplitudes : 1431/1696 [00:04<00:00, 614.76it/s]
86%|########5 | cHPI amplitudes : 1454/1696 [00:04<00:00, 636.08it/s]
86%|########5 | cHPI amplitudes : 1455/1696 [00:04<00:00, 585.81it/s]
87%|########7 | cHPI amplitudes : 1476/1696 [00:04<00:00, 604.06it/s]
88%|########8 | cHPI amplitudes : 1498/1696 [00:04<00:00, 624.52it/s]
90%|########9 | cHPI amplitudes : 1520/1696 [00:05<00:00, 592.56it/s]
90%|######### | cHPI amplitudes : 1534/1696 [00:05<00:00, 599.38it/s]
91%|#########1| cHPI amplitudes : 1549/1696 [00:05<00:00, 607.70it/s]
92%|#########2| cHPI amplitudes : 1564/1696 [00:05<00:00, 568.67it/s]
93%|#########3| cHPI amplitudes : 1578/1696 [00:05<00:00, 576.44it/s]
94%|#########3| cHPI amplitudes : 1593/1696 [00:05<00:00, 585.30it/s]
95%|#########4| cHPI amplitudes : 1609/1696 [00:05<00:00, 549.04it/s]
96%|#########5| cHPI amplitudes : 1624/1696 [00:05<00:00, 557.99it/s]
97%|#########6| cHPI amplitudes : 1640/1696 [00:05<00:00, 568.53it/s]
98%|#########7| cHPI amplitudes : 1655/1696 [00:05<00:00, 534.36it/s]
98%|#########8| cHPI amplitudes : 1670/1696 [00:05<00:00, 543.80it/s]
99%|#########9| cHPI amplitudes : 1685/1696 [00:05<00:00, 553.40it/s]
100%|##########| cHPI amplitudes : 1696/1696 [00:05<00:00, 314.43it/s]
Second, let’s compute time-varying HPI coil locations from these:
Out:
Computing 4385 HPI location guesses (1 cm grid in a 10.7 cm sphere)
HPIFIT: 5 coils digitized in order 5 1 4 3 2
HPI consistency of isotrak and hpifit is OK.
0%| | cHPI locations : 0/1696 [00:00<?, ?it/s]
0%| | cHPI locations : 1/1696 [00:00<19:27, 1.45it/s]
2%|1 | cHPI locations : 28/1696 [00:00<00:43, 38.02it/s]
4%|3 | cHPI locations : 65/1696 [00:00<00:18, 88.91it/s]
6%|5 | cHPI locations : 101/1696 [00:00<00:14, 109.04it/s]
7%|7 | cHPI locations : 124/1696 [00:01<00:12, 124.71it/s]
9%|9 | cHPI locations : 160/1696 [00:01<00:09, 162.93it/s]
12%|#1 | cHPI locations : 197/1696 [00:01<00:07, 202.82it/s]
12%|#1 | cHPI locations : 201/1696 [00:01<00:08, 169.70it/s]
13%|#3 | cHPI locations : 227/1696 [00:01<00:08, 181.01it/s]
16%|#5 | cHPI locations : 264/1696 [00:01<00:06, 215.07it/s]
18%|#7 | cHPI locations : 301/1696 [00:01<00:06, 211.43it/s]
20%|#9 | cHPI locations : 337/1696 [00:01<00:05, 241.08it/s]
22%|##2 | cHPI locations : 374/1696 [00:01<00:04, 272.26it/s]
23%|##2 | cHPI locations : 382/1696 [00:01<00:04, 264.46it/s]
24%|##3 | cHPI locations : 401/1696 [00:01<00:05, 235.57it/s]
26%|##5 | cHPI locations : 437/1696 [00:01<00:04, 262.96it/s]
28%|##7 | cHPI locations : 474/1696 [00:01<00:04, 291.84it/s]
29%|##8 | cHPI locations : 487/1696 [00:01<00:04, 287.35it/s]
30%|##9 | cHPI locations : 501/1696 [00:02<00:04, 252.13it/s]
32%|###1 | cHPI locations : 537/1696 [00:02<00:04, 277.89it/s]
33%|###2 | cHPI locations : 559/1696 [00:02<00:05, 223.21it/s]
33%|###3 | cHPI locations : 568/1696 [00:02<00:05, 189.41it/s]
34%|###3 | cHPI locations : 573/1696 [00:03<00:06, 163.78it/s]
34%|###4 | cHPI locations : 577/1696 [00:03<00:07, 143.65it/s]
34%|###4 | cHPI locations : 581/1696 [00:03<00:08, 126.98it/s]
35%|###4 | cHPI locations : 587/1696 [00:04<00:09, 114.62it/s]
35%|###5 | cHPI locations : 600/1696 [00:04<00:10, 106.90it/s]
37%|###6 | cHPI locations : 625/1696 [00:04<00:09, 112.92it/s]
39%|###9 | cHPI locations : 666/1696 [00:04<00:08, 128.15it/s]
41%|####1 | cHPI locations : 700/1696 [00:04<00:07, 127.15it/s]
44%|####3 | cHPI locations : 740/1696 [00:04<00:06, 141.68it/s]
46%|####6 | cHPI locations : 782/1696 [00:04<00:05, 157.59it/s]
47%|####6 | cHPI locations : 789/1696 [00:05<00:06, 143.37it/s]
47%|####6 | cHPI locations : 794/1696 [00:05<00:06, 130.11it/s]
47%|####7 | cHPI locations : 800/1696 [00:05<00:07, 118.97it/s]
47%|####7 | cHPI locations : 805/1696 [00:05<00:08, 109.19it/s]
48%|####7 | cHPI locations : 810/1696 [00:06<00:08, 100.63it/s]
48%|####8 | cHPI locations : 815/1696 [00:06<00:09, 93.22it/s]
48%|####8 | cHPI locations : 819/1696 [00:06<00:10, 86.32it/s]
49%|####8 | cHPI locations : 823/1696 [00:07<00:10, 80.46it/s]
49%|####8 | cHPI locations : 827/1696 [00:07<00:11, 75.19it/s]
49%|####9 | cHPI locations : 833/1696 [00:07<00:12, 70.88it/s]
50%|##### | cHPI locations : 848/1696 [00:08<00:12, 69.29it/s]
52%|#####1 | cHPI locations : 876/1696 [00:08<00:10, 75.08it/s]
54%|#####4 | cHPI locations : 918/1696 [00:08<00:09, 86.10it/s]
56%|#####5 | cHPI locations : 948/1696 [00:08<00:08, 87.43it/s]
58%|#####8 | cHPI locations : 988/1696 [00:08<00:07, 98.06it/s]
61%|###### | cHPI locations : 1030/1696 [00:08<00:06, 109.72it/s]
61%|######1 | cHPI locations : 1040/1696 [00:08<00:06, 103.82it/s]
62%|######1 | cHPI locations : 1051/1696 [00:09<00:06, 98.39it/s]
63%|######2 | cHPI locations : 1062/1696 [00:09<00:06, 93.49it/s]
63%|######3 | cHPI locations : 1070/1696 [00:09<00:06, 93.70it/s]
63%|######3 | cHPI locations : 1072/1696 [00:09<00:07, 88.61it/s]
64%|######3 | cHPI locations : 1079/1696 [00:09<00:06, 88.69it/s]
64%|######4 | cHPI locations : 1086/1696 [00:09<00:07, 85.20it/s]
65%|######4 | cHPI locations : 1095/1696 [00:10<00:06, 85.90it/s]
67%|######6 | cHPI locations : 1136/1696 [00:10<00:05, 97.55it/s]
69%|######9 | cHPI locations : 1178/1696 [00:10<00:04, 110.00it/s]
70%|######9 | cHPI locations : 1186/1696 [00:10<00:04, 103.56it/s]
72%|#######2 | cHPI locations : 1227/1696 [00:10<00:04, 115.83it/s]
75%|#######4 | cHPI locations : 1269/1696 [00:10<00:03, 128.95it/s]
76%|#######5 | cHPI locations : 1286/1696 [00:10<00:03, 123.12it/s]
76%|#######6 | cHPI locations : 1296/1696 [00:10<00:03, 114.99it/s]
77%|#######6 | cHPI locations : 1301/1696 [00:11<00:03, 106.54it/s]
77%|#######7 | cHPI locations : 1306/1696 [00:11<00:03, 99.04it/s]
77%|#######7 | cHPI locations : 1311/1696 [00:11<00:04, 92.21it/s]
78%|#######7 | cHPI locations : 1315/1696 [00:12<00:04, 86.12it/s]
78%|#######7 | cHPI locations : 1319/1696 [00:12<00:04, 80.63it/s]
78%|#######8 | cHPI locations : 1325/1696 [00:12<00:04, 76.11it/s]
78%|#######8 | cHPI locations : 1331/1696 [00:12<00:04, 73.50it/s]
79%|#######9 | cHPI locations : 1341/1696 [00:13<00:05, 70.58it/s]
80%|#######9 | cHPI locations : 1351/1696 [00:13<00:04, 71.72it/s]
82%|########1 | cHPI locations : 1390/1696 [00:13<00:03, 81.61it/s]
84%|########4 | cHPI locations : 1431/1696 [00:13<00:02, 92.47it/s]
85%|########4 | cHPI locations : 1441/1696 [00:13<00:02, 90.43it/s]
87%|########6 | cHPI locations : 1468/1696 [00:13<00:02, 96.01it/s]
89%|########8 | cHPI locations : 1509/1696 [00:13<00:01, 107.64it/s]
91%|######### | cHPI locations : 1541/1696 [00:13<00:01, 110.28it/s]
91%|#########1| cHPI locations : 1545/1696 [00:13<00:01, 109.15it/s]
92%|#########2| cHPI locations : 1565/1696 [00:14<00:01, 105.26it/s]
93%|#########2| cHPI locations : 1573/1696 [00:14<00:01, 98.57it/s]
93%|#########3| cHPI locations : 1580/1696 [00:14<00:01, 92.59it/s]
94%|#########3| cHPI locations : 1586/1696 [00:15<00:01, 87.01it/s]
94%|#########3| cHPI locations : 1590/1696 [00:15<00:01, 81.24it/s]
94%|#########3| cHPI locations : 1594/1696 [00:15<00:01, 76.25it/s]
94%|#########4| cHPI locations : 1599/1696 [00:16<00:01, 71.90it/s]
95%|#########4| cHPI locations : 1609/1696 [00:16<00:01, 69.29it/s]
97%|#########7| cHPI locations : 1650/1696 [00:16<00:00, 79.16it/s]
97%|#########7| cHPI locations : 1652/1696 [00:16<00:00, 73.99it/s]
99%|#########8| cHPI locations : 1678/1696 [00:16<00:00, 78.95it/s]
100%|##########| cHPI locations : 1696/1696 [00:16<00:00, 101.09it/s]
Lastly, compute head positions from the coil locations:
head_pos = mne.chpi.compute_head_pos(raw.info, chpi_locs, verbose=True)
Out:
t=9.000: 5/5 good HPI fits, movements [mm/s] = 0.1 / 0.1 / 0.5 / 0.2 / 0.3
t=10.000: 5/5 good HPI fits, movements [mm/s] = 0.1 / 0.3 / 0.0 / 0.2 / 0.1
t=11.000: 5/5 good HPI fits, movements [mm/s] = 0.1 / 0.1 / 0.1 / 0.0 / 0.1
t=12.000: 5/5 good HPI fits, movements [mm/s] = 0.0 / 0.0 / 0.0 / 0.0 / 0.0
t=13.000: 5/5 good HPI fits, movements [mm/s] = 0.0 / 0.1 / 0.0 / 0.0 / 0.0
t=14.000: 5/5 good HPI fits, movements [mm/s] = 0.0 / 0.0 / 0.1 / 0.1 / 0.1
t=14.580: 5/5 good HPI fits, movements [mm/s] = 5.0 / 4.8 / 6.1 / 5.5 / 4.9
t=14.670: 5/5 good HPI fits, movements [mm/s] = 33.4 / 34.2 / 39.8 / 38.1 / 30.2
t=14.720: 5/5 good HPI fits, movements [mm/s] = 49.0 / 47.4 / 60.6 / 59.1 / 44.3
t=14.760: 5/5 good HPI fits, movements [mm/s] = 65.0 / 63.1 / 72.7 / 71.1 / 56.6
t=14.800: 5/5 good HPI fits, movements [mm/s] = 66.4 / 59.4 / 83.1 / 78.3 / 60.9
t=14.860: 5/5 good HPI fits, movements [mm/s] = 54.9 / 51.8 / 57.6 / 62.1 / 47.2
t=14.990: 5/5 good HPI fits, movements [mm/s] = 23.3 / 22.5 / 24.2 / 27.0 / 19.9
t=15.990: 5/5 good HPI fits, movements [mm/s] = 0.7 / 0.9 / 0.8 / 0.8 / 0.9
t=16.880: 5/5 good HPI fits, movements [mm/s] = 2.5 / 3.4 / 3.0 / 3.8 / 3.3
t=16.930: 5/5 good HPI fits, movements [mm/s] = 52.3 / 55.7 / 58.7 / 67.2 / 59.3
t=16.990: 5/5 good HPI fits, movements [mm/s] = 57.3 / 53.6 / 61.8 / 65.1 / 57.6
t=17.040: 5/5 good HPI fits, movements [mm/s] = 53.0 / 50.1 / 60.0 / 61.8 / 49.7
t=17.090: 5/5 good HPI fits, movements [mm/s] = 57.8 / 50.2 / 66.4 / 64.8 / 51.3
t=17.140: 5/5 good HPI fits, movements [mm/s] = 60.1 / 54.5 / 73.0 / 67.1 / 57.6
t=17.180: 5/5 good HPI fits, movements [mm/s] = 63.9 / 58.4 / 74.2 / 72.1 / 62.0
t=17.220: 5/5 good HPI fits, movements [mm/s] = 60.9 / 58.9 / 75.2 / 71.5 / 63.3
t=17.260: 5/5 good HPI fits, movements [mm/s] = 67.7 / 67.0 / 73.6 / 69.0 / 69.1
t=17.320: 5/5 good HPI fits, movements [mm/s] = 49.9 / 50.9 / 54.8 / 54.9 / 52.3
t=17.470: 5/5 good HPI fits, movements [mm/s] = 18.4 / 21.8 / 19.3 / 20.5 / 17.4
t=18.470: 5/5 good HPI fits, movements [mm/s] = 1.9 / 2.6 / 2.0 / 2.4 / 1.9
t=19.390: 5/5 good HPI fits, movements [mm/s] = 2.5 / 2.7 / 1.9 / 2.9 / 2.5
t=19.500: 5/5 good HPI fits, movements [mm/s] = 23.0 / 25.2 / 19.5 / 28.8 / 27.8
t=19.610: 5/5 good HPI fits, movements [mm/s] = 21.2 / 25.6 / 21.6 / 31.8 / 31.3
t=19.710: 5/5 good HPI fits, movements [mm/s] = 21.7 / 20.7 / 23.2 / 29.7 / 27.8
t=19.850: 5/5 good HPI fits, movements [mm/s] = 16.6 / 14.8 / 18.5 / 21.7 / 20.1
t=20.850: 5/5 good HPI fits, movements [mm/s] = 2.3 / 1.9 / 2.0 / 2.5 / 2.2
t=21.850: 5/5 good HPI fits, movements [mm/s] = 0.6 / 1.7 / 1.7 / 2.0 / 1.9
t=21.950: 5/5 good HPI fits, movements [mm/s] = 25.8 / 27.1 / 24.1 / 32.1 / 26.4
t=22.000: 5/5 good HPI fits, movements [mm/s] = 66.0 / 59.4 / 46.4 / 64.7 / 51.9
t=22.050: 5/5 good HPI fits, movements [mm/s] = 59.8 / 62.5 / 51.2 / 69.1 / 57.9
t=22.100: 5/5 good HPI fits, movements [mm/s] = 61.6 / 65.3 / 58.5 / 75.1 / 64.8
t=22.140: 5/5 good HPI fits, movements [mm/s] = 74.2 / 74.0 / 62.4 / 79.8 / 68.2
t=22.180: 5/5 good HPI fits, movements [mm/s] = 63.9 / 59.3 / 53.2 / 67.3 / 53.1
t=22.240: 5/5 good HPI fits, movements [mm/s] = 38.5 / 39.4 / 36.7 / 47.9 / 42.3
t=22.300: 5/5 good HPI fits, movements [mm/s] = 41.8 / 40.0 / 33.4 / 47.5 / 39.4
t=22.400: 5/5 good HPI fits, movements [mm/s] = 31.9 / 28.5 / 22.1 / 30.8 / 24.9
t=23.400: 5/5 good HPI fits, movements [mm/s] = 1.8 / 1.8 / 1.1 / 1.5 / 1.2
t=24.400: 5/5 good HPI fits, movements [mm/s] = 1.2 / 0.8 / 0.7 / 0.8 / 0.7
t=24.640: 5/5 good HPI fits, movements [mm/s] = 12.6 / 11.6 / 11.6 / 13.0 / 10.9
t=24.720: 5/5 good HPI fits, movements [mm/s] = 30.3 / 33.1 / 31.6 / 39.0 / 35.3
t=24.790: 5/5 good HPI fits, movements [mm/s] = 31.0 / 35.8 / 32.8 / 43.0 / 40.9
t=24.850: 5/5 good HPI fits, movements [mm/s] = 37.4 / 41.0 / 35.8 / 44.8 / 42.1
t=24.890: 5/5 good HPI fits, movements [mm/s] = 50.5 / 51.6 / 50.0 / 59.8 / 53.5
t=24.930: 5/5 good HPI fits, movements [mm/s] = 55.6 / 54.9 / 59.2 / 68.7 / 61.6
t=24.980: 5/5 good HPI fits, movements [mm/s] = 47.3 / 48.0 / 51.0 / 58.4 / 53.6
t=25.080: 5/5 good HPI fits, movements [mm/s] = 23.8 / 18.9 / 23.1 / 28.2 / 26.5
t=25.510: 5/5 good HPI fits, movements [mm/s] = 2.4 / 6.4 / 7.3 / 6.5 / 7.8
Note that these can then be written to disk or read from disk with
mne.chpi.write_head_pos()
and mne.chpi.read_head_pos()
,
respectively.
Visualizing continuous head position¶
We can plot as traces, which is especially useful for long recordings:
mne.viz.plot_head_positions(head_pos, mode='traces')
Or we can visualize them as a continuous field (with the vectors pointing in the head-upward direction):
mne.viz.plot_head_positions(head_pos, mode='field')
These head positions can then be used with
mne.preprocessing.maxwell_filter()
to compensate for movement,
or with mne.preprocessing.annotate_movement()
to mark segments as
bad that deviate too much from the average head position.
Total running time of the script: ( 0 minutes 36.803 seconds)
Estimated memory usage: 16 MB