Image Registration Module
Image registration functions using cucim, scikit-image, and SimpleITK.
This module contains functions for image registration leveraging tools like cucim, scikit-image, and SimpleITK, optimized for use with qi2lab 3D MERFISH data.
History:
- 2024/12: Refactored repo structure.
- 2024/07: Prepared to remove all Dask usage and integrate functions into the DataRegistration class as static methods.
- 2024/01: Updated for qi2lab MERFISH file format v0.1.
- 2023/07: Initial commit.
Functions:
Name | Description |
---|---|
apply_transform | Apply simpleITK transform |
compute_optical_flow | Compute the optical flow to warp a target image to a reference image. |
compute_rigid_transform | Calculate initial translation transform using scikit-image |
make_flow_vectors | Arrange the results of a optical flow method to display vectors in a 3D volume. |
warp_coordinates | First apply a translation transform to the coordinates, then warp them using a given displacement field. |
apply_transform(image1, image2, transform)
Apply simpleITK transform
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image1 | ArrayLike | reference image | required |
image2 | ArrayLike | moving image | required |
transform | Transform | simpleITK transform object | required |
Returns:
Name | Type | Description |
---|---|---|
resampled_image | ArrayLike | transformed moving image |
Source code in src/merfish3danalysis/utils/registration.py
compute_optical_flow(img_ref, img_trg)
Compute the optical flow to warp a target image to a reference image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img_ref | ArrayLike | reference image | required |
img_trg | ArrayLike | moving image | required |
Returns:
Name | Type | Description |
---|---|---|
field | ArrayLike | optical flow matrix |
Source code in src/merfish3danalysis/utils/registration.py
compute_rigid_transform(image1, image2, use_mask=False, downsample_factor=4.0, projection=None)
Calculate initial translation transform using scikit-image phase cross correlation. Create simpleITK transform using shift.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image1 | ArrayLike | reference image | required |
image2 | ArrayLike | moving image | required |
use_mask | Optional[bool] | use mask for middle 1/3 of image | False |
downsample_factor | Optional[float] | amount of downsampling applied before calling registration | 4.0 |
projection | Optional[str] | projection method to use | None |
Returns:
Name | Type | Description |
---|---|---|
transform | simpleITK transform | translation transform |
shift_xyz | Sequence[float] | xyz shifts in pixels |
Source code in src/merfish3danalysis/utils/registration.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
make_flow_vectors(field, mask=None)
Arrange the results of a optical flow method to display vectors in a 3D volume.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field | Union[ArrayLike, list[ArrayLike]] | Result from scikit-image or cucim ILK or TLV1 methods, or from DEEDS. | required |
mask | ArrayLike | Boolean mask to select areas where the flow field needs to be computed. | None |
Returns:
Name | Type | Description |
---|---|---|
flow_field | ArrayLike | A (im_size x 2 x ndim) array indicating origin and final position of voxels. |
Source code in src/merfish3danalysis/utils/registration.py
warp_coordinates(coordinates, tile_translation_transform, voxel_size_zyx_um, displacement_field_transform=None)
First apply a translation transform to the coordinates, then warp them using a given displacement field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coordinates | ArrayLike | List of tuples representing the coordinates. MUST be in xyz order! | required |
voxel_size_zyx_um | ArrayLike | physical pixel spacing | required |
displacement_field_transform | Optional[Transform] | simpleITK displacement field transform | None |
Returns:
Name | Type | Description |
---|---|---|
transformed_coordinates | ArrayLike | List of tuples representing warped coordinates Returned in xyz order! |