-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdbs_write.m
More file actions
97 lines (66 loc) · 2.08 KB
/
dbs_write.m
File metadata and controls
97 lines (66 loc) · 2.08 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function dbs_write(options)
try
ea_updatemodel(options);
end
if options.d2.write || options.d3.write
if strcmp(options.atlasset,'Segment patient anatomy')
ea_subcorticalsegmentation(options);
if ~options.native % normalize 2 MNI space
ea_normsubcorticalsegm(options);
end
options.atlasset=options.patientname;
options.atl.pt=1;
options.atl.can=0;
end
end
% Slice 2D Visualization
if options.d2.write
% Prior Results are loaded here inside the function (this way, function
% can be called just by giving the patient directory.
cuts=ea_writeplanes(options);
end
% Render 3D Visualization
if options.d3.write
% Prior Results are loaded here inside the function (this way, function
% can be called just by giving the patient directory.
resultfig=ea_elvis(options);
% save scene as matlab figure
try % if path is not defined, don't save.
saveas(resultfig,[options.root,options.patientname,filesep,'LEAD_scene.fig']);
end
%figure2xhtml([options.root,options.patientname,filesep,'eAuto_scene'],resultfig);
if options.d3.autoserver
ea_export_server([],[],options);
close(resultfig);
end
end
%% check traject sanity
for side=1:length(options.sides)
try
trajectissane=ea_checktrajectsanity(trajvector{side});
if ~trajectissane
disp(['Trajectory of side ',num2str(side),' seems not to have been correctly reconstructed. Check manually.']);
end
end
end
try
if isnan(results)
clear results
end
results.coords_mm=coords_mm;
results.realcoords=realcoords;
for electrode=1:length(coords_mm)
results.distances(electrode)=pdist([coords_mm(electrode,:);realcoords(electrode,:)]);
end
results.fit=ea_nanmean(results.distances);
end
function y = ea_nanmean(varargin)
if nargin==2
x=varargin{1};
dim=varargin{2};
elseif nargin==1
x=varargin{1};
dim=1;
end
N = sum(~isnan(x), dim);
y = nansum(x, dim) ./ N;