Home > vbmeg > functions > brain > vb_freesurfer_get_files.m

vb_freesurfer_get_files

PURPOSE ^

Get freesurfer files for brain_parm/gbrain_parm

SYNOPSIS ^

function brain_parm = vb_freesurfer_get_files(brain_parm, fs_sbj_dir)

DESCRIPTION ^

 Get freesurfer files for brain_parm/gbrain_parm
 Find files by looking at fs_subj_dir/surf [1st search]
                                     /bem  [2nd search]
 [Usage]
    vb_freesurfer_get_files(brain_parm, fs_sbj_dir);

 [Input]
    brain_parm : brain_parm.FS_left_file
                           .FS_right_file
                           .FS_left_infl_file
                           .FS_right_infl_file
                           .FS_left_curv_file
                           .FS_right_curv_file
                           .FS_left_label_file
                           .FS_right_label_file
                           are set.
    fs_sbj_dir : freesurfer subject directory.
                 e.g. '/home/user/FS_SUBJECTS_DIR/SBJ1'

 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function brain_parm = vb_freesurfer_get_files(brain_parm, fs_sbj_dir)
0002 % Get freesurfer files for brain_parm/gbrain_parm
0003 % Find files by looking at fs_subj_dir/surf [1st search]
0004 %                                     /bem  [2nd search]
0005 % [Usage]
0006 %    vb_freesurfer_get_files(brain_parm, fs_sbj_dir);
0007 %
0008 % [Input]
0009 %    brain_parm : brain_parm.FS_left_file
0010 %                           .FS_right_file
0011 %                           .FS_left_infl_file
0012 %                           .FS_right_infl_file
0013 %                           .FS_left_curv_file
0014 %                           .FS_right_curv_file
0015 %                           .FS_left_label_file
0016 %                           .FS_right_label_file
0017 %                           are set.
0018 %    fs_sbj_dir : freesurfer subject directory.
0019 %                 e.g. '/home/user/FS_SUBJECTS_DIR/SBJ1'
0020 %
0021 % Copyright (C) 2011, ATR All Rights Reserved.
0022 % License : New BSD License(see VBMEG_LICENSE.txt)
0023 
0024 %
0025 % --- Previous check
0026 %
0027 if nargin ~= 2
0028     error('Please check function usage');
0029 end
0030 
0031 %
0032 % --- Main Procedure
0033 %
0034 
0035 % Check whether the specified directory is Freesurfer's one or not
0036 fs_label_dir = fullfile(fs_sbj_dir, 'label');
0037 [tmp, num_found_files] = search(brain_parm, fs_label_dir);
0038 if num_found_files ~= 2
0039     error('This is not Freesurfer subject directory.');
0040 end
0041 
0042 %
0043 % --- Find surface files
0044 %
0045 
0046 % candidate directories for surface data.
0047 fs_surf_dir  = fullfile(fs_sbj_dir, 'surf');
0048 fs_bem_dir   = fullfile(fs_sbj_dir, 'bem');
0049 [tmp, num_found_files] = search(brain_parm, fs_surf_dir);
0050 if num_found_files >= 6
0051     brain_parm = tmp;
0052 else
0053     [tmp, num_found_files] = search(brain_parm, fs_bem_dir);
0054     if num_found_files >= 6
0055         brain_parm = tmp;
0056     else
0057         warning('Freesurfer files not found.');
0058     end
0059 end
0060 
0061 %
0062 % --- Find label files
0063 %
0064 [brain_parm] = search(brain_parm, fs_label_dir);
0065 
0066 
0067 function [brain_parm, num_found_files] = search(brain_parm, target_dir)
0068 % Search target_files inside target_dir and set brain_parm fields
0069 num_found_files = 0;
0070 target_files = {'lh.smoothwm.asc';
0071                 'rh.smoothwm.asc';
0072                 'lh.inflated.asc';
0073                 'rh.inflated.asc';
0074                 'lh.curv.asc';
0075                 'rh.curv.asc';
0076                 'lh.cortex.label';
0077                 'rh.cortex.label';
0078                 'lh.sphere.reg.asc';
0079                 'rh.sphere.reg.asc'};
0080 
0081 for k=1:length(target_files)
0082     target_file = fullfile(target_dir, target_files{k});
0083     if exist(target_file, 'file') ~= 2
0084         continue;
0085     end
0086     switch(target_files{k})
0087         case 'lh.smoothwm.asc'
0088             brain_parm.FS_left_file = target_file;
0089         case 'rh.smoothwm.asc'
0090             brain_parm.FS_right_file = target_file;
0091         case 'lh.inflated.asc'
0092             brain_parm.FS_left_infl_file = target_file;
0093         case 'rh.inflated.asc'
0094             brain_parm.FS_right_infl_file = target_file;
0095         case 'lh.curv.asc';
0096             brain_parm.FS_left_curv_file = target_file;
0097         case 'rh.curv.asc';
0098             brain_parm.FS_right_curv_file = target_file;
0099         case 'lh.cortex.label'
0100             brain_parm.FS_left_label_file = target_file;
0101         case 'rh.cortex.label'
0102             brain_parm.FS_right_label_file = target_file;
0103         case 'lh.sphere.reg.asc'
0104             brain_parm.FS_left_sphere_file = target_file;
0105         case 'rh.sphere.reg.asc'
0106             brain_parm.FS_right_sphere_file = target_file;
0107         otherwise
0108             error('Unknown target file is found.');
0109     end
0110     num_found_files = num_found_files + 1;
0111 end

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