0001 function pa_leadfield_make_center_sphere(fig)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if ~exist('fig', 'var') || isempty(fig) || ~ishandle(fig)
0017 error('invalid figure handle.');
0018 end
0019
0020
0021
0022
0023
0024
0025 data = guidata(fig);
0026 H = data.H;
0027
0028
0029 [d_name, f_name] = vb_file_select({'.nii', '.hdr'}, 'Select MRI file');
0030 if ~isempty(d_name)
0031 mri_file = [d_name, filesep, f_name{1}];
0032 else
0033
0034 return;
0035 end
0036
0037
0038
0039
0040
0041
0042
0043 h = waitbar(0,'MRI file reading');
0044 pause(0.01);
0045
0046
0047 try
0048 avw = avw_read_ras(mri_file);
0049 catch
0050 errordlg('cannot read mri file.', 'error');
0051 cancelled = true;
0052 return;
0053 end
0054
0055 waitbar(100);
0056
0057
0058
0059 Vcenter = str2num(get(H.center_head_edit, 'String'));
0060 if ~isempty(Vcenter)
0061 if isfield(data, 'Vradius')
0062 sphere.radius = data.Vradius;
0063 else
0064 sphere.radius = 0;
0065 end
0066 sphere.center = Vcenter;
0067 avw.sphere_on_spm_right_m = sphere;
0068 end
0069
0070
0071 try
0072
0073 vb_sphere_head(avw);
0074 if ishandle(h), close(h); end
0075
0076 waitfor(gcf);
0077 catch
0078 errordlg('something error occured in vb_sphere_head', 'error');
0079 return;
0080 end
0081
0082
0083 try
0084 center = evalin('base', 'avw.center');
0085 radius = evalin('base', 'avw.radius');
0086 catch
0087
0088 evalin('base', 'clear avw;');
0089 return;
0090 end
0091 evalin('base', 'clear avw;');
0092
0093
0094 set(H.center_head_edit, 'String', num2str(center, 3));
0095 data.Vradius = radius;
0096
0097 guidata(fig, data);