How to register stacks with Fiji
================================
This guide shows you how to align your microscopy movies (registration) before importing them into Celldetective.
**Prerequisite:** You have installed `Fiji (ImageJ) `_.
We highly recommend adhering to the :doc:`Data Organization <../../concepts/data-organization>` guidelines to structure your folders.
Overview
--------
Registration corrects for stage drift or shaking during acquisition. A common tool for this is the **Linear Stack Alignment with SIFT Multichannel** plugin available in Fiji [#]_.
Step 1: Install the SIFT plugin
-------------------------------
1. Open Fiji.
2. Go to **Help > Update...**.
3. Click **Manage update sites**.
4. Check the **PTBIOP** update site.
5. Click **Close** and then **Apply changes**.
6. Restart Fiji.
For more details on this plugin, see the `Image.sc discussion `_.
Step 2: Register a stack (Manual)
---------------------------------
1. Open your stack in Fiji.
2. Go to **Plugins > BIOP > Linear Stack Alignment with SIFT Multichannel**.
3. Select the transformation mode (usually "Translation" for simple drift).
4. Run the alignment.
5. Save the registered stack as a new TIFF file.
Step 3: Batch registration (Macro)
----------------------------------
To facilitate batch processing, we provide an ImageJ macro that can be used to process multiple positions automatically.
1. Copy the code below (or download the `alignment macro <../../_static/macros/align_stack.ijm>`_) into Fiji's macro editor (**Plugins > New > Macro**).
2. Update the variables in the code (lines 6-9) to match your data:
* ``target_channel``: the channel used for registration.
* ``prefix``: the prefix of the stacks to be aligned (e.g., "After" or "Raw").
3. Run the macro.
4. When prompted, select the **root folder** of your Celldetective experiment.
.. code-block:: javascript
:caption: align_stack.ijm
run("Collect Garbage");
experiment = getDirectory("Experiment folder containing movies to align...");
wells = getFileList(experiment);
octave_steps = "7";
target_channel = "4";
target_channel_int = 4;
prefix = "After"
for (i=0;i