Archive pour 30 juillet 2008

matlab .m Techniques for Visualizing Scalar Volume MRI Data

Techniques for Visualizing Scalar Volume Data

What Is Scalar Volume Data?

Typical scalar volume data is composed of a 3-D array of data and three coordinate arrays of the same dimensions. The coordinate arrays specify the x-, y-, and z-coordinates for each data point.

The units of the coordinates depend on the type of data. For example, flow data might have coordinate units of inches and data units of psi.

A number of MATLAB® functions are useful for visualizing scalar data:

  • Slice planes provide a way to explore the distribution of data values within the volume by mapping values to colors. You can orient slice planes at arbitrary angles, as well as use nonplanar slices. (For illustrations of how to use slice planes, see slice, a volume slicing example, and slice planes used to show context.) You can specify the data used to color isosurfaces, enabling you to display different information in color and surface shape (see isocolors).
  • Contour slices are contour plots drawn at specific coordinates within the volume. Contour plots enable you to see where in a given plane the data values are equal. See contourslice for an example
  • Isosurfaces are surfaces constructed by using points of equal value as the vertices of patch graphics objects.

Example — Ways to Display MRI Data

Changing the Data Format
Displaying Images of MRI Data
Displaying a 2-D Contour Slice
Displaying 3-D Contour Slices
Displaying an Isosurface
Adding an Isocap to Show a Cutaway Surface
Defining the View
Add Lighting

An example of scalar data includes Magnetic Resonance Imaging (MRI) data. This data typically contains a number of slice planes taken through a volume, such as the human body. MATLAB includes an MRI data set that contains 27 image slices of a human head. This example illustrate the following techniques applied to MRI data:

  • A series of 2-D images representing slices through the head
  • 2-D and 3-D contour slices taken at arbitrary locations within the data
  • An isosurface with isocaps showing a cross section of the interior

Changing the Data Format

The MRI data, D, is stored as a 128-by-128-by-1-by-27 array. The third array dimension is used typically for the image color data. However, since these are indexed images (a colormap, map, is also loaded) there is no information in the third dimension, which you can remove using the squeeze command. The result is a 128-by-128-by-27 array.

The first step is to load the data and transform the data array from 4-D to 3-D.

load mri
D = squeeze(D);

Displaying Images of MRI Data

To display one of the MRI images, use the image command, indexing into the data array to obtain the eighth image. Then adjust axis scaling, and install the MRI colormap, which was loaded along with the data.

image_num = 8;
axis image

Save the x- and y-axis limits for use in the next part of the example.

x = xlim;
y = ylim;

Displaying a 2-D Contour Slice

You can treat this MRI data as a volume because it is a collection of slices taken progressively through the 3-D object. Use contourslice to display a contour plot of a slice of the volume. To create a contour plot with the same orientation and size as the image created in the first part of this example, adjust the y-axis direction (axis), set the limits (xlim, ylim), and set the data aspect ratio (daspect).

axis ij

This contour plot uses the figure colormap to map color to contour value.

Displaying 3-D Contour Slices

Unlike images, which are 2-D objects, contour slices are 3-D objects that you can display in any orientation. For example, you can display four contour slices in a 3-D view. To improve the visibility of the contour line, increase the LineWidth to 2 points (one point equals 1/72 of an inch).

phandles = contourslice(D,[],[],[1,12,19,27],8);
view(3); axis tight

Displaying an Isosurface

You can use isosurfaces to display the overall structure of a volume. When combined with isocaps, this technique can reveal information about data on the interior of the isosurface.

First, smooth the data with smooth3; then use isosurface to calculate the isodata. Use patch to display this data as a graphics object.

Ds = smooth3(D);
hiso = patch(isosurface(Ds,5),...

Adding an Isocap to Show a Cutaway Surface

Use isocaps to calculate the data for another patch that is displayed at the same isovalue (5) as the surface. Use the unsmoothed data (D) to show details of the interior. You can see this as the sliced-away top of the head.

hcap = patch(isocaps(D,5),...

Defining the View

Define the view and set the aspect ratio (view, axis, daspect).

axis tight 

Add Lighting

Add lighting and recalculate the surface normals based on the gradient of the volume data, which produces smoother lighting (camlight, lighting, isonormals). Increase the AmbientStrength property of the isocap to brighten the coloring without affecting the isosurface. Set the SpecularColorReflectance of the isosurface to make the color of the specular reflected light closer to the color of the isosurface; then set the SpecularExponent to reduce the size of the specular spot.

set(gcf,'Renderer','zbuffer'); lighting phong

Example of an Isocap

The isocap uses interpolated face coloring, which means the figure colormap determines the coloring of the patch. This example uses the colormap supplied with the data.

To display isocaps at other data values, try changing the isosurface value or use the subvolume command. See the isocaps and subvolume reference pages for examples.


Volume visualization of data sets defined on 3D grids. help matlab

Volume visualization is the creation of graphical representations of data sets that are defined on three-dimensional grids. Volume data sets are characterized by multidimensional arrays of scalar or vector data. These data are typically defined on lattice structures representing values sampled in 3-D space. There are two basic types of volume data:

  • Scalar volume data contains single values for each point.
  • Vector volume data contains two or three values for each point, defining the components of a vector.

An example of scalar volume data is that produced by the flow M-file. The flow data represents the speed profile of a submerged jet within an infinite tank. Typing

[x,y,z,v] = flow;

produces four 3-D arrays. The x, y, and z arrays specify the coordinates of the scalar values in the array v.

The wind data set is an example of vector volume data that represents air currents over North America. You can load this data in the MATLAB® workspace with the command

load wind

This data set comprises six 3-D arrays: x, y, and z are the coordinate data for the arrays u, v, and w, which are the vector components for each point in the volume.

Selecting Visualization Techniques

The techniques you select to visualize volume data depend on what type of data you have and what you want to learn. In general,

  • Scalar data is best viewed with isosurfaces, slice planes, and contour slices.
  • Vector data represents both a magnitude and direction at each point, which is best displayed by stream lines (particles, ribbons, and tubes), cone plots, and arrow plots. Most visualizations, however, employ a combination of techniques to best reveal the content of the data.

The material in these sections describes how to apply a variety of techniques to typical volume data.

Steps to Create a Volume Visualization

Creating an effective visualization requires a number of steps to compose the final scene. These steps fall into four basic categories:

  1. Determine the characteristics of your data. Graphing volume data usually requires knowledge of the range of both the coordinates and the data values.
  2. Select an appropriate plotting routine. The information in this section helps you select the right methods.
  3. Define the view. The information conveyed by a complex three-dimensional graph can be greatly enhanced through careful composition of the scene. Viewing techniques include adjusting camera position, specifying aspect ratio and project type, zooming in or out, and so on.
  4. Add lighting and specify coloring. Lighting is an effective means to enhance the visibility of surface shape and to provide a three-dimensional perspective to volume graphs. Color can convey data values, both constant and varying.

Volume Visualization Functions

MATLAB functions enable you to apply a variety of volume visualization techniques. The following tables group these functions into two categories based on the type of data (scalar or vector) that each is designed to work with. The reference page for each function provides examples of the intended use.

Functions for Scalar Data

Function Purpose
contourslice Draw contours in volume slice planes
isocaps Compute isosurface end-cap geometry
isocolors Compute the colors of isosurface vertices
isonormals Compute normals of isosurface vertices
isosurface Extract isosurface data from volume data
patch Create a patch (multipolygon) graphics object
reducepatch Reduce the number of patch faces
reducevolume Reduce the number of elements in a volume data set
shrinkfaces Reduce the size of each patch face
slice Draw slice planes in volume
smooth3 Smooth 3-D data
surf2patch Convert surface data to patch data
subvolume Extract subset of volume data set

Functions for Vector Data

Function Purpose
coneplot Plot velocity vectors as cones in 3-D vector fields
curl Compute the curl and angular velocity of a 3-D vector field
divergence Compute the divergence of a 3-D vector field
interpstreamspeed Interpolate streamline vertices from vector-field magnitudes
streamline Draw stream lines from 2-D or 3-D vector data
streamparticles Draw stream particles from vector volume data
streamribbon Draw stream ribbons from vector volume data
streamslice Draw well-spaced stream lines from vector volume data
streamtube Draw stream tubes from vector volume data
stream2 Compute 2-D stream line data
stream3 Compute 3-D stream line data
volumebounds Return coordinate and color limits for volume (scalar and vector)

matlab .m , voxel render a 3-D array using 2-D OpenGL texture maps.

VOL3D Volume (voxel) render a 3-D array using 2-D OpenGL texture maps.

Useful for visualizing and exploring 3-D data such as MRI images.

This function requires OpenGL hardware acceleration. See ‘opengl’ command for more information.

Use vol3dtool for editing the colormap and alphamap. Adjusting these maps will allow you to explore your 3-D volume data at various intensity levels.


v = flow(50);
h = vol3d(‘cdata’,v,’texture’,’3D’);

See vol3d.m m-help for more information.


alliance for medical image computing Kit = free open source software platform


The NA-MIC Kit is a free open source software platform. The NA-MIC Kit is distributed under a BSD-style license without restrictions or « give-back » requirements and is intended for research, but there are not restrictions on other uses. It consists of the 3D Slicer application software, a number of tools and toolkits such as VTK and ITK, and a software engineering methodology that enables multiplatform implementations. It also draws on other « best practices » from the community to support automatic testing for quality assurance. The NA-MIC kit uses a modular approach, where the individual components can be used by themselves or together. The NA-MIC kit is fully-compatible with local installation (behind institutional firewalls) and installation as an internet service. Significant effort has been invested to ensure compatibility with standard file formats and interoperability with a large number of external applications.

See this presentation on the NA-MIC Kit for more information.

Download Central

Please go here to download Slicer software, documentation and data.

Software Packages

3D Slicer

3D Slicer is a software package for visualization and medical image computing. A tutorial for prospective users of the program can be found on the web. See our tutorials page for an introduction to the use of 3D Slicer. More…

The Visualization Toolkit VTK

The Visualization Toolkit is an object-oriented toolkit for processing, viewing and interacting with a variety of data forms including images, volumes, polygonal data, and simulation datasets such as meshes, structured grids, and hierarchical multi-resolution forms. It also supports large-scale data processing and rendering. More…

The Insight Toolkit ITK

The Insight Segmentation and Registration Toolkit (ITK) is an open-source software toolkit for performing registration and segmentation. Segmentation is the process of identifying and classifying data found in digitally sampled representations. Typically the sampled representation is an image acquired from such medical instrumentation as CT or MRI scanners. Registration is the task of aligning or developing correspondences between data. For example, in the medical environment, a CT scan may be registered with a MRI scan in order to combine the information contained in both. More…

KWKidgets GUI Toolkit

KWWidgets is an Open Source library of GUI classes based on Tcl/Tk with a C++ API. This library was originally developed by Kitware for ParaView, and now has been extended in functionality and architecture thanks to NAMIC support. More…

Teem Libraries and Command Line Tools

Teem is a coordinated group of libraries for representing, processing, and visualizing scientific raster data. Teem includes command-line tools that permit the library functions to be quickly applied to files and streams, without having to write any code. More…

XNAT Web-based Image Informatics Server

The Extensible Neuroimaging Archive Toolkit (XNAT) is an open source software platform designed to facilitate management and exploration of neuroimaging and related data. XNAT includes a secure database backend and a rich web-based user interface.

NA-MIC is working to provide a portable, easy-to-install and easy-to-administer version of XNAT that can be deployed as part the Kit. These efforts will build on ongoing work in the BIRN community to integrate Slicer with XNAT.


BatchMake is a cross platform tool for batch processing of large amount of data. BatchMake can process datasets locally or on distributed systems using Condor (a grid computing tool that enables distributed computing across the network). Some of the key features of BatchMake include: 1) a BSD License, 2) CMake-like scripting language, 3) distributed scripting via Condor, 4) a centralized remote website for online statistical analysis. 4) a user Interface using FLTK, and 5) BatchMake is cross platform. More…

CMake The Cross-platform Make Tool

CMake is used to control the software build process using simple platform, compiler and operating system independent configuration files. CMake generates native makefiles and workspaces that can be used in the development environment of your choice. That is, CMake does not attempt to replace standard development tools such as compilers and debuggers, rather it produces build files and other development resources that can benefit from automated generation. Further, once CMake configuration files are created, they can be used to produce developer resources across the many platforms that CMake supports. CMake is quite sophisticated: it is possible to support complex environments requiring system configuration, pre-processor generation, code generation, and template instantiation. More…

New: CMake has been adopted by KDE, one of the world’s largest open source software systems.

CDash, CTest, CPack Software Process Tools

As an adjunct to CMake the tools CDash, CTest, CPack are used to test and package all components of the NAMIC kit. CTest is a testing client that locally performs testing on a software repository, and then communicates the results of the testing to CDash (and other testing, dashboard servers such as DART2). CPack is a cross-platform tool for packaging, distributing and installing the NAMIC kit on various systems including Linux, Windows, and Mac OSX. More…

DART Testing Server

DART is a testing server, meaning that it gathers the results of testing from clients (such as CTest) and aggregates them on the testing « dashboard ». This dashboard is central to the NAMIC software process; it provides a centralized web site where NAMIC Kit developers and users can ascertain the day-to-day health of the software, and repair the software immediately if faults are discovered. It facilitates distributed development, and provides the stability that complex software such as the NAMIC Kit requires to support a large community of users. More…




NA-MIC Kit in Numbers

The numbers in this table are statistics characterizing the NA-MIC kit. They provide an estimate of the scale of the Kit, including approximate costs to create and total effort expended. Note that estimates such as these are required because large open-source software systems cannot be tracked via direct investment since much of the effort is voluntary in nature, and distributed across the world through a variety of organizations.
Source: Captured on May 30 2008. See the Ohloh website for an explanation of how the numbers were computed.

Package Lines of code Person years Price tag at 100k per person year
Slicer 587,919 161 $16,068,440
KWW 189,627 49 $ 4,925,590
VTK 1,344,989 385 $38,521,873
ITK 711,474 197 $19,712,495
CMAKE 213,671 56 $ 5,586,895
Total 3,047,680 848 $84,815,293


Blog Stats

  • 223 070 hits


Flickr Photos

juillet 2008