0001 function [varargout] = vbmeg(command, arg1)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 if ~exist('command', 'var')
0025 command = 'set_path';
0026 end
0027
0028 global vbmeg_inst
0029 global vbmeg_saving_version
0030 global reduce_algorithm;
0031
0032 reduce_algorithm = 'CGAL';
0033
0034
0035
0036 switch(command)
0037 case 'set_path'
0038 prog_file = which('vbmeg.m');
0039 ix = findstr(prog_file,filesep);
0040 prog_dir = prog_file(1:ix(end));
0041 disp('--- Find VBMEG program directory');
0042 fprintf('VBMEG program directory: %s\n',prog_dir);
0043
0044
0045 vbmeg_home_dir = prog_dir;
0046 addpath(vbmeg_home_dir);
0047 addpath(genpath(fullfile(vbmeg_home_dir, 'external')));
0048 addpath(genpath(fullfile(vbmeg_home_dir, 'functions')));
0049 addpath(genpath(fullfile(vbmeg_home_dir, 'standard_brain')));
0050
0051
0052
0053 disp('--- Set program directories to MATLAB path');
0054 vbmeg_inst.const = vb_define_set(vbmeg_home_dir);
0055
0056 verbose_const = vb_define_verbose;
0057 vbmeg_inst.verbose_level = verbose_const.VERBOSE_LEVEL_NOTICE;
0058
0059 disp('--- Create global variable ''vbmeg_inst''')
0060
0061 case 'version'
0062 [major, minor, alpha_beta, rev] = vb_version;
0063 ver_str = sprintf('%.1f-%d.%c.%d', major, minor, alpha_beta, rev);
0064
0065 varargout{1} = ver_str;
0066
0067 case 'set_global'
0068 vbmeg_inst.const = vb_define_set;
0069 disp('--- Create global variable ''vbmeg_inst''')
0070
0071 case 'save_version'
0072 if ~exist('arg1', 'var') || isempty(arg1)
0073 vbmeg_saving_version = '';
0074 disp('VBMEG Save format reset to : system setting.');
0075 elseif (strcmpi(arg1, '-v6') || strcmpi(arg1, '-v7') || strcmpi(arg1, '-v7.3') || ...
0076 (vb_matlab_version('>=', '9.2') && strcmpi(arg1, '-v7.3 -nocompression')) )
0077 fprintf('VBMEG Save format set to : %s\n', arg1);
0078 vbmeg_saving_version = arg1;
0079 else
0080 if vb_matlab_version('>=', '9.2')
0081 error('save_version : ''-v6'' or ''-v7'' or ''-v7.3'', ''-v7.3 -nocompression''');
0082 else
0083 error('save_version : ''-v6'' or ''-v7'' or ''-v7.3''');
0084 end
0085 end
0086 case 'vb_rc_file'
0087 varargout{1} = fullfile(vb_get_file_parts(which('vbmeg.m')), 'vbmegrc');
0088 otherwise
0089 error('Unknown command: %s', command);
0090
0091 end
0092
0093
0094 iso2mesh_dir = fileparts(which('cgalsurf'));
0095 if ~ispc
0096 iso2mesh_bin = fullfile(iso2mesh_dir, '*.*');
0097 cmd = ['chmod 755 ' iso2mesh_bin];
0098 system(cmd);
0099 end