Differences between revisions 16 and 17
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
This page relates to the "template" file type used in the !FreeSurfer pipeline as part of the process of coregistering the surfaces of individual subjects. Several concepts are needed to understand this area. (In the following "?h." refers to either of "lh." or "rh.".)

 * '''Inflated Spherical "version" of a subject's surface mesh:''' As the pipeline progresses, the initial white surface mesh is "inflated" (with constraints to minimize distortion) to several other states, one of which is a sphere, typically '''?h.sphere'''. The inflation process is constrainted to minimize the total distortion.

 * '''Vertex-wise data is applicable to all versions of the surface:''' The inflation process does not add or remove any vertices, so any data associated with the white vertices (such as curvature or convexity) is still associated with the same-numbered vertices of the sphere mesh. This is the basis of displays such as the following where a per-vertex variable "convexity" of the white surface (aka 'sulc') is plotted in color on the '''lh.sphere surface''':[[BR]]attachment:fsbert_sulc_sphere.jpg

 * '''Registration of a subject's surface''' to a reference consists of a 2-D warp of the subject's sphere surface so that the individual's curvature data pattern aligns with a reference '''template''' pattern. The template was previously prepared as the "average" (loosely speaking) pattern from a group of representative subjects. The standard template supplied with !FreeSurfer is in the files '''{fshome}/average/?h.average.curvature.filled.buckner40.tif'''.

 * '''The result of registation''' is yet another version of the subject's surface mesh, typically named '''?h.sphere.reg''', this time with the x,y,z vertex positions still on a sphere, but warped so that the subject's curvature pattern best aligns with the template data. Here is the same convexity data, now plotted on the '''lh.sphere.reg''' surface. Similar pattern, but "stretched around". [[BR]]attachment:fsbert_sulc_spherereg.jpg.

What is to be discussed below relates to the content and format of the template file just mentioned.

== Disambiguation: template, atlas, parameterization file ==
In many places, especially within the !FreeSurfer source code, the word '''"atlas"''' is often used interchangeably with "template". I am reserving the term atlas for the GCA files used in labeling regions. Further, a template file is sometimes referred to as a "parameterization file".
This page describes technical aspects of the "template" file type used in the !FreeSurfer pipeline as part of the process of coregistering the surfaces of individual subjects. If you are unfamiliar with this process and the programs involved, please see this overview: SurfaceRegAndTemplates.
Line 23: Line 10:
As might be guessed, a template contains curvature-related data as an array of data items that correspond to a grid of points on the sphere -- but which grid? Is it a specific surface mesh supplied with FreeSurfer? A standard "icosahedron"? As might be guessed, a template contains curvature-related data as an array of data items that correspond to a grid of points on the sphere -- but which grid? Is it a specific surface mesh supplied with FreeSurfer? A standard "icosahedron" such as ic7.tri with an even distribution of 327680 triangles?
Line 29: Line 17:
So, for any single data item, we can expect an array(256 * 512) of numbers. So, for any single data item, we can expect an array(256 * 512) numbers.
Line 44: Line 32:
1. "inflated.H" is likely "mean curvature", that is the per-vertex value (kmin+kmax)/2.[[BR]]
2. I'm not sure on the measure in the 3rd row because in the mris_register source code it's calculated on the fly, and hard to tell which options cause it to do what.[[BR]]
1. "inflated.H" is likely "mean curvature" of the inflated surface, that is the per-vertex value (kmin+kmax)/2.[[BR]]
2. I'm not certain on the measure in the 3rd row because in the mris_register source code it's calculated on the fly, and hard to tell which options cause it to do what.[[BR]]
Line 54: Line 42:
The !FreeSurfer code includes a library called that is suitable for handling 2-D images (ie: pictures), which already knows how to work with 2-D arrays of pixels, including keeping track of the type of data at each pixel, rows and columns and so on. In addition, it is able to save and load various image formats. As it happens, the TIFF format is able to do two useful things in this regard: save multiple images, and apply compression. The !FreeSurfer code includes a library that is suitable for handling 2-D images (ie: pictures), which already knows how to work with 2-D arrays of pixels, including keeping track of the type of data at each pixel, rows and columns and so on. In addition, it is able to save and load various image formats. As it happens, the TIFF format is able to do two useful things in this regard: save multiple images, and apply compression.
Line 56: Line 44:
So, the template's (256 * 512) arrays are handled in memory as though they are images, and loaded and saved using TIFF functions. So, the template's (256 * 512) arrays are handled in memory data structures as though they are picture images, and loaded and saved using TIFF functions.
Line 58: Line 46:
By way of closure, here is lh.average.curvature.filled.buckner40.tif as seen in an image viewer (irfanview):[[BR]]
attachment:bucknertif4.gif [[BR]]
Given that this is the template to which lh.sphere.reg (shown above) was registered, doubtless you can immediately see the resemblance in the pattern :-).
By way of closure, here is lh.average.curvature.filled.buckner40.tif as seen in an image viewer (irfanview):

attachment:bucknertif4.gif

Given that this is the template to which subject bert's data is registered, doubtless you can immediately see the resemblance of this pattern to the bert lh.sphere.reg shown here SurfaceRegAndTemplates :-).
Line 74: Line 64:








Index TableOfContents

Context: The surface registration process

This page describes technical aspects of the "template" file type used in the FreeSurfer pipeline as part of the process of coregistering the surfaces of individual subjects. If you are unfamiliar with this process and the programs involved, please see this overview: SurfaceRegAndTemplates.

Template data

Template data grid

As might be guessed, a template contains curvature-related data as an array of data items that correspond to a grid of points on the sphere -- but which grid? Is it a specific surface mesh supplied with FreeSurfer? A standard "icosahedron" such as ic7.tri with an even distribution of 327680 triangles?

As it turns out, it's a grid defined in spherical coordinates:BR

  • theta (0..2*pi in 512 steps)
  • phi (0..pi in 256 steps)BR

... the two parameters of the so-called "surface parameterization" (elsewhere known as u and v).

So, for any single data item, we can expect an array(256 * 512) numbers.

Template data items

The various programs involved have some flexibility in what size and shape of template to work with, but here I will describe the standard ?h.average.curvature.filled.buckner40.tif.

The registration process does not simply attempt to match a subject and template based on a single variable. Instead it works with several variables, and statistics about those variables.

Here's what I think is in the standard template:

Surface

Measure

Variable/Statistics

inflated ("football")

inflated.H

-- meanBR-- varianceBR-- Degrees-of-freedom

smoothwm

sulc (ie: convexity)

-- meanBR-- varianceBR-- Degrees-of-freedom

smoothwm

curv?

-- meanBR-- varianceBR-- Degrees-of-freedom

Notes:[[BR]] 1. "inflated.H" is likely "mean curvature" of the inflated surface, that is the per-vertex value (kmin+kmax)/2.BR 2. I'm not certain on the measure in the 3rd row because in the mris_register source code it's calculated on the fly, and hard to tell which options cause it to do what.BR 3. Inspecting the actual data in the standard template, the Degrees-of-freedom data seems to be zero.

So, we expect that the standard template contains nine arrays of (256 * 512) numbers.

Template data storage format; What's with this tif business anyway?

In several areas throughout FreeSurfer, non-obvious choices have been made regarding persisting (saving to disk for later use) various kinds of data, and this is the case for templates.

The FreeSurfer code includes a library that is suitable for handling 2-D images (ie: pictures), which already knows how to work with 2-D arrays of pixels, including keeping track of the type of data at each pixel, rows and columns and so on. In addition, it is able to save and load various image formats. As it happens, the TIFF format is able to do two useful things in this regard: save multiple images, and apply compression.

So, the template's (256 * 512) arrays are handled in memory data structures as though they are picture images, and loaded and saved using TIFF functions.

By way of closure, here is lh.average.curvature.filled.buckner40.tif as seen in an image viewer (irfanview):

attachment:bucknertif4.gif

Given that this is the template to which subject bert's data is registered, doubtless you can immediately see the resemblance of this pattern to the bert lh.sphere.reg shown here SurfaceRegAndTemplates :-).

Several points to note:

  • Status bar shows dimensions of 256 x 512, so theta 0..2*pi in 512 steps vertically, and phi 0..pi in 256 steps horizontally.
  • A separate information window tells us 32 bits per pixel (the template data are 32-bit floating point), though as an image this is interpreted as 24 bit color.
  • The "Page 4/9" indicates that we are looking at the smoothwm convexity mean data. (ie: second row in the table above, first statistic.)

Creating a template

That's done using mris_make_template. Separate article in the works.

Extracting template data

Supposing one wanted to extract data from a template, for example to inspect the pattern, and perhaps display it in color on a sphere. The extraction is possible using ["mrisp_paint"] which samples the template to a target surface and produces a "curv" format file which can be displayed in tksurfer.

Author(s)

GrahamWideman

TemplateTifImageFiles (last edited 2009-02-02 20:29:28 by GrahamWideman)