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

back_DICOM

PURPOSE ^

---

SYNOPSIS ^

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

DESCRIPTION ^

 ---
 function [A,n1]=back_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. 

 filename: .mri.mat file (e.g., 10000fb.191.mri). 
 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). 

 2005-02-07 Taku Yoshioka
 ---

 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]=back_DICOM(filename,dx,dy,dz,A,n)
0002 % ---
0003 % function [A,n1]=back_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 % filename: .mri.mat file (e.g., 10000fb.191.mri).
0011 % dx,dy,dz: These values should be set to 0 as long as there is no
0012 %           special reason.
0013 % A       : Vertex position in DICOM coordinate (mm).
0014 %
0015 % 2005-02-07 Taku Yoshioka
0016 % ---
0017 %
0018 % Copyright (C) 2011, ATR All Rights Reserved.
0019 % License : New BSD License(see VBMEG_LICENSE.txt)
0020 
0021 d=read_dicom(filename);
0022 
0023 % Direction Cos Matrix
0024 dcm = direction_cos(d);
0025 
0026 ip=getfield(d,'image_position');
0027 ps=getfield(d,'pixel_spacing');
0028 st=getfield(d,'slice_thickness');
0029 
0030 %画素開始位置
0031 A(:,1)=A(:,1)-ip(1);
0032 A(:,2)=A(:,2)-ip(2);
0033 A(:,3)=A(:,3)-ip(3);
0034 
0035 %回転
0036 A1=inv(dcm)*A';
0037 A1=A1';
0038 if nargin>=6, 
0039   n1=inv(dcm)*n';
0040   n1=n1';
0041 end
0042 
0043 %画素豹スライス豹
0044 A1(:,1)=A1(:,1)./ps(1);
0045 A1(:,2)=A1(:,2)./ps(2);
0046 A1(:,3)=A1(:,3)./st;
0047 if nargin>=6, 
0048   n1(:,1)=n1(:,1)./ps(1);
0049   n1(:,2)=n1(:,2)./ps(2);
0050   n1(:,3)=n1(:,3)./st;
0051 end
0052 
0053 %縮小分位置修正
0054 A1(:,1)=A1(:,1)-dx+1;
0055 A1(:,2)=A1(:,2)-dy+1;
0056 A1(:,3)=A1(:,3)-dz+1;
0057

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