Home > vbmeg > demo > test_scripts > sbi > inv_DICOM.m

inv_DICOM

PURPOSE ^

---

SYNOPSIS ^

function [A1,n1]=inv_DICOM(filename,dx,dy,dz,A,n)

DESCRIPTION ^

 ---
 function [A,n1]=inv_DICOM(filename,dx,dy,dz,A,n)

 Convert coordinate system of given vertices and directional
 vectors from DICOM to MRI-Voxel (backward conversion of
 bat_read_DICOM). Directional vector should be normalized after 
 conversion. 

 dx,dy,dz: These values should be set to 0 as long as there is no 
           special reason. 
 A       : Vertex position in DICOM coordinate (mm). 
 n       : normal vector : no translation and scaling is applied

 2005-02-07 Taku Yoshioka
 2005-03-27 M. Sato modified
 ---

 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 [A1,n1]=inv_DICOM(filename,dx,dy,dz,A,n)
0002 % ---
0003 % function [A,n1]=inv_DICOM(filename,dx,dy,dz,A,n)
0004 %
0005 % Convert coordinate system of given vertices and directional
0006 % vectors from DICOM to MRI-Voxel (backward conversion of
0007 % bat_read_DICOM). Directional vector should be normalized after
0008 % conversion.
0009 %
0010 % dx,dy,dz: These values should be set to 0 as long as there is no
0011 %           special reason.
0012 % A       : Vertex position in DICOM coordinate (mm).
0013 % n       : normal vector : no translation and scaling is applied
0014 %
0015 % 2005-02-07 Taku Yoshioka
0016 % 2005-03-27 M. Sato modified
0017 % ---
0018 %
0019 % Copyright (C) 2011, ATR All Rights Reserved.
0020 % License : New BSD License(see VBMEG_LICENSE.txt)
0021 
0022 d=read_dicom(filename);
0023 
0024 % Direction Cos Matrix
0025 dcm = direction_cos(d);
0026 
0027 ip=getfield(d,'image_position');
0028 ps=getfield(d,'pixel_spacing');
0029 st=getfield(d,'slice_thickness');
0030 
0031 %画素開始位置
0032 A(:,1)=A(:,1)-ip(1);
0033 A(:,2)=A(:,2)-ip(2);
0034 A(:,3)=A(:,3)-ip(3);
0035 
0036 %回転
0037 A1=A*dcm;
0038 
0039 %画素豹スライス豹
0040 A1(:,1)=A1(:,1)./ps(1);
0041 A1(:,2)=A1(:,2)./ps(2);
0042 A1(:,3)=A1(:,3)./st;
0043 
0044 %縮小分位置修正
0045 A1(:,1)=A1(:,1)-dx+1;
0046 A1(:,2)=A1(:,2)-dy+1;
0047 A1(:,3)=A1(:,3)-dz+1;
0048 
0049 % normal vector
0050 if nargin>=6, 
0051     n1=n*dcm;
0052 end

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