Difference between revisions of "3D Reslicing using COMKAT image tool (basic)"

From COMKAT wiki
Jump to navigation Jump to search
Line 10: Line 10:
  
 
----
 
----
====Approach I. Demonstrates coordinate transformations====
+
====Approach I. Demonstrate coordinate transformations====
 
Load a file using COMKAT image tool and use the functions to translate and rotate the image volume as you desire.  
 
Load a file using COMKAT image tool and use the functions to translate and rotate the image volume as you desire.  
  
Line 16: Line 16:
  
  
Use read data to ivd,  e.g. read_DICOM()
+
Read data to ivd,  e.g. read_DICOM()
  
 
   ivd = read_DICOM(ivd, pathName, fileName); % load volume into an instance of IVD object;
 
   ivd = read_DICOM(ivd, pathName, fileName); % load volume into an instance of IVD object;
Line 29: Line 29:
 
Specify the transformation matrix based on desired pixel spacing (zoom), position (location), orientation. ref [http://medical.nema.org/dicom/2004/04_03PU.PDF] p. 275
 
Specify the transformation matrix based on desired pixel spacing (zoom), position (location), orientation. ref [http://medical.nema.org/dicom/2004/04_03PU.PDF] p. 275
  
   M = ( Insert the method for generate the transformation );
+
   M = ( Insert the method for generating the transformation matrix );
  
  
Line 47: Line 47:
  
  
Use sliceVolume() to interpolate the results
+
Use sliceVolume() to interpolate the slice
  
 
   slice = sliceVolume(idv, v, u, w, backgroundPixelValue, ‘linear);
 
   slice = sliceVolume(idv, v, u, w, backgroundPixelValue, ‘linear);
Line 55: Line 55:
  
 
   figure, imagesc(slice); axis image % isotropic
 
   figure, imagesc(slice); axis image % isotropic
 +
 +
  
 
----
 
----
====Approach II. Uses coordinateGen to do the coordinate transformation)====
+
====Approach II. Use coordinateGen() to do the coordinate transformation)====
this should create same result as approach 1 but require fewer lines of coding
+
* This should create same result as approach I but require fewer lines of coding since coordinateGen() does most things that are needed.
since coordinateGen does most things that are needed
 
  
  
Line 65: Line 66:
  
 
   ivd = ( Insert the method for reading data );
 
   ivd = ( Insert the method for reading data );
 +
  
 
Use coordinateGen() to generate uvw
 
Use coordinateGen() to generate uvw
  
   [u, v, w] = coordinateGen(ivd, Nc, Nr, pixelSpacing, planePos, orientationInput);
+
   [u, v, w] = coordinateGen(ivd, Nc, Nr, pixelSpacing, planePos, orientation); % Input the desired pixelSpacing, planePos and orientation matrices
  
  

Revision as of 23:27, 7 August 2012

Reslicing 3D image volume using COMKAT image tool (basic)

Overview

Reslicing a 3D (or 3D vs time) image dataset can be accomplished using the COMKAT image tool and sliceVolume(). This example explains how to create image slices from a volume in at a position, plane orientation, and magnification. The approach is to load the image volume dataset into an instance if an ImageVolumeData (abbreviated IVD) object and to use the sliceVolume() method.

Background

sliceVolume() is a mex-file written in c with an interface to MATLAB that makes the operation particularly efficient. COMKATImageTool uses sliceVolume() and you can use it too.


Approach I. Demonstrate coordinate transformations

Load a file using COMKAT image tool and use the functions to translate and rotate the image volume as you desire.

  ivd = ImageVolumeData();


Read data to ivd, e.g. read_DICOM()

  ivd = read_DICOM(ivd, pathName, fileName); % load volume into an instance of IVD object;


Create a list of indicies of all pixels in slice that we are creating

  [i, j] = meshgrid(0 : Nc-1, 0 : Nr-1);
   ij = [c(:)’ ; r(:)’];  % make matrix, each column corresponding to a single pixel in the slice we are creating


Specify the transformation matrix based on desired pixel spacing (zoom), position (location), orientation. ref [1] p. 275

  M = ( Insert the method for generating the transformation matrix );


Calculate physical (mm) location of each pixel in the desired slice

  xyz = M * ij;


Specify the reverse mapping matrix ( xyz --> index space of the original image volume )

  Mhat = ( Insert the method for generate the mapping);


Calculate voxel indcies into the volume corresponding to xyz physical location

  uvw =  Mhat * xyz;


Use sliceVolume() to interpolate the slice

  slice = sliceVolume(idv, v, u, w, backgroundPixelValue, ‘linear);


Display new slice

  figure, imagesc(slice); axis image % isotropic



Approach II. Use coordinateGen() to do the coordinate transformation)

  • This should create same result as approach I but require fewer lines of coding since coordinateGen() does most things that are needed.


Read the image volume into an ImageVolumeData object

  ivd = ( Insert the method for reading data );


Use coordinateGen() to generate uvw

  [u, v, w] = coordinateGen(ivd, Nc, Nr, pixelSpacing, planePos, orientation); % Input the desired pixelSpacing, planePos and orientation matrices


Use sliceVolume() to interpolate

  slice = sliceVolume(idv, v, u, w, backgroundPixelValue, ‘linear);


Display slice

  figure, imagesc(slice); axis image % isotropic