apply_registration_to_image
Applies pre-calculated registration to images.
_get_ref_path_heuristic(path_list, path)
¶
Pick the best-matching reference path from path_list for a given path.
Matches by the suffix (everything after the first _ in the path name).
If no suffix match is found, falls back to the first sorted entry and logs
a warning. Used when a well contains multiple images of the same
acquisition (e.g. ['0', '0_illum_corr']) and we need to find the
reference counterpart of a given image (e.g. '1_illum_corr').
| PARAMETER | DESCRIPTION |
|---|---|
path_list |
Candidate reference image paths in the well. |
path |
Current image path whose reference counterpart is sought.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The best-matching path from |
Source code in fractal_tasks_core/apply_registration_to_image.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
_write_registered_ngio_image(source_ome_zarr, new_zarr_url, roi_pairs)
¶
Write a registered OME-Zarr image to disk using pre-computed ROI pairs.
Creates a new image container derived from the source (same shape, dtype, and metadata, initialised to zeros), writes image data from each acquisition ROI into the corresponding reference ROI position, then builds the pyramid using linear interpolation.
| PARAMETER | DESCRIPTION |
|---|---|
source_ome_zarr |
Source image container (current acquisition).
TYPE:
|
new_zarr_url |
Path where the new registered image will be written.
TYPE:
|
roi_pairs |
List of (acq_roi, ref_roi) tuples. For each pair the data
is read from |
| RETURNS | DESCRIPTION |
|---|---|
OmeZarrContainer
|
The newly created OmeZarrContainer. |
Source code in fractal_tasks_core/apply_registration_to_image.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
_write_registered_ngio_label(acq_ome_zarr, new_ome_zarr, label_name, roi_pairs)
¶
Write a registered label image into an existing new OME-Zarr container.
Derives an empty label from the source container, writes label data from each acquisition ROI into the reference ROI position, then builds the pyramid using nearest-neighbour interpolation (appropriate for integer segmentation masks).
| PARAMETER | DESCRIPTION |
|---|---|
acq_ome_zarr |
Source image container (current acquisition).
TYPE:
|
new_ome_zarr |
Target container where the registered label is written.
TYPE:
|
label_name |
Name of the label to process.
TYPE:
|
roi_pairs |
List of (acq_roi, ref_roi) tuples (same as for the image). |
Source code in fractal_tasks_core/apply_registration_to_image.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
apply_registration_to_image(*, zarr_url, registered_roi_table, reference_acquisition=0, register_labels=True, overwrite_input=True)
¶
Apply registration to images by using a registered ROI table.
Crops and shifts each acquisition so that all acquisitions are aligned to the reference acquisition. Only the region visible in all acquisitions is retained. This task consists of 4 steps:
- Write a new image aligned to the reference acquisition for each ROI.
- Apply the same registration to all label images (if requested).
- Copy tables from the original image to the registered image.
- Replace the original image with the registered image.
| PARAMETER | DESCRIPTION |
|---|---|
zarr_url |
Path or url to the individual OME-Zarr image to be processed. (standard argument for Fractal tasks, managed by Fractal server).
TYPE:
|
registered_roi_table |
Name of the ROI table which has been registered
and will be applied to mask and shift the images.
Examples:
TYPE:
|
reference_acquisition |
Which acquisition to register against. Uses the OME-NGFF HCS well metadata acquisition keys to find the reference acquisition.
TYPE:
|
register_labels |
Whether to also apply the registration to the label images. If True, all label images will be registered in the same way as the main image. If False, only the main image is registered.
TYPE:
|
overwrite_input |
Whether the old image data should be replaced with the
newly registered image data. If False, a new image is created with
TYPE:
|
Source code in fractal_tasks_core/apply_registration_to_image.py
107 108 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 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |