Home > vbmeg > functions > device > meg > yokogawa > utility > vb_read_yokogawa_pos.m

vb_read_yokogawa_pos

PURPOSE ^

This function reads yokogawa's Marker file(text file)

SYNOPSIS ^

function [pos, id] = vb_read_yokogawa_pos(fname,Nmark)

DESCRIPTION ^

 This function reads yokogawa's Marker file(text file)

 pos : marker position [N x 3]
 id  : marker id
 fname : marker text file
 Nmark : number of marker (Optional, Default = 5)

 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    [pos, id] = vb_read_yokogawa_pos(fname,Nmark)
0002 % This function reads yokogawa's Marker file(text file)
0003 %
0004 % pos : marker position [N x 3]
0005 % id  : marker id
0006 % fname : marker text file
0007 % Nmark : number of marker (Optional, Default = 5)
0008 %
0009 % Copyright (C) 2011, ATR All Rights Reserved.
0010 % License : New BSD License(see VBMEG_LICENSE.txt)
0011 
0012 if ~exist('fname','var')
0013     fname = 'AEFマーカー.txt';
0014 end
0015 
0016 key_start = 'MEG marker file';
0017 key_mark  = 'Marker';
0018 key_end   = '[mm]';
0019 
0020 xkey = 'x=';
0021 ykey = 'y=';
0022 zkey = 'z=';
0023 
0024 if ~exist('Nmark','var')
0025     Nmark = 5;
0026 end
0027 
0028 id  = zeros(Nmark,1);
0029 pos = zeros(Nmark,3);
0030 
0031 fid=fopen(fname);
0032 
0033 if fid == -1, fprintf('[%s] can not be opened\n',fname);return; end;
0034 
0035 % Check keyname
0036 while 1
0037     next_line = fgetl(fid);
0038     if ~ischar(next_line), break, end;
0039     if ~isempty( strfind(next_line,key_start)), break, end;
0040 end
0041 
0042 for n = 1:Nmark
0043     next_line = fgetl(fid);
0044     js = strfind(next_line,key_mark);
0045     je = strfind(next_line,key_end);
0046     jx = strfind(next_line,xkey);
0047     jy = strfind(next_line,ykey);
0048     jz = strfind(next_line,zkey);
0049 
0050     id(n)    = sscanf(next_line(js+6:js+7)      ,'%d');
0051     pos(n,1) = sscanf(next_line(jx(1)+2:jy(1)-1),'%f');
0052     pos(n,2) = sscanf(next_line(jy(1)+2:jz(1)-1),'%f');
0053     pos(n,3) = sscanf(next_line(jz(1)+2:je-1)   ,'%f');
0054 end
0055 
0056 % Change unit [mm] -> [m]
0057 pos = pos*0.001;
0058 
0059 fclose(fid);
0060 
0061 return
0062 %
0063 % ---- END ----
0064 %
0065 
0066 
0067 
0068 next_line1 = ...
0069 '    MEG marker file:  C:\Documents and Settings\meg.MEG-SYSTEM\デスクトップ\ATR様向けトレーニング\20060203\木村実演\AEFマーカー.mrk';
0070 
0071 next_line = ...
0072 '    Marker 1:   MEG:x=   -3.87, y=   89.27, z=  -12.05[mm]    MRI:x=********, y=********, z=********    ';
0073 
0074 
0075 ~isempty( strfind(next_line1,key_start))
0076 
0077 %return
0078 
0079 next_line(js+6:js+7)      
0080 next_line(jx(1)+2:jy(1)-1)
0081 next_line(jy(1)+2:jz(1)-1)
0082 next_line(jz(1)+2:je-1)

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