forked from fieldtrip/fieldtrip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinspect_bug2993.m
70 lines (53 loc) · 1.71 KB
/
inspect_bug2993.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function inspect_bug2993
% WALLTIME 00:10:00
% MEM 1gb
% DEPENDENCY
% DATA private
cd(dccnpath('/home/common/matlab/fieldtrip/data/test/bug2993'));
elec_original = ft_read_sens('EEGMarkersLocalite.xml');
% elec_original = ft_determine_coordsys(elec_original);
elec_original.coordsys = 'lps';
% the electrodes should be rotated around the z-axis with 180 degrees to make them consistent
% with the MNI coordinate system (x=right, y=nose), which is expected by default in ft_prepare_layout
figure
ft_plot_sens(elec_original, 'label', 'on');
ft_plot_axes(elec_original);
%%
cfg = [];
cfg.elec = elec_original;
cfg.method = 'interactive';
elec_realigned1 = ft_electroderealign(cfg);
assert(~isequal(elec_realigned1.chanpos, elec_original.chanpos));
%%
cfg = [];
cfg.elec = elec_original;
cfg.method = 'interactive';
% this requires a headshape, but it can be empty
cfg.headshape = [];
cfg.headshape.pos = zeros(0,3);
cfg.headshape.tri = zeros(0,3);
cfg.headshape.unit = 'mm';
elec_realigned2 = ft_sensorrealign(cfg);
assert(~isequal(elec_realigned2.chanpos, elec_original.chanpos));
%%
cfg = [];
cfg.individual.elec = elec_original;
cfg.template.headshape = [];
cfg.template.headshape.pos = randn(10,3);
cfg.template.headshape.tri = zeros(0,3);
cfg.template.headshape.unit = 'mm';
cfg.method = 'interactive';
outcfg = ft_interactiverealign(cfg);
% this returns the transformation, not the updated electrode positions
assert(~isequal(outcfg.m, eye(4)));
%%
cfg = [];
cfg.elec = elec_original;
figure; ft_plot_layout(ft_prepare_layout(cfg));
cfg = [];
cfg.elec = elec_original;
cfg.rotate = 180;
figure; ft_plot_layout(ft_prepare_layout(cfg));
cfg = [];
cfg.elec = elec_realigned1;
figure; ft_plot_layout(ft_prepare_layout(cfg));