forked from netstim/leaddbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathea_findcoords.m
45 lines (23 loc) · 893 Bytes
/
ea_findcoords.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
function coords=ea_findcoords(goodz,trajectory,trajvector,dist,correction,options)
trajectory=ea_genhdtrajectory(trajectory,options);
onecoord=trajectory(abs(trajectory(:,3)-(goodz+correction(3)))<0.001,:);
%% add correction term...
orth=null(trajvector);
orth=[orth,trajvector'];
orthx=orth(:,1);
orthy=orth(:,2);
try
onecoord=[onecoord(1)+orthx(1)*correction(1)+orthy(1)*correction(2); ...
onecoord(2)+orthx(2)*correction(1)+orthy(2)*correction(2); ...
onecoord(3)+orthx(3)*correction(1)+orthy(3)*correction(2)]';
catch
return
end
%%
%coords(1,:)=trajectory(trajectory(:,3)==(min(finalzs)),:);
coords(1,:)=onecoord;
%% find coords best matching found coords and having equal distance calculated.
normtrajvector=trajvector./norm(trajvector);
for electrode=2:4
coords(electrode,:)=coords(1,:)-normtrajvector.*((electrode-1)*dist);
end