Home > vbmeg > functions > gui > preAnalysis > leadfield > pa_leadfield_make_center_sphere.m

pa_leadfield_make_center_sphere

PURPOSE ^

make center sphere

SYNOPSIS ^

function pa_leadfield_make_center_sphere(fig)

DESCRIPTION ^

 make center sphere
 [USAGE]
    pa_leadfield_set_parm(<fig>);
 [IN]
    fig : figure handle of leafield gui.
 [OUT]
    none

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function pa_leadfield_make_center_sphere(fig)
0002 % make center sphere
0003 % [USAGE]
0004 %    pa_leadfield_set_parm(<fig>);
0005 % [IN]
0006 %    fig : figure handle of leafield gui.
0007 % [OUT]
0008 %    none
0009 %
0010 % Copyright (C) 2011, ATR All Rights Reserved.
0011 % License : New BSD License(see VBMEG_LICENSE.txt)
0012 
0013 %
0014 % --- Previous check
0015 %
0016 if ~exist('fig', 'var') || isempty(fig) || ~ishandle(fig)
0017     error('invalid figure handle.');
0018 end
0019 
0020 %
0021 % --- Main Procedure
0022 %
0023 
0024 % load data(@see pa_leadfield_create)
0025 data = guidata(fig);
0026 H = data.H; % component handles
0027 
0028 % analyze file input
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     % selection cancelled.
0034     return;
0035 end
0036 
0037 
0038 %
0039 % --- run make sphere model gui.
0040 %
0041 
0042 % show wait bar
0043 h = waitbar(0,'MRI file reading');
0044 pause(0.01); % for draw waitbar.
0045 
0046 % MRI data read
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 % current center info.
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 % --- run gui
0071 try
0072     % launching vb_sphere_head
0073     vb_sphere_head(avw);
0074     if ishandle(h), close(h); end
0075     % wait for close sphere_head.
0076     waitfor(gcf);
0077 catch
0078     errordlg('something error occured in vb_sphere_head', 'error');
0079     return;
0080 end
0081 
0082 % returns sphere_data(radius, center)
0083 try
0084     center = evalin('base', 'avw.center');
0085     radius = evalin('base', 'avw.radius');
0086 catch
0087     % sphere model gui closed by x button.
0088     evalin('base', 'clear avw;');
0089     return;
0090 end
0091 evalin('base', 'clear avw;');
0092 
0093 % save sphere
0094 set(H.center_head_edit, 'String', num2str(center, 3));
0095 data.Vradius = radius; % radius is officially not used.
0096 
0097 guidata(fig, data);

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005