-
Notifications
You must be signed in to change notification settings - Fork 141
Anatomy
(http://web.stanford.edu/group/vista/cgi-bin/wiki/index.php/Anatomical_Methods)
High quality anatomical images (T1-weighted) are important because they images serve as the spatial reference frame in both functional and diffusion-weighted applications. We call the T1-anatomical the reference volume. The T1-anatomical data for a subject are stored in a compressed NIFTI file named t1.nii.gz. For visualization and flattening we segment the T1 data into gray, white and csf regions.
This page is a general overview. There are guides for specific tasks (e.g., alignment to the reference volume, segmenting, flattening) on the Tutorials and Programming pages. There is also a more detailed page for specific Anatomical Processing methods that explain how to combine dicom files into a NIFTI file and align the data.
- The Matlab Image Processing Toolbox (very important)
- SPM (used slightly)
- FSL tools for pre-processing prior to gray/white classification
- ITKGray for tissue (gray/white/csf) classification
There are many anatomical data sets on the system, and many files are created from these anatomical data. It is important to keep them organized. We use a common naming and directory system for storing these files. On Linux, the anatomical data and various processed forms of these data an be found at
- /biac2/wandell2/data/anatomy/subjectCode
We generally combine multiple T1-weighted SPGRs for each subject. We co-register and average these anatomicals together to improve the gray/white contrast and reduce noise. There is a page describing Anatomical Processing methods for acquiring and combining T1-anatomical data.
The images below illustrate the quality we obtain after averaging 6 scans collected in 3 different scan sessions. Anat t1 mbs.jpg
The path to the main anatomy directory differs on Windows and Linux systems. If you typically use one computer, we recommend you store the name of the anatomy directory permanently using the Matlab preference mechanism. Use the command:
- setpref (‘ VISTA ', ‘ defaultAnatomyPath ', ‘ nameOfYourAnatomyDirectory ')
(Programming note: The variable is retrieved in the mrVista function getAnatomyPath();.)
Another source of anatomical data sets is the Human Connectome Project Data which can be accessed at this link. To download the files, first create an account. If prompted to install the Aspera Connect plugin, click on the link and download it. To install it on Linux, open up a terminal and follow the procedure below:
cd <PATH_TO_YOUR_DOWNLOADED_PLUGIN> tar -xzf <pluginName>.tar.gz sh <pluginName>.sh
Log into your account and accept the data use terms by clicking on the button located near the top right of the page. You can now download any of the subject data by clicking on one of the subject options provided near the top of the page.
The standard steps we perform to obtain and segment an anatomy are described on the pages listed below:
- Acquisition: this page describes taking the raw anatomical data from the scanner converting to MrVista-compatible formats (including NIFTI format, resampling to an isotropic resolution (usually 1mm), coregistering multiple measurements if you collected more than one, and (optionally) rotating into AC/PC space. (For applications requiring back-compatibility conversion from the MrGray vAnatomy.dat format is also described).
- Pre-processing: this page describes using the Oxford FSL package to run automated preprocessing steps, including creating a version of the anatomy containing only the brain, and creating an initial segmentation. These steps are not always done, but can often be useful to get started. They require that FSL be installed.
- Gray/White matter segmentation:There pages describe ItkGray and include a step-by-step overview of using ItkGray to produce a high-quality segmentation.
- Create a 3D Surface Mesh: A beneit of segmenting is that functional and diffusion data can be visualized on a 3D mesh representing the gray matter surface. This visualization can help scientific understanding greatly. This page describes how to use the classification files to produce 3D mesh files, and how to view the meshes using MrVista utilities.
- Flattening (optional): This page describes producing flattened cortical patches from the gray matter representations, for use with the Flat view in analyzing functional data. This is not always used, but can be useful for certain applications, like retinotopic mapping.
Detailed instructions for producing a segmentation can be found [here](https://github.com/vistalab/vistasoft/wiki/Segmentation).
There are several methods for aligning Functional or DTI data to the anatomical reference volume. Current methods for aligning functional and anatomical data can be found [here](https://github.com/vistalab/vistasoft/wiki/ACPC%20alignment).
The [Mesh](https://github.com/vistalab/vistasoft/wiki/Mesh) page contains information for creating, smoothing, and displaying 3-dimensional reconstructions of the cortical surface.
We use these meshes routinely to interact with data in both MrVista and MrDiffusion.
This page describes methods related to the collection and analysis of SPGR to get T1 PD TF and aHLF.
This section provides useful information for dealing with common tasks, specifically related to anatomical data.
If you don't have a NIFTI-format T1-weighted image, or the original I-files, but you do have the older vAnatomy.dat file, you can create a new NIFTI format anatomical using
[vData,mmPerVox] = readVolAnat('path/to/vAnatomy.dat');
% Convert mrgray sagittal format to our preferred axial format for NIFTI
vData = flipdim(flipdim(permute(vData,[3 2 1]),2),3);
mmPerVox = mmPerVox([3 2 1]);
xform = [diag(1./mmPerVox), size(vData)'/2; 0 0 0 1];
ni = niftiGetStruct(vData, inv(xform));
ni.fname = '/path/to/new/nifti/file.nii.gz';
writeFileNifti(ni);
Or, here's some alternative code if the preceding doesn't work:
anat = mrLoad('path/to/vAnatomy.dat');
anat.data = mrAnatRotateAnalyze(anat.data);
mrSave(anat, '/path/to/new/nifti/file.nii.gz');
To resample the T1 & class files use the command
- mrGrayResampleNiftiClass(t1File, classFile, outMm)
Talairach coordinates are often used to compare anatomical locations across labs. The Matlab command '''computeTalairach''' launches a GUI to transform vAnatomy (native) coordinates into Talairach coordinates.
Note that the computeTalairach function will give you a talairach coordinate transform. Many labs will report coordinates in MNI space instead. We call this the spatialNorm, which you can generate using the following code:
ni = readFileNifti('3DAnatomy/t1.nii.gz'); % this assumes you are starting from your mrSESSION directory
[sn,template,inv] = mrAnatComputeSpmSpatialNorm(double(ni.data), ni.qto_xyz, 'MNI_T1');
invLUT = rmfield(inv,{'deformX','deformY','deformZ'});
save('3DAnatomy/t1_sn.mat','sn','invLUT');
Once you've computed either the Talairach transform or the MNI (spatialNorm) transform, or both, you can simply use the GUI in the mrVista Volume/Gray view. Choose Talairach under ROI, and either: 1) Enter some Talairach (or MNI) coordinates to be transformed into the subject's space. 2) Load Talairach coordinates from file (not sure what this does), or 3) Load an ROI and compute the Talairach/MNI coordinates for this ROI, using the "Compute Talairach coordinates" menu option.
In the relatively short time brain imaging has been around, it's managed to acquire a heap of different conventions for how to store and display 3-dimensional brain data. Consequently, keeping track of what direction in your data matrices corresponds to what direction in the real world can be exhausting. A thorough, and exceedingly well written summary of the various conventions can be found on this excellent page.
For simplicity's sake, here is the break down: the simple processing described above uses data in which increasing (rows, columns, slices) in the data correspond to increasingly (right, anterior, superior) positions, respectively. This is the standard orientation used in the Talairach convention. This is also called the Neurological convention. (Radiological convention is the same, except that left and right are flipped.) This format can be referred to as RAS for "Right-increasing, Anterior-increasing, Superior increasing".
Sometimes, when papers or code refer to "X, Y, or Z" axes, they mean "left <-> right", "posterior <-> anterior", and "inferior <-> superior" axes, respectively. When you display the first slice of an RAS anatomy using MATLAB or another program, it will show an axial slice at the bottom of the brain in which right is down, and the front of the brain to the right.
The file conventions described below, including the mrGray / mrVista vAnatomy.dat file (and the function VOLUME view in mrVista), use an IPR space, in which (rows, columns, slices) are increasingly (inferior, posterior, right) respectively. This isn't that widely used, but a display of the raw data looks nicer. The first slice of an IPR data set will be the left-most sagittal slice, in which the front of the brain is to the left.
- createVolAnat([imgPathName],[outputVAnatName],[outputUnfoldName])
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;
- Coronal100 = squeeze(img(:,100,:));
- Sagittal100 = squeeze(img(:,:,100));
The command 'mrAnatResliceSpm' resamples the anatomical data(SPM tools required). e.g., to isovoxel a vAnatomy, try this:
- img = readVolAnat('vAnatomy.dat');
- mrAnatResliceSpm(img, eye(4), [], [1]);
If you are not able to install the t1_class.nii.gz straight into mrVista and grow the gray, then do the steps outlined below.
Segmentations produced using the newer ITKGray pipeline reside in a single NIFTI file (usually named t1_class.nii.gz), which is convenient; but the interface to use these files within MrVista is unfortunately not fully debugged. Although the code works for some combinations of MATLAB version and operating system, a key part of the code does not work for other versions. (The main issue seems to be a piece of compiled code, grow_gray, which produces a gray matter graph from the t1 class file NIFTI.) It has been an objective to have this MEX file, along with others in the repository, debugged, but it has been on the back burner for a while. Even assessing whether it will work on a given OS / MATLAB is not clear: the best way to know is to try it out, by selecting the t1_class.nii.gz file as the segmentation.
In cases where the new NIFTI files don't work with mrVista, we back-convert these files to the old format using mrGray. Here is one way to do this:
- Ensure you've saved the main T1-weighted anatomy as a NIFTI file. If you haven't here is simple MATLAB code to do this. (In this case, the anatomy is named t1.nii.gz, and is not to be confused with t1_class.nii.gz, which is the classification rather than the anatomy.)
-
anat = mrLoad('t1.nii.gz', 'nifti');
-
anat.data = mrAnatRotateAnalyze(anat.data);
-
mrSave(anat, 'vAnatomy.dat', 'vanat');
-
- Run the function itkGray2mrGrayClass with no arguments. You will be prompted to select the t1_class.nii.gz file. This function will create two new subdirectories, Left/ and Right/, in the same anatomy directory as the NIFTI file. Within the Left/ and Right/ folders will be mrGray classification file, Left/Left.Class and Right/Right.Class.
- Open mrGray on a Windows machine. (The path to mrGray in the vistasoft repository is vistasoft/trunk/mrAnatomy/MrGray/mrGray.exe.)
- Create a new project, named "Left.mrp" in the left hemsiphere directory.
- Select the menus File | Classification | Load, and select the Left.Class file created in step 2.
- Select the menu Classification | Grow Gray Matter. Press OK.
- Save the gray graph. Select gray matter by holding down Control and left-clicking it. It should change color. Then select File | Save Selected Gray, and choose OK. (Left.Gray is a good default name for it.)
- Optional step if you want to flatten the gray matter: Build a 3D Mesh visualisation in mrGray and save it.
- Select the menu 3D | Build Visualization.
- You will get a dialog box labeled "Visualization Parameters". There will be several tabs at top; the "Structural" tab will be selected first. In this tab, select "White/gray boundary" and set the voxel dimensions appropriately (usually X:1, Y:1, Z:1).
- Select the "Smoothing1", "Decimation", and "Smoothing 2" tabs. For each tab, check off the checkbox "Skip this step".
- Select the "Output" tab. Check off the options "Save output mesh to file" and "Start viewer on completion".
- Press the "Begin" button at bottom.
- A blocky, uninflated mesh representation should be built. Verify that this looks approximately like the gray/white bounder for the appropriate hemisphere, and close the 3D window.
- The mesh file saved (in the old mrGray format, *.MrM) is needed for the flattening code. (A newer version may not need this, but doing things this way works.)
- Repeat steps 3-8 for the Right hemisphere.
- Vistasoft
- Getting Started
- mrVista Overview
- Anatomy
- Functional MRI
- mrVista
- Retinotopy tutorial
- Population RF methods also prf Model, prf_tutorial, prf tutorial
- Diffusion weighted MRI
- Visualization
- Tractography
- Tutorials
- Software overview