0001 function [obj, result] = ...
0002 bm_fileio_import_file(obj, file_type, model_file, analyze_info, args)
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 if ~exist('obj', 'var'), error('obj is a required parameter.'); end
0025 if ~strcmp(obj.class_type, 'bm_fileio')
0026 error('class type is invalid.');
0027 end
0028 if ~exist('file_type', 'var')
0029 error('file_type is a required parameter.');
0030 end
0031 if ~exist('model_file', 'var')
0032 error('model_file is a required parameter.');
0033 end
0034 if ~exist('analyze_info', 'var')
0035 error('analyze_info is a required parameter.');
0036 end
0037
0038
0039
0040
0041 global vbmeg_inst;
0042 result = SUCCESS;
0043
0044 app_const = define_bm_edit_app;
0045
0046
0047 switch(file_type)
0048 case app_const.file_type.BRAIN_FILE
0049 [V_cel, F_cel, xx_cel, name_cel, conduct_cel] = ...
0050 bm_fileio_read_brain_file(model_file, args{1}, analyze_info);
0051 case app_const.file_type.HEAD_FILE
0052 [V_cel, F_cel, xx_cel, name_cel, conduct_cel] = ...
0053 bm_fileio_read_head_file(model_file);
0054 case app_const.file_type.CURRY_FILE
0055 [V_cel, F_cel, xx_cel, name_cel, conduct_cel] = ...
0056 bm_fileio_read_curry_file(model_file, analyze_info);
0057 case app_const.file_type.FACE_FILE
0058 [V_cel, F_cel, xx_cel, name_cel, conduct_cel] = ...
0059 bm_fileio_read_face_file(model_file);
0060 case app_const.file_type.MASK_FILE
0061 [V_cel, F_cel, xx_cel, name_cel, conduct_cel] = ...
0062 bm_fileio_read_mask_file(model_file, args{1}, analyze_info);
0063 case app_const.file_type.SPM_NORM_FILE
0064 [V_cel, F_cel, xx_cel, name_cel, conduct_cel] = ...
0065 bm_fileio_read_spm_norm_file(model_file, args{1}, analyze_info);
0066 otherwise
0067 error('specified file_type is invalid.');
0068 end
0069
0070 const = vbmeg_inst.const;
0071
0072
0073 Vdim = vb_analyze_info_get_voxdim(analyze_info);
0074 Vsize = vb_analyze_info_get_voxsize(analyze_info);
0075
0076 for k=1:length(V_cel)
0077
0078 V = vb_spm_right_to_analyze_right_mm(V_cel{k}, Vdim, Vsize);
0079
0080
0081 brain_data = surf_data_new(V, F_cel{k}, xx_cel{k}, ...
0082 const.COORDINATE_ANALYZE_RIGHT_MM, ...
0083 name_cel{k}, ...
0084 conduct_cel{k});
0085
0086 comment = ['Imported from ' model_file];
0087 brain_data = brain_data_add_history_item(brain_data, comment);
0088
0089
0090 obj.bm_list = bm_list_add_model(obj.bm_list, brain_data);
0091 end
0092
0093
0094
0095
0096 if nargout == 0
0097 error('function caller should receive obj.');
0098 end