Quality Checking

From VISTA LAB WIKI

Revision as of 20:58, 20 July 2015 by Rjpatruno (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

[edit] In Matlab

  • Open Matlab R2008b.
  • After waiting for Matlab to finish initializing, cd (change directory) to subject's bin directory: cd Kids\dti\alldata\SUBJECT NAME\dti30_trilin\bin
    • If can't access Kids folder: make sure correct network drive is connected. In the My Computer window, check which drives are connected. It should start with something like "sns2" or "moach."
    • If you're not connected: Tools-->Map Network Drive. Select a drive, and in folder type, "sns2.stanford.edu\your login name." Use your white password to login.
    • If you are connected, but can't access Kids folder, you're probably missing soft links to the folder. In cywin, make a soft link: ls-s \biac2\kgs\projects\Kids.
  • Read in wmProb nifti: ni1=readFileNifti('wmProb.nii.gz');
  • Find and read in segmentation nifti
    • Search: ls ../../3DAnatomy/*nii.gz
    • From displayed files, look for something that says "seg." It may look like this (but naming convention varies): SUBJECT NAME_seg.nii.gz'
    • Finally: ni2=readFileNifti('../../3DAnatomy/SUBJECT NAME.nii.gz')
  • Change the data in the wmProb nifti such that all values greater than 0 are set to 4 (this is arbitrary, but should be consistent) and of data type unit16
    • ni1.data(ni1.data>0)=4;
    • ni1.data=uint16(ni1.data);
  • Make other fields of the ni1 struct match those of the ni2 struct
    • ni1.scl_slope = ni2.scl_slope;
    • ni1.cal_max = ni2.cal_max;
    • ni1.sform_code = ni2.sform_code;
  • Save file as wmProb_binary.nii.gz. Make sure you're still in the bin directory. DO NOT cd anywhere in these steps. If you need to look for a file, use ls.
    • ni1.fname = 'wmProb_binary.nii.gz';
  • ls to make sure wmProb_binary file was made and in correct location.
    • writeFileNifti(ni1);
    • clx

[edit] In ITKGray

  • Open ITKGray.
  • File--> Open--> Grayscale Image. Load subject's b0 image from bin directory. If you have trouble finding it, just type in beginning of pathway to file: i.e. Z/Kids/dti/alldata.
    • Orient yourself: Upper left hand view show axial slices, upper right shows saggital, and lower right shows coronal. You will be working predominantly in the coronal view, but checking against sagittal and axial.
    • Use mouse wheel to scroll anterior/posterior, inferior/superior, lateral/medial, depending on which image you're working with.
    • If necessary, you can enlarge image by clicking + sign in upper right hand corner of each image.
  • These images are often dark, with low contrast. If so, Edit-->Options-->Adjust Image Contrast. Move contrast line to brighten image and increase contrast.
  • Load segmentation image: File--> Open --> Segmentation Image. Load wmProb_binary.nii.gz that you just made.
    • This will open a segmentation that will cover much of the brain.
    • Adjust label opacity. Ideally you want something dark enough that you can see where the label is but light enough that you can also see the underlying brain structures.
  • Starting from medial sagittal slice, scroll anterior and posterior to get a feel for the cerebellum and brain stem in the coronal view. The cerebellum is below the two hemispheres to the posterior of the brain. As you move more anterior, the brain stem will appear as a rectangular shape. Choose a slice towards the posterior end of the brain, where the cerebellum is clearly apparent.
  • Choose paintbrush tool.
    • Shape: Round, Size: ~10
    • Active drawing label: clear. (This effectively sets the paintbrush as an eraser tool).
    • Draw over: all labels
  • Carefully erase the segmentation covering the cerebellum and brain stem in the coronal slices.
    • Check edges against axial and sagittal views. In axial view, cerebellum appears as wavy stripes. In middle sagittal view, cerebellum looks like wavy vertical stripes and are clearly separated from the hemispheres by a gyrus.
    • Don't worry too much about edges, especially if they extend off brain surface, but DO NOT ERASE AREA IN CORTEX.
    • Once the segmentation is edited on a slice, move in the anterior direction. Since the 3D brush is being used, it is unnecessary to erase on every slice. Be sure to check that the 3D brush doesn't miss a few voxels in other slices.


  • Check edits in the sagittal and axial slices. In the axial slice, the segmentation may look uneven and cover parts of the cerebellum--this is just due to this particular viewing angle. Do not edit segmentation on the axial view. If there is a questionable area in the axial or sagittal slices, click on it and look in the coronal view. Make edits as needed.
  • Save file as wmProb_edited.nii.gz' in the subject's bin . Be sure to check the directory for correct location!

[edit] In Matlab

  • Load the edited file: ni1=readFileNifti('wmProb_edited.nii.gz');
  • Load original wmProb file: ni2=readFileNifti('wmProb.nii.gz');
    • Be sure not to overwrite this file!
  • For mask candidate voxels (non-zero voxels in wmProb_edited), rewrite the values with the original probabilities from wmProb:

ni1.data(find(ni1.data))=ni2.data(find(ni1.data));

  • Check your work: showMontage(ni1.data); showMontage(ni2.data);
    • This will open two new figures with a montage of dti images. Both montages should be identical, except ni1 will be missing the cerebellum and brain stem. In picture below, ni1 is the figure on the left.
    • Flip between both pictures several times to ensure nothing else is missing.

Figures produced by show montage. Left montage is edited ni1, missing cerebellum and brain stem. Otherwise, both images are identical

  • Convert fields/formats to original by storing values from ni2 strut in ni1. This undoes the first Matlab step.
    • ni1.scl_slope = ni2.scl_slope;
    • ni1.cal_max = ni2.cal_max;
    • ni1.sform_code = ni2.sform_code;
  • Save your work: writeFileNifti(ni1);
  • ls bin directory to make sure you all your files are present. The bin directory should now include:
    • wmProb.nii.gz
    • wmProb_edit.nii.gz
Personal tools