Documentation‎ > ‎

ODF visualization

    
    

Introduction


DSI Studio is able to export ODF data for further processing and visualization. To visualize ODF, you need to build a FIB file with ODF data exported (see Reconstruction(DTI, QBI, DSI, GQI, QSDR) for detail) . This can be done by checking the "ODF" box in the advanced options.
 
Load the .fib in DSI Studio. The ODF panel is now ready to present the ODFs.  

The ODFs will be presented along the slice, and you can switch rendering option in the window to the right.


Visualize ODF in Matlab        


    The detail about the ODF matrices is documented at Data exchange between DSI Studio and Matlab

    There are several important notes you may need to know to visualize ODF using Matlab.

    1) A FIB file with ODF exported is needed to visualize the ODFs. To know how to export ODF in a FIB file, please refer to the reconstruction document. Extract the ".fib.gz" file to ".fib" file and rename it as a ".mat" file. This mat file is ready to be loaded in Matlab by double click or using the "load" command. 

    2) The odfs matrix is split into several smaller matrices (odf0, odf1, odf2, ...) because a single large matrix may easily cause memory insufficiency. To restore the full odfs matrix, use odfs = [odf0 odf1 odf2 odf3 odf4 odf5 odf6 odf7 odf8 odf9 odf10];

    3) The odfs matrix stores ALL ODFs. It is a concatenation of all ODF vectors obtained from voxels in the brain mask (Background voxels are ignored). Thus, you may found out the dimension of this odfs matrix is 321-by-n, where n is the total number of voxels in the mask, and 321 is the half of the sampling directions. You can get n by length(find(fa0( : ) > 0.00)), assuming the all fa0 value is not zero in the mask.

    4) The sampling directions of an ODF is stored in the "odf_vertices" matrix. To learn more about the meaning of each matrix in the .fib file, please refer to the "data exchange between DSI Studio and Matlab" page.
     
    5) Since ODF values are symmetric regarding the origin, we need only to record the non-redundant part. Thus, an ODF with 642 sampling directions can be represented using a vector with a dimension of 321. The elements of this ODF vector are scalar values. For example, if an ODF is isotropic, then its representing vector is [1,1,1,1,...., 1]. 

    6) The surface points of an ODF can be calculated by multiplying the ODF vector with "odf_vertices".

Accessing the ODF at coordinate x,y,z


If you want to visualize a voxel at a specific coordinate, say, (x,y,z), you may need to obtain the ODF vector first using the following codes.  If you supply an invalid coordinate (e.g. where fa0 = 0 and the odf is not recorded), odf_full(x,y,z) will return zero and cause an error. 

function odf=get_odf_at(odfs,fa0,dimension,x,y,z)
% use odfs = [odf0 odf1 odf2 odf3 odf4 odf5 odf6 odf7 odf8 odf9 odf10 ...add all odfs up]; to merge the odfs matrix. 
% the odfs, fa, and dimension matrixs are stored in fib file
% to load fib file in matlab, extract it and rename it as a .mat file
odfs = odfs(:,max(odfs) > 0);
non_zero_index = find(fa0(:) > 0.00);
odf_full=zeros(1,prod(dimension));
odf_full(:,non_zero_index) = 1:length(non_zero_index);
odf_full = reshape(odf_full(:),dimension(1),dimension(2),dimension(3));
odf = odfs(:,odf_full(x,y,z));
end

     
Having the ODF, you can visualize it using the following codes. To use the code, you may also need to assign the "odf_vertices" and "odf_faces" matrices, which can be downloaded from at the bottom of the page (odf8.mat is for odf vertices with 8-fold tessellation. odf6.mat is for 6-fold, ...etc).

      
      For ODFs from QSDR reconstruction, the total number of ODFs may not be the same as the number of the voxel with fa0 > 0. This discrepancy happens only in QSDR reconstruction. The cause to this discrepancy is that the size of the MNI space (the template space) is often larger than the original image space. As a result, some voxels in MNI space do not have a corresponding voxel in the original image space, and DSI Studio assumes these voxels have diffusion signals=0. This leads to zero QA
and causes this discrepancy.

      The solution is using the fa0 matrix from the NTU90 atlas (NTU90.template.2mm.fib.gz.mean.fib.gz) instead of the fa0 matrix from the subject's fib data to locate the ODF location. The total number of voxels with fa > 0 in NTU90 atlas should be consistent with the number of ODFs in the subject data.


3D presentation of the ODFs in Matlab


function plot_odf(odf,odf_vertices,odf_faces)
%
%  plot_odf(odf,odf_vertices,odf_faces)
%  you may need to supply odf_vertices and odf_faces matrixs,
%  which can be download from at the bottom of this page
%
odf_points = odf_vertices.*repmat(odf-min(odf),[2 3])';
polygon.vertices = odf_points';
polygon.faces = odf_faces'+1;
polygon.facevertexcdata = abs(odf_vertices)';
p = patch(polygon);
set(p,'FaceColor','interp','EdgeColor','none','SpecularStrength',0);
daspect([1 1 1])
view(3); axis tight
camlight
lighting gouraud
end


ODF visualization with principle direction


You may use the following code to visualize the ODF along with the principle fiber directions. The subroutine find_peak can be found here.


function plot_odf_with_dir(odf,odf_vertices,odf_faces)
%
p=find_peak(odf,odf_faces);
for i = 1:length(p)
    line( odf_vertices(1,p(i))*[-1 1],...
          odf_vertices(2,p(i))*[-1 1],...
          odf_vertices(3,p(i))*[-1 1]);
end
hold on
plot_odf(odf(:)/max(odf),odf_vertices,odf_faces);%%
end



ċ
example_odf.mat
(7k)
Fang-Cheng Yeh,
Apr 14, 2012, 7:25 PM
ċ
find_peak.m
(1k)
Fang-Cheng Yeh,
Mar 20, 2012, 8:23 AM
ċ
get_odf_at.m
(1k)
Fang-Cheng Yeh,
Jun 9, 2013, 7:04 PM
ċ
odf6.mat
(6k)
Fang-Cheng Yeh,
Jun 24, 2013, 11:19 AM
ċ
odf8.mat
(10k)
Fang-Cheng Yeh,
Jun 24, 2013, 11:20 AM
ċ
plot_odf.m
(0k)
Fang-Cheng Yeh,
Mar 20, 2012, 8:23 AM
ċ
plot_odf_with_dir.m
(0k)
Fang-Cheng Yeh,
Mar 20, 2012, 8:24 AM
Comments