Jump to: navigation, search

This page describes how to convert a set of raw T1-weighted anatomy images from the scanner format into the format used by mrVista. It covers the steps of converting formats, coregistering and averaging together multiple measurements, resampling the anatomy to a standard resolution, and (optionally) rotating the anatomy into AC/PC space.


[edit] Acquiring T1 anatomicals

[edit] Scanner Protocols

The protocols for acquiring our T1s at the Lucas Center are described on a separate, private page (Stanford users only).

[edit] Organizing the raw data files

Perform the multiple MR measurements and retrieve the raw image files from the scanner. If you have made multiple T1 measurements, place each group of image files in its own sub-directory. We suggest naming the sub-directories sequentially, such as 001, 002, ... or spgr1, spgr2, ... and so forth.

[edit] Processing T1 anatomicals

[edit] Create an NIFTI format file for each of the T1-weighted scans

[edit] Data Collected from the Lucas Center (GE)

Use Matlab to run niftiFromDicom

 >> niftiFromDicom(dicomDir, [outDir=dicomDir/..], [studyId=], [sortByFilenameFlag=false], [makeAxialFlag=true])
  • niftiFromDicom loads all the dicom files found in the specified dicomDir and packs the data from each individual series into a nifti file. All the nifti files are saved in outDir, named with the studyID ie. exam number and series number.
  • An older version, mrAnatMakeNiftiFromIfiles, is recommended only if the first one fails, for example if you have I files (old GE format) not dicoms. This function will reorient the volume so that it is in a 'cannonical' orientation (axial, left-is-left, right-is-right), and save it as nifti. With sagittal slices, this is pretty much your only choice.
  • TIPS: Contra to the function's name, it will work on dicoms as well, not I files necessarily. However, niftiFromDicom is more robust.If this code reports an error because of a non-existent field, please add the code of "if isfield(), end; " for protection.

[edit] Data Collected from SIEMENS Scanners

Use dcm2nii to convert the dicoms to nifti

  • If you have dcm2nii installed and in your Linux path:
 $ dcm2nii fullpath/to/your/dicom/directory/0001.dcm
  • If you're on Windows: (a) Download and install dcm2nii. (b) Run the dcm2niigui program in Program Files > Mricron. (c) File > Open - select yourDicomDirectory. (d) The program will convert the dicoms and output a niftiFile.
Note: At this point it's a good idea to rename the resulting nifti file. dcm2nii returns an exorbitantly long file name by default.

2. Set the xForm to work with our software: This has to be done because the qto_xyz transform should be the same as the sto_xyz xForm.

  • In Matlab (in the directory containing yourNiftiFile):
  1. ni = readFileNifti('yourNiftiFile.nii.gz');
  2. ni = niftiSetQto(ni,ni.sto_xyz);
  3. ni.fname = 'newNiftiFileName.nii.gz');
  4. writeFileNifti(ni);

The specific issues with the nifti created by this process lie in whether some parameters are correctly dimed, especially freq_dim, phase_dim,slice_dim,slice_start and slice_end. One solution to this issue is through other tools: dinifti and MRIConvert seem to perform well according according to a user. Discussion for these solutions can be further found here.

[edit] Other Options

If one of the above methods does not work for you consider the following options:

  • In Linux, run dinifti (from NYU CBI).
  • Windows: run dcm2nii (developed by Chris Rorden).
  • Windows: you can use MRIConvert (from University of Oregon). The current version is 2.0 Beta - we have had success with rev. 21 of the beta software. (Under the "Help" menu, select "About" to see the version information.) In the upper window, click "Add Folder" and select the folder with your DICOM images. We recommend *not* using the "Add Files" option, as this may fail if there are many image files. Choose "NIFTI" as the output format (using the dropdown menu). Click the "Directory" button, and choose an output directory for your NIFTI file. Finally, click the "Convert All" button at the bottom. The process should take less than a minute.

NOTE: rev. 21 of MRIConvert seems to work correctly only in processing axial slices. Sagittal slices end up incorrectly oriented in fslview. Similarly, dcm2nii produces errors in the next step with sagittals.

== Resample and Align to AcPc==
mrAnatAverageAcPcNifti: Set Ac, Pc and Mid Sagital points.
    1. In MATLAB run mrAnatAverageAcPcNifti to (a) align the other T1 weighted scans to the first, (b) reslice each to 1 mm isotropic voxels , and (c) average the scans, and (d) save out the averaged and resliced NIFTI file.
    i. Place cursor on the anterior commisure > Click "Set Ac"
    ii. Place cursor on the posterior commisure > Click "Set Pc"
    iii. Place cursor on the mid-sagital slice (choose a high point on the sagital slice) > Click "Set MidSag".
    iv. Click "Finish"
    Example for Averaging many t1s: >> mrAnatAverageAcpcNifti({'t1_1.nii.gz','t1_2.nii.gz','t1_3.nii.gz','t1_4.nii.gz'},'t1.nii.gz');
    • Important: Even if you only have just one T1-weighted scan, use this function. It will still do the 1mm isovoxel reslicing and realign to ac-pc space. Alternatively, you can avoid reslicing but still have the benefit of ac-pc alignment by setting the qto transform in your NIFTI file to an ac-pc transform with mrAnatSetNiftiXform (in VISTASOFT/Anatomy/VolumeUtilities).
    • To realign to ac-pc space, you need to specify the pixel coordinates of a couple of landmarks for the first volume in your fileNameList. You can specify these on the command line if you happen to know them. Or, you can leave them empty and a GUI will come up allowing you to specify the AC, PC and another mid-sagital reference point. Be sure to choose a mid-sagital point high on the head, this helps the alignment algorithm. For help see section 3.4 on the Anatomical Methods page.
    • NOTE: In this GUI, if any of the views is looking funny (i.e., if the coronal is lying on its side, or the axial is upside down, etc), you should go back to step 2 and remake the nifti(s). You can also use the function displayVol to visualize your data. Usage: displayVol([matrix or path to MR volume], [slice], [colormap]);

[edit] Create vAnatomy.dat (Old Style)

    This step is no longer necessary. It was used in older mrVista functional data sets and the older vAnatomy.dat files are still used in these older sets. >> createVolAnat([NIFTI file path],'vAnatomy.dat'); For some calculations mrVista requires a special anatomy file (vAnatomy.dat). This function starts with the NIFTI file you created and produces a standard vAnatomy.dat file and a corresponding UnfoldParams.mat file. If you omit the arguments, a GUI will allow you to select the name of the t1 nifti file (the average you created above). You may need to change the filter at the bottom to show nifti files, rather than analyze. createVolAnat reads the t1 file and then shows you some example slices and the intensity histogram. The slices and histogram appear in a window. In the subplot for the histogram (upper left), select lower and upper limits to the MR values. The routine shows you the effect on the MR data for these values. Choose upper and lower values that maximize the gray/white contrast, without saturating the white matter completely. If you don't understand this, click a few times and you will get the idea. After each click you are given the option of keeping (or not) the particular choice. (We should improve the UI here.) When you accept your selection, the vAnatomy.dat file and the UnfoldParams.mat file will be written to disk. You can select where they are written. The default is the current directory. The data saved in the volume anatomy file are a 3D volume. The dimensions are (sup-inf, ant-post, left-right). So, to view axial slice 100, specify only sup-inf, you can run >> [img,mmPerPix,volSize,fileName] = readVolAnat([fileName]) >> Axial100 = squeeze(img(100,:,:)); >> imagesc(Axial100); colormap gray; To see Coronal (specify only ant-post) or Sagittal (specify only left-right) you can use >> Coronal100 = squeeze(img(:,100,:)); >> Sagittal100 = squeeze(img(:,:,100)); Alternately, you can use the utility displayVol to look at the vAnatomy.dat file.
Personal tools