For the rigid registration of 2D or 3D image stacks and visualization of the results. Particularly useful when trying to keep a microscopic sample in identical orientation across multiple days, as in in vivo two-photon imaging. A reference image (either 2D or 3D z-stack) taken on the first day will allow accurate registration of subsequent day images, and guide the movement/rotation required for alignment of the sample.
Sister hardware designs for rodent head fixation rigs are available: Go^2-stages on Github
Installation:
- Works on Windows 10/11, Matlab 2017-2023. Installation should take less than 20 minutes.
- Install elastix v4.X (https://github.com/SuperElastix/elastix/releases) (add elastix.exe folder to PATH in Windows System Properties -> Environment Variables panel, and check accessibility to elastix.exe and transformix.exe at command prompt)
- Install elastix wrapper (https://github.com/rcasero/gerardus but please use fork https://github.com/ingiehong/gerardus.git for sustained compatibility) (add matlab/ElastixToolbox and matlab/FileFormatToolbox to MATLAB path)
- Install StackGPS (download and add folder and GUI subfolder to MATLAB path)
- If you need Scanimage TIF support, download scim_openTif.m and parseHeader.m from the 3.8 release or make scanimage.util.opentif available from later versions (https://docs.scanimage.org/About/Download%2BScanImage.html).
- For image file formats other than TIF, download OME BIO-FORMATS Matlab toolbox (https://www.openmicroscopy.org/bio-formats/) and add to MATLAB path.
Getting Started:
- Run stackGPS (without any arguments this function loads the GUI but it also can be used as the main command prompt function)
- Set options including voxel size and high-pass filtering
- Load fixed image and moving image to register
- Press register button to initiate registration (Results should be visible in GUI like above and in text in command line)
- Physically apply resulting shift recommendations and acquire another moving image. Go to 2 and repeat registration.
- Alternative command-line workflow
- Use demo_startGPS.m script to quickly start aligning images.
- compare3D allows easy visualization of the 3D alignment.
- When a reference image is already loaded, use the demo_continueGPS.m script to load just a moving image.
- For batch registration of multiple moving images to one fixed image, start with the demo_stackGPS_batch.m script.
App pseudocode:
- Open moving target image (2D or 3D Moving)
- Open reference Z-stack (2D or 3D Fixed)
- Run elastix (rigid registration mode) to either: a.register 2D moving image on to each slice of the 2D or 3D fixed reference image. b.register 3D moving image to the 3D fixed reference image.
- Check validity of registration and visualize registration.
- Present parameters for adjustment of microscope/sample position.
Later features to work on:
- Automatic positioning for Scanimage/Prariescan
- Tilt adjustment (3D to 3D fitting) (done in v1.1)
- Multi-resolution image adaptation (done in v1.1)
- Plots for fit
- Automatic image header reading - for dimension/channel/XYZ spacing information etc. (done in v1.3 through OME)
- Option to use a subvolume of the reference image.
- Support for multi-channel image registration (done in v1.2)
- Create GUI (done in v1.3)
Updates:
v1.3 -Added GUI -Added image file compatibility through OME BIO-FORMATS
v1.2 -Added batch registration mode -Added demo scripts and more documentation.
v1.1 -Added 3D-to-3D registration -Added save_tif.m for simple tif saving. -Fixed bug with Elastix parameter file location -Optimized Elastix parameters