Documentation‎ > ‎

3D Volume rendering


Introduction

Many users find the 3D volume rendering in DSI Studio very useful and are wondering whether it is possible to use it to render  other image dataset. The answer is yes, and this document details the steps that use the 3D engine in DSI Studio to do 3D rendering of any given image dataset. This feature is provided in versions after Jan 2012. Here is the use case example.


      
Input: 3D image volume in matlab

Export FIB using MATLAB

Say we have a image volume stored in MATLAB as a 3-dimensional matrix, as shown by the figure above. Run the following command to save it as a .fib file.

dimension=size(image);
image=reshape(image,1,[]);
save volume.fib -v4

The above matlab command stores the image volume in a MAT V4 format that can be loaded in DSI Studio. The maximum loadable size of the image is around 200-by-200-by-200. Volume larger then this may causes error, and you may use the following code to reduce the size in half for each dimension. (if your image volume is loadable, ignore the following commands).

image = reshape(image,dimension);
image = image(:,:,1:2:dimension(3));
image = image(:,1:2:dimension(2),:);
image = image(1:2:dimension(1),:,:);
dimension = size(image);
image = reshape(image,1,[]);
save volume.fib -v4

Load FIB in DSI Studio

Open DSI Studio to load the fib file, then you can see the images loaded. To render the surface, adjust the fiber threshold and select from the top menu [Regions]->[Whole Brain Seeding]. The color of the surface can be changed from the color button in the upper left-hand window, and opacity of the rendered surface can be further adjusted from the options provided in the right option window, as shown in the following figure. You may visualize a cross section by the instruction mentioned in here.


DSI Studio loaded with an image volume.


You may also loaded an ROI and visualize it together with the surface rendering. The ROI can be stored in a MATLAB matrix and use the following command to save it as a ROI file.

 

dimension=size(roi);
roi=reshape(roi,1,[]);
save roi.mat -v4

This ROI file can be loaded in DSI Studio from the top menu [Regions]->[Open], and its color can also be changed from color buttons in the upper left hand corner window. Changing the opacity of the rendering can help visualize the ROI along with the surface.


Create rotation GIF


To create the rotation GIF, select from top menu [View]->[Save Rotation Images]. Assign the file name such as W.bmp, and specify number of frames in one cycle (e.g. 60 frames in one rotation cycle). This will save several BMP files in the directory. To create a GIF from these BMP files, execute the following matlab command in the directory storing the BMP files:

n = 64;
% number of frames save as the BMP file
f = getframe;
[im,map] = rgb2ind(f.cdata,256,'nodither');
im(1,1,1,n) = 0;
for i = 0:n-1
  % the BMP files names are w_0001.bmp w_0002.bmp ... etc
  fname = 'w_';
  if i < 10
      fname = strcat(fname,'0');
  end
  if i < 100
      fname = strcat(fname,'0');
  end
  I = imread(strcat(fname,int2str(i),'.bmp'));
  imshow(I);
  f = getframe;
  im(:,:,1,i+1) = rgb2ind(f.cdata,map,'nodither');
end
% output GIF as result.gif
imwrite(im,map,'result.gif','DelayTime',0,'LoopCount',inf);

The exemplary GIF is shown in the following: (click it to see how it rotates)
 


  
Comments