Fundamental of Medical Imaging
MATLAB Tutorial II Junmo An [email protected] Office Hour: Monday 2:30pm – 4:30pm (PGH 315)
Department of Computer Science, University of Houston What is DICOM?
• Digital Imaging and COmmunications in Medicine (DICOM) • A joint project (ACR-NEMA) – The American College of Radiology (ACR) – The National Electrical Manufacturers Association (NEMA) • Reference data and presentations – http://dicom.nema.org/ – ftp://medical.nema.org/medical/Dicom/Multifra me/
2 General Communication Model
DICOM is a vast set of standards Concentrate here on file format for MRI
3 Simplified DICOM File Structure
Metadata Pixel Value
PatientName StudyDate Modality ImageOrientationPatient Public Fields ImagePositionPatient PixelSpacing
…
PrivateFields Private Fields
4 DICOM Terms: Module
Patient Module Attribute Tag Type Attribute Description Patient Name (0010,0010) 2 Patient’s Full Name Patient ID (0010,0020) 2 Primary hospital identification number or code for the patient Issuer of Patient ID (0010,0021) 3 Identifier of the Assigning Authority that issued the Patient ID … (See DICOM Part 3: Information Object Definitions)
• Module: an architectural convenience; a logical group of attributes about a common topic • Type: (1) Required (2) May Be Empty if Unknown (3) Optional (C) Conditional
5 Image Plane Module Attributes
Attribute Tag Type Attribute Description Pixel Spacing (0028,0030) 1 Physical distance in the patient between the center of each pixel, specified by a numeric pair - adjacent row spacing (delimiter) adjacent column spacing in mm. (Pixel Spacing = Row Spacing \ Colum Spacing = 0.30\0.25) Image Orientation (0020,0037) 1 The direction cosines of the first row (Patient) and the first column with respect to the patient. Image Position (Patient) (0020,0032) 1 The x, y, and z coordinates of the upper left hand corner (center of the first voxel transmitted) of the image, in mm. Slice Thickness (0018,0050) 2 Nominal slice thickness, in mm. Slice Location (0020,1041) 3 Relative position of exposure expressed in mm.
6 Geometry Information in DICOM
• DICOM uses a right handed LPH (=LPS) coordinate system. • Relates to patient, not scanner. • DICOM provides public fields that relate a 2D image to 3D patient space. – ImagePositionPatient • Coordinate of top left image pixel. – ImageOrientationPatient • Unit vector along an image row, the unit vector along a column.
7
Sagittal Transverse Coronal (frontal)
8 ImagePositionPatient (0020,0032)
ImagePositionPatient (x\y\z) ImagePositionPatient -10\-10\5 IPP + origin PixelSpacing 2\4 3 * PixelSpacing[1] 2\-10\5 x-axis
PixelSpacing[0]
y - axis
IPP + 3 * PixelSpacing[0] 2\-6\5
PixelSpacing[1]
• PixelSpacing and Transverse Cut ImagePositionPatient are in mm. • ImageOrientationPatient are two unit vectors (direction cosines). • Height and Width give number of rows IPP = ImagePositionPatient and columns. 9 ImageOrientationPatient (0020,0037)
• Should have 6 values • (Xx\Xy\Xz\Yx\Yy\Yz) – Direction cosines of the image plane relative to the RCS. – The first direction (X vector) is the direction of the image rows in the RCS. – The second direction (Y vector) is the direction of the image columns in the RCS.
RCS = Reference Coordinate System
10 ImageOrientationPatient (0020,0037)
ImagePositionPatient 0\0\10 • 1\0\0\0\1\0 PixelSpacing 1\1
– The X vector is (1,0,0) Z
meaning it is exactly (0,0,10) A X 1\0\0 directed with the image pixel matrix row direction. • (푐표푠 0° , 푐표푠 90° , 푐표푠 90°) – The Y vector is (0,1,0) R L meaning it is exactly directed with the image pixel matrix column Y 0\1\0 P (3,3,10) direction. • (푐표푠 90° , 푐표푠 0° , 푐표푠 90°)
11 ImageOrientationPatient (0020,0037)
• 0.5\0\-0.8660254\0\1\0 – The X vector (0.5,0,-0.8660254) is the direction of the image rows in Z the RCS. • The image rows are rotated 60° from Y the patient's X direction (right-to-left) R and 150° from the patient's Z direction ퟏퟓퟎ° P (feet-to-head). – (푐표푠 60°, 푐표푠 90°, 푐표푠 150°) X ퟔퟎ° – The Y vector (0,1,0) is the direction A
of the image columns in the RCS. L • The patient's Y direction is perpendicular to the image X axis. X 0.5,0,-0.8660254
12 Finding an Image Pixel Coordinate in LPH
IPP + 3 * IOP(1:3) * PixelSpacing[1] + 1* IOP(4:6) * PixelSpacing[0] IPP = ImagePositionPatient IOP = ImageOrientationPatient
13 Putting it all together
• ImageOrientationPatient – rotation • ImagePositionPatient – translation • PixelSpacing – scaling
14 Composing the overall transform
IPP = ImagePositionPatient
15 Direction Cosines in 3D with Homogeneous Coordinates
16 Displaying a 2D image in 3D using surf(X,Y,Z,img)
17 Reading Metadata from DICOM info = dicominfo('CT-MONO2-16-ankle.dcm');
>> info.Modality
ans = CT
18 Reading Image Data from DICOM
I = dicomread('CT- MONO2-16- ankle.dcm');
OR info = dicominfo('CT- MONO2-16- ankle.dcm'); I = dicomread(info);
19 Viewing Images from DICOM Files imshow(I); imshow(I,'DisplayRange colorbar; ',[]); colorbar; – Autoscaling syntax
20 Writing Image Data or Metadata to a DICOM File dicomwrite(I,'ankle.dcm'); Imodified = I; Imodified(Imodified == 4080) = 32; imshow(Imodified,[]);
Removing text characters
21 Shepp-Logan Head Phantom
P = phantom('Modified Shepp- Logan',200); imshow(P);
• 3D Shepp-Logan head phantom – http://www.mathworks.com/matla bcentral/fileexchange/9416 – http://tomography.o-x- t.com/2008/04/13/3d-shepp- logan-phantom/ – https://sites.google.com/site/hisp eedpackets/Home/shepplogan
22 Displaying Images of MRI Data load mri; D = squeeze(D); % a 128-by-128-by-1-by-27 array to a 128-by-128-by-27 figure('Colormap',map); image_num = 15; % 1 to 27 image(D(:,:,image_num));
23 Displaying a 2D Contour Slice cm = brighten(jet(length(map)),-.5); figure('Colormap',cm); contourslice(D,[],[],image_num); axis ij; xlim(x); ylim(y); daspect([1,1,1]);
24 Displaying 3D Contour Slices phandles = contourslice(D,[],[],[1,12,19,27],8); view(3); axis tight; set(phandles,'LineWidth',2);
25 Displaying 3D MRI Slices load mri; D = squeeze(D); h=slice(double(D),[],[],1:27); shading interp; colormap gray; alpha(.1);
26 User Driven Orthogonal Slicer
27 Applying an Isosurface to the MRI Data figure('Colormap',map) Ds = smooth3(D); hiso = patch(isosurface(Ds,5),... 'FaceColor',[1,.75,.65],... 'EdgeColor','none'); isonormals(Ds,hiso); view(35,30); hcap = patch(isocaps(D,5),... 'FaceColor','interp',... 'EdgeColor','none'); axis tight; daspect([1,1,.4]); lightangle(45,30); set(gcf,'Renderer','zbuffer'); lighting phong; set(hcap,'AmbientStrength',.6); set(hiso,'SpecularColorReflectance',0,'S pecularExponent',50); 28 User Driven isosurface Plotting
29 Display multiple image frames as rectangular montage load mri; montage(D,map); figure; montage(D, map, 'Indices', 1:9);
30 Managing DICOM Files
• Problem: Thousands of files with meaningless names. How do you store, browse and retrieve the ones you want? • Tools – OsiriX: Mac based viewer. – 3DSlicer: Viewer (Windows, Mac OS X & Linux). – MicroDicom: Viewer working under Windows. – DCM4CHE: Database and web viewer. – Many others – see http://www.idoimaging.com
31 OsiriX
• Free. • Mac based only. • Good functionality. • Popular with clinicians. • OsiriX MD is $649. • Allows user to add and write plugins. • http://www.osirix- viewer.com
32 3DSlicer • Free. • Working under Windows, Mac OS X and Linux. • Good functionality. – Interactive segmentation. – Volume rendering. – 4D Image Viewer. • Extension Manager for exploring and installing plug-ins. • http://www.slicer.org
33 MicroDicom
• Free. • Fast and Light. • Windows based only. • Limited functionality. • Thumbnails view in Windows explorer on .dcm. • http://www.microdico m.com
34 References
• Book – “MATLAB Graphics and Data Visualization Cookbook” by Nivedita et al. – "MATLAB® 7 3-D Visualization" by The MathWorks • Publication – "The Fourier reconstruction of a head section" by Shepp, L.A. et al. – "Three-Dimensional Analytical Magnetic Resonance Imaging Phantom in the Fourier Domain" by Cheng et al. • Lecture Note – “DICOM Technical Concepts” by Kevin O’Donnell – “DICOM (for MRI images)” by David Atkinson
35
? Do you have any questions? Junmo An [email protected] http://mrl.cs.uh.edu Thank you
36