0001 function vb_sn_and_graymatter_file_create(mri_file)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 spm = which('spm.m');
0023 if isempty(spm)
0024 error('SPM path should be added to MATLAB.');
0025 end
0026 if nargin ~= 1
0027 error('Please check function usage.');
0028 end
0029 if exist(mri_file, 'file') ~= 2
0030 error('Specified file not found %s', mri_file);
0031 end;
0032
0033
0034
0035
0036
0037 mri_file = [mri_file, ',1'];
0038
0039
0040 spm_dir = which('spm.m');
0041 gray_file = fullfile(spm_dir, 'tpm', 'grey.nii');
0042 white_file = fullfile(spm_dir, 'tpm', 'white.nii');
0043 csf_file = fullfile(spm_dir, 'tpm', 'csf.nii');
0044
0045 opt.tmp = str2mat(gray_file, white_file, csf_file);
0046 opt.ngaus = [2; 2; 2; 4];
0047 opt.regtype = 'mni';
0048 opt.warpreg = 1;
0049 opt.warpco = 25;
0050 opt.biasreg = 0.0001;
0051 opt.biasfwhm = 60;
0052 opt.samp = 3;
0053 opt.msk = '';
0054
0055 res = spm_preproc(mri_file, opt);
0056
0057
0058 sn = spm_prep2sn(res);
0059
0060 [pth, nam] = vb_get_file_parts(mri_file);
0061 sn_filename = fullfile(pth, [nam '_seg_sn.mat']);
0062 vb_save_struct(sn_filename, sn);
0063
0064
0065 output.GM = [0 0 1];
0066 output.WM = [0 0 0];
0067 output.CSF = [0 0 0];
0068 output.biascor = 0;
0069 output.cleanup = 0;
0070 spm_preproc_write(sn, output);