Browse code

searchlight ready. missing nifti-image-write support. added timing to FBS

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@167 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on30/03/2009 17:54:25
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,92 @@
1
+%   rri_xhair: create a pair of full_cross_hair at point [x y] in
2
+%              axes h_ax, and return xhair struct
3
+%
4
+%   Usage: xhair = rri_xhair([x y], xhair, h_ax);
5
+%
6
+%   If omit xhair, rri_xhair will create a pair of xhair; otherwise,
7
+%   rri_xhair will update the xhair. If omit h_ax, current axes will
8
+%   be used.
9
+%
10
+
11
+%   24-nov-2003 jimmy (jimmy@rotman-baycrest.on.ca)
12
+%
13
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
+
15
+function xhair = rri_xhair(varargin)
16
+
17
+   if nargin == 0
18
+      error('Please enter a point position as first argument');
19
+      return;
20
+   end
21
+
22
+   if nargin > 0
23
+      p = varargin{1};
24
+
25
+      if ~isnumeric(p) | length(p) ~= 2
26
+         error('Invalid point position');
27
+         return;
28
+      else
29
+         xhair = [];
30
+      end
31
+   end
32
+
33
+   if nargin > 1
34
+      xhair = varargin{2};
35
+
36
+      if ~isempty(xhair)
37
+         if ~isstruct(xhair)
38
+            error('Invalid xhair struct');
39
+            return;
40
+         elseif ~isfield(xhair,'lx') | ~isfield(xhair,'ly')
41
+            error('Invalid xhair struct');
42
+            return;
43
+         elseif ~ishandle(xhair.lx) | ~ishandle(xhair.ly)
44
+            error('Invalid xhair struct');
45
+            return;
46
+         end
47
+
48
+         lx = xhair.lx;
49
+         ly = xhair.ly;
50
+      else
51
+         lx = [];
52
+         ly = [];
53
+      end
54
+   end
55
+
56
+   if nargin > 2
57
+      h_ax = varargin{3};
58
+
59
+      if ~ishandle(h_ax)
60
+         error('Invalid axes handle');
61
+         return;
62
+      elseif ~strcmp(lower(get(h_ax,'type')), 'axes')
63
+         error('Invalid axes handle');
64
+         return;
65
+      end
66
+   else
67
+      h_ax = gca;
68
+   end
69
+
70
+   x_range = get(h_ax,'xlim');
71
+   y_range = get(h_ax,'ylim');
72
+
73
+   if ~isempty(xhair)
74
+      set(lx, 'ydata', [p(2) p(2)]);
75
+      set(ly, 'xdata', [p(1) p(1)]);
76
+      set(h_ax, 'selected', 'on');
77
+      set(h_ax, 'selected', 'off');
78
+   else
79
+      figure(get(h_ax,'parent'));
80
+      axes(h_ax);
81
+
82
+      xhair.lx = line('xdata', x_range, 'ydata', [p(2) p(2)], ...
83
+	'zdata', [11 11], 'color', [1 0 0], 'hittest', 'off');
84
+      xhair.ly = line('xdata', [p(1) p(1)], 'ydata', y_range, ...
85
+	'zdata', [11 11], 'color', [1 0 0], 'hittest', 'off');
86
+   end
87
+
88
+   set(h_ax,'xlim',x_range);
89
+   set(h_ax,'ylim',y_range);
90
+
91
+   return;
92
+