Introduction All the data output from DSI Studio can be loaded into Matlab for further calculation. Likewise, the data exported from Matlab can also be loaded into DSI Studio, provided that the matrixs are named under certain rules and saved in MAT4 format. This data exchange function enables user to manipulate the images using Matlab and presented it using the powerful 3D engine provided by DSI Studio. There are two major format available for data exchange. The .src file contains the information of dimension, voxel size, b-table, and the images extracted from the DICOM or Analyze files (see how to get .src file). To load the .src file into Matlab, extract .src.gz file to create an uncompressed .src file. Then rename the .src file to .mat file and load it in Matlab. The meanings of each exported matrix are explained as follows. dimension This 1x3 vector is the dimension of the containing image. voxel_size The voxel size in each dimension. (mm) image0~imageN The images extracted from the DICOM or Analyze format. These images can be restored to a 3 dimensional matrix by the command "reshape(image0,dimension);" b-table The b-table of the extracted images. After loading the .src file in Matlab, the user can manipulate the data and save it back to a file using the following command "save('filename.src','-v4');" Note that you have to specify '-v4' so that DSI Studio can read the .src file. ![]() A .fib contains the resolve fiber direction and related indecies such gfa, generated from the reconstruction step (see how to get .fib file). To load a .fib file into Matlab, extract the .fib.gz file to create an uncompressed .fib file. Then rename the .fib file to .mat file and load it using Matlab. The meanings of each exported matrix are explained as follows. dimension This 1x3 vector is the dimension of the containing image. voxel_size The voxel size in each dimension. (mm) Fiber orientation The fiber orientations can be stored in two approaches. One is the directional approach, which uses matrices like "dir0", "dir1" ..etc. Another approach is the ODF approach, which uses matrices like "index0","index1",...and "odf_vertices" and "odf_faces". Either way can be used for fiber tracking. dir0, dir1, dir2 (can be replaced by index0, index1,index2) dir0 is the directional vector of the most prominent fiber, and dir1 is the vector of the second most prominent fiber. These matrices have to be "reshaped" to restore to its original form: dir0 = reshape(dir0,[3 dimension]); This will make it a 3-by-x-by-y-by-z matrix. index0, index1, index2 (can be replaced by dir0, dir1, dir2) Although the direction of a fiber is usually represented by a unit vector, to simplify the calculation and to reduce data storage, DSI Studio use a index table for storing the direction of fibers. The actual three dimensional unit vectors are stored in odf_vertices. For instance, if a voxel's index0 value is 5, the voxel's first resolved fiber has the orientation: odf_vertices(:,5+1). Note that the index0 value started from 0, and the index should add 1 to access the correct fiber direction. These three "index" matrices store the "directional index" of the resolved fibers. Note that the matrix is stored in one-dimensional. To use them, apply reshape command to make them a 3-dimensional matrix: index0 = reshape(index0,dimension); Any matrix stored in a dimension of 1-by-total_voxels will be viewed as the quantitative measurements. You may assign a quantitative map using any naming such as "gfa", "diffusivity", "t1_map", ...etc. Among all the quantitative matricies, "fa0", "fa1", ...etc are reserved for measuring the fiber quantity. These "fa" matrices will be used in fiber tracking to determine the extent of the fibers. fa0, fa1, fa2 For each voxel in the image space, DSI Studio assumes that a voxel may contain at most three fiber populations which give three different FA values. The most prominent one will be stored in fa0, and the others stored subsequently. These three matrices (fa0,fa1,fa2) are in fact three dimensional matrices but stored as one dimensional instead. To restored the matrix back to a three dimensional one, use the following command. A = reshape(fa0,dimension); This fa value is defined as follows: fa0 = (The ODF value at the orientation of the most prominent fiber) - (the ODF value of the isotropic part, or the minimum value of the ODF) fa1 = (The ODF value at the orientation of the second most prominent fiber) - (the ODF value of the isotropic part, or the minimum value of the ODF) fa2 = (The ODF value at the orientation of the third most prominent fiber) - (the ODF value of the isotropic part, or the minimum value of the ODF) odf1, odf2, .... The ODF values of each voxel can also be exported from DSI Studio. To enabled such function, check the "record ODF" checkbox in the reconstruction window. This forces DSI Studio to store ODF values as a series of matrices named odf1, odf2,.... For each these odf matrices, the dimension is e.g. 321-by-20000. 321 is the dimension for one ODF vector, and 20000 means the odfs of a total of 20,000 voxels are stored. You nay need to note that the last odf matrix may not have 20,000 columns, and only the ODFs from the voxels with QA > 0 or FA > 0 are stored. For more detail in how to use odf matrix and visualize them, please refer to the ODF visualization document. Similar to saving .src file, users can save the .fib file using the "save xxx.fib -v4" command. The generated .fib files are readily loadable in DSI Studio. Note that some matricies are required in a .fib file, including the dimension (matrix named "dimension"), voxel size (matrix named "voxel_size"), fiber directions (dir0, dir1, dir2 or index0, index1, index2), and fiber anisotropy (fa0, fa1, fa2). ODF information is in optional and can be left out. |
