Documentation‎ > ‎

Read DICOM, NIFTI, Bruker 2dseq, or Varian FDF Files

        

Introduction 


The following list is the image formats supported by DSI Studio.

1. DICOM Format, including image acquired by SIEMENS TIM, SIEMENS Trio, GE SIGNA HDx, and Philips 4D DICOM.

2. Analyze format, Nifti format, 3D volume or 4D volume (diffusion space as the highest dimension order)

3. Bruker 2dseq files

4. Varian FDF files

If your image formats are not listed in the list, you may send me a test image dataset (frankyeh (at) cmu.edu), and I will improve the format support in the future release.

DICOM Files



To parse DICOM files, click the step 1 button in the main window to open the image files. After parsing the DICOM files, DSI Studio will be presenting a new window with a b-value table, as shown in the figure. 

The GUI shows gradient vectors in the image space. DSI Studio reads in the b-table from the headers. DSI Studio is able to retrieve the b-table from DICOM, Bruker method file, and Varian FDF files. The top [Files] menu provides functions to load an external table. You can add more diffusion images using [Files][Open images]

There are cases that the headers do not have b-table information, and the users are required to provide a b-table text file using with the following format (bvalue bvectorx bvectory bvectorz):

3000 0.994200 -0.000000 -0.107600
3000 0.985100 -0.130800 0.111300
3000 0.985100 0.130800 0.111300
3000 0.963800 -0.245300 -0.104400
3000 0.963800 0.245300 -0.104400
3000 0.994200 -0.000000 -0.107600
3000 0.985100 -0.130800 0.111300
3000 0.985100 0.130800 0.111300
3000 0.963800 -0.245300 -0.104400
3000 0.963800 0.245300 -0.104400

The first column is the b-value, and the rest are bx, by and bx of the directional vectors. You can load in the table using [Files][Open b-table];

Once the b-table is loaded, click the Ok button, and DSI Studio will generate a .src file for further reconstruction. This .src file is in fact a .mat file. You may load it in Matlab using the step described in this page.

Rename DICOM files according to their pulse sequences
DSI Studio is able to rename DICOM files and place them in different folders according to their pulse sequences. The function is placed under the "tools" menu, where you can see an item named  "rename DICOM Files".
 
To perform this function, select all the DICOM files that are ready to be renamed, and then the file will be moved into its related folders. It is highly recommended that the DICOM images are renamed first.
 

Applying slice orientation


Started from the September 2011 version, DSI Studio will apply slice orientation correction to the b-table. This approach is suggested by Dr. Kwan-Jin Jung at CMU to consider the slice tilting condition. The detail of the correction is the following. 

corrected b-vector = [slice orientation matrix] * original b-vector;

The first two columns of the slice orientation matrix are obtained from the DICOM header (0x0020,0x0037). The third column is the orthogonal vector calculated from the first two columns, making this matrix a unitary matrix. The corrected b-vector is calculated by applying the orientation matrix to the original b-vector.

NIFTI files may not have slice orientation matrix in the header, and DSI Studio will not apply rotation to the b-table if nifti files are used as the input. Thus, the users are recommended to rotate the b-table by multiplying the slice orientation matrix to the b-table.

Problems in loading GE, Philips, and Toshiba DICOM images


   GE, Philips, and Toshiba scanners often output each slice to an individual DICOM image, and the resulting DTI dataset may contain thousands of image files, causing trouble in parsing DICOM files. The solution is the following:

1. In Step1 open DICOM files, select some DICOM files. 
2. DSI Studio will ask whether you would like to load all other DICOM images. Select yes.
3. Load an external b-table to construct the src file.

   The Toshiba DICOM files may need to be corrected for their b-table orientation by clicking on "swap xy" and "flip z". The user should check out the output fiber orientation to see if the orientation is correct.

   You may need to rename DICOM files first by using the "rename DICOM" function provided by DSI Studio.

B-table problem in the SIEMENS WIP sequence


   Users of the Siemens WIP sequence may experience reconstruction error if the a full sampling scheme is used to acquire the full DSI. The cause to this problem is the b-table in the dicom header. When the WIP sequence acquires the full sampling DSI, it is, in fact, acquiring a half sampling and copying the acquired images to another half to make it a full one. However, the image copy fails to copy the b-table to the Dicom header and results in incorrect reconstruction. This is a known problem in the certain version of the WIP sequence using the full sampling. TrackVis is not affected by this because it is using its own built-in table and does not make use of the one in the Dicom header.

    The solution is the following, after reading the DICOM files, replace the b-table by clicking the "load b-table" button. The correct b-table can be found here. (choose the 515 one if q5 full is used). Replacing the b-table can solve this problem.


4D NIFTI files


    DSI Studio can use 4D nifti file. An example of this type of data is the human connectome project data. NIFTI file header does not contain b-table information, and thus, another text file is often needed to provide the b-table information (Please see the DICOM section for the format). The file can be loaded using the top menu [Files][Open b-table];

    Alternatively, DSI Studio will search in the same directory for b-value files named "bvals" or "bvals.txt" as well as "bvecs" or "bvecs.txt". The b value and b vector can also be loaded using the function under the top menu.

    DSI Studio can also use the gradient nonlinearity information. It will search under the same folder for a file named "grad_dev.nii.gz". A mask file named "nodif_brain_mask.nii.gz" can also be included. 


Bruker 2dseq files


    DSI Studio also supports Bruker images (2dseq file). To load the images, in the main window, click on the "STEP1" button and assign the "subject" file in the folder. DSI Studio will then scan all sessions under this subject and include all diffusion scans. If you have multiple diffusion scans, you may choose to select the "2dseq" file for creating the SRC file. 

    Note that DSI Studio will obtain spatial parameters from other accessory files including "3dproc" and "reco", which is stored in the same directory as 2dseq. In addition to these two files, the b-table will be obtained from the "method" file, which should be stored in the upper directory.  Make sure that these files exist and are in correct relative directories.

    Once the image is loaded, the b-table may need addition flipping (e.g. swap x-y, y-z, or x-z). For example, you may need to swap x-y to get a correct result.

    If you prefer to handle the 2dseq by yourself (e.g. perform addition noise reduction or distortion correction), you may parse the 2dseq using Matlab. The example is provided as follows:
 

Case 1: read 2dseq and convert the image to src format.


    Bruker scanner exported image files as "2dseq" binary files. The following code can be used to transform 2dseq file to .src file for further reconstruction. 

num_dif = 7;
dimension = [128 128 100]; % [x y z] the dimension of the 2dseq file, suppose average=1
voxel_size = [0.1 0.1 0.1]; % [x y z] pixel spacing in mm
f1 = fopen('2dseq','r');
A=fread(f1,'int16');
A=reshape(A,dimension(1),dimension(2),dimension(3),num_dif);

% slope is a dimension(3) x num_dif matrix that defines the scaling parameters 
% input the slope here
slope=[81.3139111191806 81.3139111191806 81.3139111191806 81.3139111191806
...
]
slope = slope./min(min(slope));
slope = reshape(slope',dimension(3),num_dif);
for i = 1:dimension(3)
for j = 1:num_dif
    A(:,:,i,j) = A(:,:,i,j)/slope(i,j);
end
end

% image0 ~ imageN, where N is the number of diffusion gradient encoding
image0 = reshape(A(:,:,:,1),prod(dimension),1);
image1 = reshape(A(:,:,:,2),prod(dimension),1);
image2 = reshape(A(:,:,:,3),prod(dimension),1);
image3 = reshape(A(:,:,:,4),prod(dimension),1);
image4 = reshape(A(:,:,:,5),prod(dimension),1);
image5 = reshape(A(:,:,:,6),prod(dimension),1);
image6 = reshape(A(:,:,:,7),prod(dimension),1);

% if averaging on the repeat images is needed, run
% repeat = 5;
% dimension(3) = dimension(3)/repeat; 
% image0 = reshape(sum(reshape(image0,dimension(1),dimension(2),dimension(3),repeat),4),prod(dimension),1)/repeat;
% image1 = reshape(sum(reshape(image1,dimension(1),dimension(2),dimension(3),repeat),4),prod(dimension),1)/repeat;
% image2 = reshape(sum(reshape(image2,dimension(1),dimension(2),dimension(3),repeat),4),prod(dimension),1)/repeat;
% image3 = reshape(sum(reshape(image3,dimension(1),dimension(2),dimension(3),repeat),4),prod(dimension),1)/repeat;
% image4 = reshape(sum(reshape(image4,dimension(1),dimension(2),dimension(3),repeat),4),prod(dimension),1)/repeat;
% image5 = reshape(sum(reshape(image5,dimension(1),dimension(2),dimension(3),repeat),4),prod(dimension),1)/repeat;
% image6 = reshape(sum(reshape(image6,dimension(1),dimension(2),dimension(3),repeat),4),prod(dimension),1)/repeat;

% the b-table should be arranged in the format of [b-value1 bx by bz; b-value2 bx by bz;...;b-valueN bx by bz] 

b_table=[0 0 0 0
1000 0.337968743631421 0.337968743631421 0
1000 0 0.337968743631421 0.337968743631421
1000 0.337968743631421 0 0.337968743631421
1000 -0.337968743631421 0.337968743631421 0
1000 0 -0.337968743631421 0.337968743631421
1000 0.337968743631421 0 -0.337968743631421
]';% [b_value bx by bz; b_value bx by bz; ...]
b_table(4,:) = -b_table(4,:);    % note that the z-dimension should be flipped for images from bruker 
fclose(f1);
clear A;
clear ans;
clear f1;
save '1.src' '-v4'
    
    The saved .src file can be used by DSI Studio for further reconstruction. Bruker images may have been scaled during the post-processing. The scaling parameters are recorded in reco file (RECO_slope). If this is the case, you have to scale the image back to get the correct reconstruction result.
   

Merge multiple scans


DSI Studio allows for merging multiple scans of the same subjects. There are two ways to merge them. The first way assumes that the head position is the same for the scans (e.g. the subject was scanned twice consecutively). To merge the scans, first click on "STEP1 Open source image" and select the files from the first scan. DSI Studio will open up a dialog showing the DWI loaded. Then in the top menu, click on the item [Files][Open images...] and select the files from the second scans. The dialog will append these new DWIs to the existing list. If you load 4D NIFTI files here, you may need to manually concatenate the b-table and load the merged b-table using [Files[Load b-table...].


If you would like to merge scans of the same subject but the scans were acquired at different time points, additional steps are needed to linearly coregister the head position. The steps are the following:

(1) create separate SRC files for each of the scan
(2) open the SRC file using STEP2 and rotate the volume to a common T1w image using the top menu item [Edit][To T1w/T2w space]. DSI Studio will ask for a T1W image volume. 
(3) export the rotated volume using the top menu [File][Save 4D nifti]. You may also need to export the b-table as a text file here.
(4) manually merge the b-table text file using a text editor.
(5) Back to the DSI Studio main window. Click "STEP1: Open source images" and open the first exported 4D nifti file. DSI Studio will open up a new dialog. Add the second 4D NIFTI using the top menu item [Files][Open Images...].
(6) Load the merged b-table created from (4) using the top menu item [Files][Load b-table...]
(7) Create a joint SRC file which has merged all previous scans.

Flip b-table


DSI Studio allows for flipping the b-table when creating the SRC file. The functions are under the [Edit] menu.

Batch creating SRC files


DSI Studio supports batch processing to create SRC files. To use this function, the subjects' NIFTI files should be renamed as "data.nii.gz", and the b-table file should be renamed as "bvals" and "bvecs", following the FSL format. These three files should be placed under a subfolder named by the subject ID. Click on the "Create SRC files" button under the "Tools: Batch Processing" tab to initiate the batch function. The SRC files will be created within the subject folder as "data.src.gz".


Correction for susceptibility artifact


Susceptibility artifact causes a strong distortion in the frontal lobe and temporal lobe, and its correction requires two set of dMRI scan acquired at A-P and P-A orientation. DSI Studio currently does not have a routine to correct for susceptibility artifact, but it can work with FSL topup to complete the work.

Please follow the procedure to do the correction.

1. Acquire AP scan and PA scan
2. Parse the DICOM and generate one SRC file for the AP scan and another SRC file for the PA scan.
3. Open the AP SRC file and save b0 nifti file as "APb0.nii.gz" using [File][Save b0 image...]. Repeat the same procedure to get another b0 from PA scans.
4. merge AP b0 and PA b0 using the following command:

fslmerge -t APPAb0.nii.gz APb0.nii.gz PAb0.nii.gz

5. Prepare a text file named T.txt recording the phase encoding direction and echo spacing. The following examine is for AP and PA scans.

0 1 0 0.087
0 -1 0 0.087

6. Run FSL topup using the following command:

topup --imain=APPAb0.nii.gz --datain=T.txt --config=b02b0.cnf --out=my_topup_results --subsamp=1

7. Prepare 4D nifti for AP and PA scans. You may open the SRC file in STEP2 and save 4D nifti files as "AP.nii.gz" using [File][Save 4D nifti]. You may also need to save the b-table using [File][save b-table...]. The b-table for AP and PA should be identical, and you need only to save one.


8. Apply TOPUP result using the following command. It will generate one APPA.nii.gz file with distortion corrected.

applytopup --imain=AP.nii.gz,PA.nii.gz --inindex=1,2 --datain=T.txt --topup=my_topup_results --out=APPA

9. Create SRC file from APPA.nii.gz and the b-table generated in step 7.
 

Quality Control for SRC files

It is recommend that the SRC files created have a quality control procedure to ensure its integrity and quality. To do this, use [Tools: Batch Processing][SRC Files Quality Control] and select the folder that contains SRC files (DSI Studio will search for all SRC files in the subdirectories). DSI Studio will provide a report in the following format, which can be paste in Excel:


FileName Image dimension Resolution DWI count Shell count Max b-value B-table matched Neighboring DWI correlation
100206 145 174 145 1.25 1.25 1.25 271 3 3010 Yes 0.940147
100307 145 174 145 1.25 1.25 1.25 271 3 3010 Yes 0.94786
100408 145 174 145 1.25 1.25 1.25 271 3 3010 Yes 0.939901
100610 145 174 145 1.25 1.25 1.25 271 3 3010 Yes 0.936777
101006 145 174 145 1.25 1.25 1.25 271 3 3010 Yes 0.94627
101107 145 174 145 1.25 1.25 1.25 271 3 3010 Yes 0.936007
101309 145 174 145 1.25 1.25 1.25 271 3 3010 Yes 0.892282
101410 145 174 145 1.25 1.25 1.25 271 3 3010 Yes 0.952898
101915 145 174 145 1.25 1.25 1.25 271 3 3010 Yes 0.94145
102008 145 174 145 1.25 1.25 1.25 180 3 3010 No 0.937926

You may need to check the consistency of image dimension, resolution, DWI count, shell count.

The B-table matched field indicates whether the subjects b-table is consistent with the first subject.

"Neighboring DWI correlation" calculates the correlation of low-b DWI volumes that have similar gradient direction. Higher correlation indicates good quality. The value will decrease if there is prominent eddy current artifact, head motion, or any head coil issues that may impact the diffusion signals. It is recommended to sort this values and inspect low correlations subjects to see if there is any quality issue.
Comments