> For the complete documentation index, see [llms.txt](https://gut-analysis-toolbox.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gut-analysis-toolbox.gitbook.io/docs/8.-calcium-imaging-analysis/image-alignment-registration.md).

# Image alignment/registration

Correction of motion artefacts due to tissue contraction or other movement

The alignment workflow uses two plugins in Fiji: [Linear Stack Alignment with SIFT](https://imagej.net/plugins/linear-stack-alignment-with-sift) and [Template Matching and Slice Alignment](https://sites.google.com/site/qingzongtseng/template-matching-ij-plugin). By default, they are run sequentially. The first one will correct for any warping in the image and the second plugin will reduce the lateral movement.&#x20;

* Go to GAT -> Calcium imaging -> Align stack

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FVXDMc3OR8HnXZ3Mk1UpY%2F0.jpeg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* Click "Choose the file to be aligned"

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2F5Q1AkzSOmvQTgIZc3cCF%2F1.jpeg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* Click Open

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FZXrJNOsDxQkWAm48rZd9%2F2.jpeg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* If the tissue is contracting and moving, then tick both options. However, if its only moving in XY without any 'warping' then untick first option. If you're not sure leave the options as they are.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FBymALEhOWK8IM4LzOLSx%2F3.jpeg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* If the first option "Linear alignment with SIFT" was ticked, you'll get another image stack which will have the name "Aligned" at the start. The alignment processmay take a while depending on the image size. We recommend trying it on a small substack to test if its working.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2F9iar2mLula2ZduSXdKdA%2F4.jpeg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* If the Template matching option was ticked, it will undergo a second round of alignment to correct any lateral movements.

<figure><img src="https://460806082-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUMXPxIZOpwi2uL22W18F%2Fuploads%2FC2N13nxKGOJsj2BefWA8%2F5.jpeg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* The final image will be the aligned dataset. A copy of this will also be saved in the same folder as your original dataset.
