Differences between revisions 27 and 28
 Deletions are marked like this. Additions are marked like this. Line 2: Line 2: [[TableOfContents]] <> Line 12: Line 12: As it turns out, it's a grid defined in spherical coordinates:[[BR]] As it turns out, it's a grid defined in spherical coordinates:<
> Line 14: Line 14: * phi (0..pi in 256 steps)[[BR]] * phi (0..pi in 256 steps)<
> Line 27: Line 27: ||<^>inflated ("football")||<^>inflated.H ||-- mean[[BR]]-- variance[[BR]]-- Degrees-of-freedom || ||<^>smoothwm ||<^>sulc (ie: convexity)||-- mean[[BR]]-- variance[[BR]]-- Degrees-of-freedom|| ||<^>smoothwm ||<^>curv? ||-- mean[[BR]]-- variance[[BR]]-- Degrees-of-freedom|| ||<^>inflated ("football")||<^>inflated.H ||-- mean<
>-- variance<
>-- Degrees-of-freedom || ||<^>smoothwm ||<^>sulc (ie: convexity)||-- mean<
>-- variance<
>-- Degrees-of-freedom|| ||<^>smoothwm ||<^>curv? ||-- mean<
>-- variance<
>-- Degrees-of-freedom|| Line 31: Line 31: 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. [[BR]] 4. We expect that the standard template contains nine arrays of (256 * 512) numbers. [[BR]] 5. The mean and variance numbers for each surface each occupy a 256 x 512 image within the TIF file. The degrees-of-freedom data also occupies a 256 x 512 image. These DOF images are all zero except for the "top-left corner", where the single DOF value is found. DOF is basically a count of the subjects (lh.average.curvature.filled.buckner40.tif has a DOF value of 39 because that group actually has 39 subjects ). [[BR]] Notes: <
> 1. "inflated.H" is likely "mean curvature" of the inflated surface, that is the per-vertex value (kmin+kmax)/2.<
> 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.<
> 3. Inspecting the actual data in the standard template, the Degrees-of-freedom data seems to be zero. <
> 4. We expect that the standard template contains nine arrays of (256 * 512) numbers. <
> 5. The mean and variance numbers for each surface each occupy a 256 x 512 image within the TIF file. The degrees-of-freedom data also occupies a 256 x 512 image. These DOF images are all zero except for the "top-left corner", where the single DOF value is found. DOF is basically a count of the subjects (lh.average.curvature.filled.buckner40.tif has a DOF value of 39 because that group actually has 39 subjects ). <
> Line 48: Line 48: attachment:lh_buckner40_im3.jpg {{attachment:lh_buckner40_im3.jpg}} Line 54: Line 54: * This is image 3, counting from zero, of a total of 9 images. This is the second row in the table above, first statistic, so the variable shown is: [[BR]]surface: smoothwm;[[BR]]variable: convexity (ie: sulc);[[BR]]statistic: mean value across the reference subjects (ie: mean of sulc value at this location across subject). * This is image 3, counting from zero, of a total of 9 images. This is the second row in the table above, first statistic, so the variable shown is: <
>surface: smoothwm;<
>variable: convexity (ie: sulc);<
>statistic: mean value across the reference subjects (ie: mean of sulc value at this location across subject). Line 60: Line 60: attachment:fsbert_sulc_spherereg.jpg {{attachment:fsbert_sulc_spherereg.jpg}} Line 64: Line 64: attachment:lh_buckner40_im3_color.jpg {{attachment:lh_buckner40_im3_color.jpg}} Line 68: Line 68: The template is distorted relative to the spherical version, in the manner of a "Mercator projection", as described here [http://en.wikipedia.org/wiki/Map_projection Map projection]: The template is distorted relative to the spherical version, in the manner of a "Mercator projection", as described here [[http://en.wikipedia.org/wiki/Map_projection|Map projection]]: Line 70: Line 70: attachment:gw_mercator.gif {{attachment:gw_mercator.gif}} Line 76: Line 76: 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. 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.

Index

# 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

A template contains curvature-related data as an array of data items that pertain 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:

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

... 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 -- mean -- variance -- Degrees-of-freedom smoothwm sulc (ie: convexity) -- mean -- variance -- Degrees-of-freedom smoothwm curv? -- mean -- variance -- Degrees-of-freedom

Notes:
1. "inflated.H" is likely "mean curvature" of the inflated surface, that is the per-vertex value (kmin+kmax)/2.
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.
3. Inspecting the actual data in the standard template, the Degrees-of-freedom data seems to be zero.
4. We expect that the standard template contains nine arrays of (256 * 512) numbers.
5. The mean and variance numbers for each surface each occupy a 256 x 512 image within the TIF file. The degrees-of-freedom data also occupies a 256 x 512 image. These DOF images are all zero except for the "top-left corner", where the single DOF value is found. DOF is basically a count of the subjects (lh.average.curvature.filled.buckner40.tif has a DOF value of 39 because that group actually has 39 subjects ).

## 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:

Several points to note:

• Dimensions are 256 x 512, so theta 0..2*pi in 512 steps vertically, and phi 0..pi in 256 steps horizontally.
• The image viewer is set to 32 bits per pixel floating point.
• This is image 3, counting from zero, of a total of 9 images. This is the second row in the table above, first statistic, so the variable shown is:
surface: smoothwm;
variable: convexity (ie: sulc);
statistic: mean value across the reference subjects (ie: mean of sulc value at this location across subject).

• Values for this image vary from about -2.8 to +3.3.

### Relationship of template to subject pattern

Given that this is the template to which sample subject bert's data is registered, we should be able to see some resemblance between the two. Here is bert's sulc (convexity) pattern:

... snd here is the template sulc pattern, the same data as shown above but now rotated, flipped and colored green-to-red:

You can probably see the resemblance, especially in the "equatorial regions". The resemblance won't be exact, because the bert image shows bert's sulc intensity, whereas the template image shows the aggregation of sulc data from the reference subjects.

The template is distorted relative to the spherical version, in the manner of a "Mercator projection", as described here Map projection:

# Creating a template

Templates are created using mris_make_template, in a process described here SurfaceRegAndTemplates.

# 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)

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