forked from netstim/leaddbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathea_detthresh.m
42 lines (37 loc) · 1.47 KB
/
ea_detthresh.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
function thresh=ea_detthresh(atlases,atlas,img)
% function that will return the threshold according to user settings for a
% specific atlas.
% __________________________________________________________________________________
% Copyright (C) 2015 Charite University Medicine Berlin, Movement Disorders Unit
% Andreas Horn
if isfield(atlases,'threshold')
switch atlases.threshold.type
case 'percentage'
try
sso=sort(img(img>0));
thresh=sso(round(length(sso)*(1-atlases.threshold.value))); % preserve % of voxels.
catch
thresh=sso(1);
end
case 'percentage_vector'
sso=sort(img(img>0));
try
thresh=sso(round(length(sso)*(1-atlases.threshold.value(atlas)))); % preserve % of voxels.
catch
thresh=sso(1);
end
case 'relative_intensity'
thresh=max(img(:))*(1-atlases.threshold.value);
case 'relative_intensity_vector'
thresh=max(img(:))*(1-atlases.threshold.value(atlas));
case 'absolute_intensity'
thresh=atlases.threshold.value;
case 'absolute_intensity_vector'
thresh=atlases.threshold.value(atlas);
otherwise
warning(['Threshold type not recognized: ',atlases.threshold.type,'. Overwriting with default.']);
thresh=max(img(:))*0.5;
end
else
thresh=max(img(:))*0.5;
end