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.
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".
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.
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.
You may use the following code to visualize the ODF along with the principle fiber directions. The subroutine find_peak can be found here.