0001 function [parm_is_ok, msg] = pa_head_check_parm(fig, head_parm)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 if ~exist('fig', 'var') || isempty(fig) || ~ishandle(fig)
0022 error('invalid figure handle.');
0023 end
0024 if ~exist('head_parm', 'var'),
0025 error('head_parm is a required parameter.');
0026 end
0027
0028
0029
0030
0031
0032 data = guidata(fig);
0033
0034 H = data.H;
0035
0036 parm_is_ok = true;
0037 msg = [];
0038
0039 try
0040
0041 if ~isfield(head_parm, 'Nvertex') || ...
0042 head_parm.Nvertex < 0
0043 msg = 'The number of vertices is invalid.';
0044 error('go_to_catch_block');
0045 end
0046
0047
0048 if ~isfield(head_parm, 'analyze_file') || ...
0049 exist(head_parm.analyze_file, 'file') == 0
0050 msg = 'Analyze file is needed.';
0051 error('go_to_catch_block');
0052 end
0053
0054
0055 if ~isfield(head_parm, 'Nsurf') || ...
0056 head_parm.Nsurf < 0
0057 msg = 'The Model number is invalid.';
0058 error('go_to_catch_block');
0059 end
0060
0061
0062 if ~isfield(head_parm, 'vstep') || ...
0063 head_parm.vstep < 0
0064 msg = 'Voxel size should be 1 or 2 mm';
0065 error('go_to_catch_block');
0066 end
0067
0068
0069
0070
0071 if get(H.csf_source_popup, 'Value') == 1
0072
0073
0074
0075 if ~isfield(head_parm, 'gray_file') || ...
0076 exist(head_parm.gray_file, 'file') == 0
0077
0078 msg = 'SPM gray file is needed.';
0079 error('go_to_catch_block');
0080 end
0081
0082
0083 proj_root = get(H.prjroot_edit, 'String');
0084 if ~isfield(head_parm, 'brain_file') || ...
0085 exist([proj_root, '/', head_parm.brain_file], 'file') == 0
0086
0087 msg = 'Cortical model file is needed.';
0088 error('go_to_catch_block');
0089 end
0090
0091 elseif get(H.csf_source_popup, 'Value') == 2
0092
0093 if ~isfield(head_parm, 'curry_file') || ...
0094 exist(head_parm.curry_file, 'file') == 0
0095
0096 msg = 'Curry surface file is needed.';
0097 error('go_to_catch_block');
0098 end
0099 else
0100 msg = 'internal error is occured.';
0101 error('go_to_catch_block');
0102 end
0103
0104
0105
0106
0107
0108 if get(H.skull_source_popup, 'Value') == 1
0109
0110 if ~isfield(head_parm, 'Radius_scalp') || ...
0111 head_parm.Radius_scalp < 0
0112 msg = 'Scalp thickness is invalid.';
0113 error('go_to_catch_block');
0114 end
0115 elseif get(H.skull_source_popup, 'Value') == 2
0116
0117 if ~isfield(head_parm, 'fs_skull_file') || ...
0118 exist(head_parm.fs_skull_file, 'file') == 0
0119
0120 msg = 'FreeSurfer surface file is needed.';
0121 error('go_to_catch_block');
0122 end
0123 else
0124 msg = 'internal error is occured.';
0125 error('go_to_catch_block');
0126 end
0127
0128
0129
0130
0131 if get(H.scalp_source_popup, 'Value') == 1
0132
0133 if ~isfield(head_parm, 'fs_scalp_file') || ...
0134 exist(head_parm.fs_scalp_file, 'file') == 0
0135
0136 msg = 'FreeSurfer surface file(outer skin) is needed.';
0137 error('go_to_catch_block');
0138 end
0139 elseif get(H.scalp_source_popup, 'Value') == 2
0140
0141 if ~isfield(head_parm, 'face_file') || ...
0142 exist(head_parm.face_file, 'file') == 0
0143
0144 msg = 'Face surface file is needed.';
0145 error('go_to_catch_block');
0146 end
0147 end
0148
0149
0150 if ~isfield(head_parm, 'head_file') || ...
0151 isempty(head_parm.head_file);
0152
0153 msg = 'Head file is needed.';
0154 error('go_to_catch_block');
0155 end
0156
0157 catch
0158 parm_is_ok = false;
0159 end
0160