Home > vbmeg > functions > device > location_device > digitizer > vb_load_itk.m

vb_load_itk

PURPOSE ^

SYNOPSIS ^

function [marker, marker_name, ch_pos, ch_name] = vb_load_itk(fname)

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    [marker, marker_name, ch_pos, ch_name] = vb_load_itk(fname)
0002 %
0003 % Copyright (C) 2011, ATR All Rights Reserved.
0004 % License : New BSD License(see VBMEG_LICENSE.txt)
0005 
0006 % Read itk-file for 3D-digitizer IISOTRAK
0007 %
0008 % marker     : reference position         (3 x 3)
0009 % marker(1,:): Left PA position (x,y,z)
0010 % marker(2,:): Nasion
0011 % marker(3,:): Right PA position
0012 %
0013 % marker_name: marker name            (3 x 1)
0014 % ch_pos     : channel position       (Nchannel x 3)
0015 % ch_name    : channel name           (Nchannel x 1)
0016 % written by Hiroe 2005.11.1
0017 
0018 
0019 marker = [];
0020 marker_name = cell(3,1);
0021 ch_pos = [];
0022 ch_name = [];
0023 
0024 fid = fopen(fname,'r');
0025 
0026 if fid == -1
0027     error('file open error')
0028 end
0029 
0030 k = 0;
0031 flg = true;
0032 
0033 while ( flg == true )
0034     line = fgets(fid);  %%% read one line %%%
0035     
0036     if line == -1
0037         flg = false;
0038         break;
0039 
0040     elseif ~isempty(deblank(line)) % null line check
0041         [name, pos(1), pos(2), pos(3)] = strread(line, '%s%f%f%f');
0042 
0043         switch( char(name) )
0044             case 'LPA'
0045                 marker(1,:) = pos(:)';
0046                 marker_name(1,1) =name;
0047             case 'Nasion'
0048                 marker(2,:) = pos(:)';
0049                 marker_name(2,1) = name;
0050             case 'RPA'
0051                 %r_b = pos;
0052                 marker(3,:) = pos(:)';
0053                 marker_name(3,1) = name;
0054             otherwise
0055                 k = k+1;
0056                 ch_pos(k, :) = pos(:)';
0057                 ch_name = [ch_name; name];
0058         end
0059     end
0060 end
0061 % end of while
0062 
0063 fclose(fid);
0064

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