Home > vbmeg > functions > common > log > vb_load_brain_proj.m

vb_load_brain_proj

PURPOSE ^

SYNOPSIS ^

function [parm] = vb_load_brain_proj(parm)

DESCRIPTION ^

 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 [parm] = vb_load_brain_proj(parm)
0002 %
0003 % Copyright (C) 2011, ATR All Rights Reserved.
0004 % License : New BSD License(see VBMEG_LICENSE.txt)
0005 
0006 % 2005-03-20 Modified by TY
0007 %global    define
0008 global vbmeg_inst; 
0009 define = vbmeg_inst.const; 
0010 
0011 % project fileを開く。
0012 if ~isempty( findstr(parm.file.brain, define.BRAIN_EXTENSION) )
0013   BRAINfile =...
0014       parm.file.brain(1:findstr(parm.file.brain, define.BRAIN_EXTENSION)-1);
0015 else
0016   BRAINfile = parm.file.brain;
0017 end
0018 project_fname = [parm.dir.brain  BRAINfile define.BRAIN_PROJECT_EXTENSION];
0019 fd = fopen(project_fname, 'r');
0020 
0021 
0022 CR = sprintf('\n');    % 改行コード
0023 
0024 while true
0025   str = fgets(fd);
0026     
0027   if str == -1
0028     break;        % End of FILE
0029   elseif strcmp(str, CR) | str(1)=='#'
0030     ;            % '#'で始まる行はCOMMENT line
0031   else
0032     % データファイル名とディレクトリ名を読む。
0033     mri_dir = sscanf(str,'dir.mri = %s');
0034     dicom_file = sscanf(str,'file.dicom = %s');
0035     right_dir = sscanf(str,'dir.bvoy_right = %s');
0036     right_file = sscanf(str, 'file.right = %s');
0037     left_dir = sscanf(str, 'dir.bvoy_left = %s');
0038     left_file = sscanf(str, 'file.left = %s');
0039     inf_right_dir = sscanf(str,'dir.inf_right = %s');
0040     inf_right_file = sscanf(str, 'file.inf_right = %s');
0041     inf_left_dir = sscanf(str, 'dir.inf_left = %s');
0042     inf_left_file = sscanf(str, 'file.inf_left = %s');
0043     brain_dir = sscanf(str, 'dir.brain = %s');
0044     brain_file = sscanf(str, 'file.brain = %s');
0045     inflate_dir = sscanf(str, 'dir.inflate = %s');
0046     inflate_file = sscanf(str, 'file.inflate = %s');
0047     area_dir = sscanf(str,'dir.area = %s');
0048     area_file = sscanf(str, 'file.area = %s');
0049     fmri_dir = sscanf(str,'dir.act = %s');
0050     fmri_file = sscanf(str, 'file.act = %s');
0051 
0052     % keywordとcomment行を読む。
0053     brain_keyword = strncmp(str, 'brain_parm.brain_keyword =', ...
0054     length('brain_parm.brain_keyword ='));
0055     brain_comment = strncmp(str, 'brain_parm.brain_comment =', ...
0056     length('brain_parm.brain_comment ='));
0057 
0058     % 推定パラメータを読む。
0059     Reduce_ratio = sscanf(str, 'brain_parm.Reduce_ratio = %f');
0060     Rmax = sscanf(str, 'brain_parm.Rmax = %f');
0061     ignore_offset = sscanf(str, 'brain_parm.ignore_offset = %f');
0062     Nstep = sscanf(str, 'brain_parm.Nstep = %f');
0063     Display = sscanf(str, 'brain_parm.Display = %d');
0064 
0065     if ~isempty(mri_dir)    parm.dir.mri = mri_dir;
0066     elseif ~isempty(dicom_file)    parm.file.dicom = dicom_file;    
0067     elseif ~isempty(right_dir)    parm.dir.bvoy_right = right_dir;
0068     elseif ~isempty(right_file)    parm.file.right = right_file;
0069     elseif ~isempty(left_dir)    parm.dir.bvoy_left = left_dir;
0070     elseif ~isempty(left_file)    parm.file.left = left_file;
0071     elseif ~isempty(inf_right_dir)    parm.dir.right_inf = inf_right_dir;
0072     elseif ~isempty(inf_right_file)    parm.file.right_inf = inf_right_file;
0073     elseif ~isempty(inf_left_dir)    parm.dir.left_inf = inf_left_dir;
0074     elseif ~isempty(inf_left_file)    parm.file.left_inf = inf_left_file;
0075     elseif ~isempty(brain_dir)        parm.dir.brain = brain_dir;
0076     elseif ~isempty(brain_file)        parm.file.brain = brain_file;
0077     elseif ~isempty(inflate_dir)    parm.dir.inflate = inflate_dir;
0078     elseif ~isempty(inflate_file)    parm.file.inflate = inflate_file;
0079     elseif ~isempty(area_dir)        parm.dir.area = area_dir;
0080     elseif ~isempty(area_file)        parm.file.area = area_file;
0081     elseif ~isempty(fmri_dir)        parm.dir.act = fmri_dir;
0082     elseif ~isempty(fmri_file)        parm.file.act = fmri_file;
0083     
0084     elseif brain_keyword
0085       parm.brain_parm.brain_keyword =...
0086       sscanf(str, 'brain_parm.brain_keyword = %s');
0087     elseif brain_comment
0088       parm.brain_parm.brain_comment =...
0089       sscanf(str, 'brain_parm.brain_comment = %s');
0090     
0091     elseif ~isempty(Reduce_ratio)
0092       parm.brain_parm.Reduce_ratio = Reduce_ratio;
0093     elseif ~isempty(Rmax)
0094       parm.brain_parm.Rmax = Rmax;
0095     elseif ~isempty(ignore_offset)
0096       parm.brain_parm.ignore_offset = ignore_offset;
0097     elseif ~isempty(Nstep)
0098       parm.brain_parm.Nstep = Nstep;
0099     elseif ~isempty(Display)
0100       brain_parm.Display = Display;
0101     else
0102       error(str);    % パラメータファイルにerror行を発見した。
0103     end
0104     
0105   end    % <-- End of 'if str == -1 ... elseif strcmp(...) ... else'
0106 end    % <-- End of 'while true'
0107 
0108 fclose(fd);
0109

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