FSL

# Some examples of composite warps |

## Contents

- Introduction
- Transforming a functional image into standard space
- Transforming an image (e.g. a mask) in standard space into functional space

## Introduction

Here we show how to perform some common tasks that involve going back and forth between different spaces when the mapping from one space to the other consists of more than a single transform.

## Transforming a functional image into standard space

Let us say we have an image in "functional space" that we call `example_func` and an image in "structural space" that we call `highres`. For a given subject these images are simply a functional image (`example_func`) and a structural image (`highres`) aquired on that particular subject. The naming reflects the names given to them in a standard analysis with `feat`.

Let us further say that there is a file named `example_func2highres.mat`with a rigid-body transformation mapping `example_func` onto `highres`. This file will have been produced by a call to `flirt`, possibly from within `feat`. Let us also assume that there is a non-linear mapping of `highres` onto standard space called `highres2standard_warp.nii.gz`.

We can now transform `example_func` straight to standard space with the command

`applywarp --ref=standard --in=example_func --warp=highres2standard_warp --premat=example_func2highres.mat --out=example_func_in_standard_space`

which will combine the transforms in `highres2standard_warp` and `example_func2highres.mat` into a single transform that is applied to `example_func`. Note that in the example above we specified `standard` as our reference image in standard space. This will work when in a `feat` directory where `standard` will point to the image that was used as `--ref` when running `fnirt`. If you are somehere else you will need to explicitly specify that image (e.g. `--ref=$FSLDIR/data/standard/MNI152_T1_2mm`).

## Transforming an image (e.g. a mask) in standard space into functional space

Let us say we have a region of interest (ROI) for the putamen that has been defined in standard space, and let us also assume that we want to extract a time-series from the putamen in a number of different subjects. We would then want to transform the putamen ROI into the functional space of each of those subjects. The required transform is then the opposite (inverse) of the case above, i.e. we want the standard->functional transform. This will also be a composite transform, one that is a combination of the inverses of the individual transforms. If you are running `feat` there will already be an inverse of `example_func2struct` calculated for you with the name `highres2example_func.mat`. If not, it can easily be created using the command

`convert_xfm -omat highres2example_func.mat -inverse example_func2highres.mat`

We also need the inverse of the non-linear transform `highres2standard_warp`. If you have run `featquery` it will already exist and be called `highres2standard_warp_inv`. If not it can be generated with the command

`invwarp --ref==highres --warp=highres2standard_warp --out=highres2standard_warp_inv`

These two (`highres2example_func.mat` and `highres2standard_warp_inv`) can now be used to bring the mask into standard space with the command

`applywarp --ref=example_func --in=mask_in_standard_space --warp=highres2standard_warp_inv --postmat=highres2example_func.mat --out=mask_in_functional_space`

N.B. that we have now used the `--postmat` argument (rather than the `--premat` argument as we did for the forward transform). This is "equivalent" to

where A and B are matrices (linear transforms). Note also that `applywarp` uses linear interpolation as default which means that the image `mask_in_functional_space` will have values between 0 and 1 (assuming `mask_in_standard_space` was binary). Direct use of `mask_in_funcional_space` will yield a weighted average, which may or may not be approppriate. It (`mask_in_functional_space`) can be converted to a binary mask using e.g.

`fslmaths mask_in_functional_space -thr 0.5 -bin mask_in_functional_space`

Copyright © 2007, University of Oxford. Jesper Andersson.