Registration
register(msims, transform_key=None, reg_channel_index=None, reg_channel=None, new_transform_key=None, registration_binning=None, reg_res_level=None, overlap_tolerance=0.0, pairwise_reg_func=phase_correlation_registration, pairwise_reg_func_kwargs=None, groupwise_resolution_method='global_optimization', groupwise_resolution_kwargs=None, pre_registration_pruning_method='alternating_pattern', pre_reg_pruning_method_kwargs=None, post_registration_do_quality_filter=False, post_registration_quality_threshold=0.2, plot_summary=False, pairs=None, scheduler=None, n_parallel_pairwise_regs=None, return_dict=False)
Register a list of views to a common extrinsic coordinate system.
High-level flow: 1) Build the overlap graph. 2) Run pairwise registrations for selected edges. 3) Resolve global transforms from the pairwise results.
Parameters
msims : list of MultiscaleSpatialImage
Input views
reg_channel_index : int, optional
Index of channel to be used for registration, by default None
reg_channel : str, optional
Name of channel to be used for registration, by default None
Overrides reg_channel_index
transform_key : str, optional
Extrinsic coordinate system to use as a starting point
for the registration, by default None
new_transform_key : str, optional
If set, the registration result will be registered as a new extrinsic
coordinate system in the input views (with the given name), by default None
registration_binning : dict, optional
Binning applied to each dimension during registration, by default None.
If reg_res_level is also provided, the binning factors must be compatible
with the resolution level.
reg_res_level : int, optional
Resolution level to use for registration (e.g., 0 for scale0, 1 for scale1).
If None and registration_binning is provided, the optimal resolution level
is automatically determined. By default None.
overlap_tolerance : float or dict, optional
Extend overlap regions considered for pairwise registration.
- if 0, the overlap region is the intersection of the bounding boxes.
- if > 0, the overlap region is the intersection of the bounding boxes
extended by this value in all spatial dimensions.
- if None, the full images are used for registration
pairwise_reg_func : Callable, optional
Function used for registration. See the docs for the function API.
By default, phase_correlation_registration is used. Another useful built-in
registration function is pairwise_reg_func=registration.registration_ANTsPy
for translation, rigid, similarity or affine registration using ANTsPy.
pairwise_reg_func_kwargs : dict, optional
Additional keyword arguments passed to the registration function.
In the case of pairwise_reg_func=registration_ANTsPy, this can include e.g:
- 'transform_type': ['Translation', 'Rigid' 'Affine'] or ['Similarity']
For further parameters, see the docstring of the registration function.
groupwise_resolution_method : str, optional
Method used to resolve global transforms from pairwise registrations:
- 'global_optimization' (transform: translation|rigid|similarity|affine)
- 'shortest_paths' (uses the transform type defined by the pairwise registrations)
- 'linear_two_pass' (transform: translation|rigid)
Custom component-level methods can be registered via
param_resolution.register_groupwise_resolution_method(...) and
referenced by name.
groupwise_resolution_kwargs : dict, optional
Additional keyword arguments passed to the groupwise resolver.
Parameters are method-specific. Common options include:
- 'transform': final transform type (see method notes above)
- 'reference_view': node index to keep fixed
See the resolver docstrings for full details.
pre_registration_pruning_method : str, optional
Method used to eliminate registration edges (e.g. diagonals) from the view adjacency
graph before registration. Available methods:
- None: No pruning, useful when no regular arrangement is present.
- 'alternating_pattern': Prune to edges between squares of differering
colors in checkerboard pattern. Useful for regular 2D tile arrangements (of both 2D or 3D data).
- 'shortest_paths_overlap_weighted': Prune to shortest paths in overlap graph
(weighted by overlap). Useful to minimize the number of pairwise registrations.
- 'otsu_threshold_on_overlap': Prune to edges with overlap above Otsu threshold.
This is useful for regular 2D or 3D grid arrangements, as diagonal edges will be pruned.
- 'keep_axis_aligned': Keep only edges that align with tile axes. This is useful for regular grid
arrangements and to explicitely prune diagonals, e.g. when other methods fail.
pre_reg_pruning_method_kwargs : dict, optional
Additional keyword arguments passed to the pre-registration pruning method, e.g.
- 'keep_axis_aligned': 'max_angle' (larger angles between stack axis and pair edge are discarded, default 0.2)
post_registration_do_quality_filter : bool, optional
post_registration_quality_threshold : float, optional
Threshold used to filter edges by quality after registration,
by default None (no filtering)
plot_summary : bool, optional
If True (and new_transform_key is set), plot graphs summarising the registration process and results:
1) Cross correlation values of pairwise registrations
(stack boundaries shown as before registration)
2) Residual distances between registration edges after global parameter resolution.
Grey edges have been removed during glob param res (stack boundaries shown as after registration).
Solid edges were used by the resolver, dotted edges were unused.
Stack boundary positions reflect the registration result.
By default False
pairs : list of tuples, optional
If set, initialises the view adjacency graph using the indicates
pairs of view/tile indices, by default None
scheduler : str, optional
(Deprecated since >0.1.28) Dask scheduler to use for parallel computation, by default None
This parameter is deprecated and no longer used.
Use a context manager instead to set the dask scheduler used within register(), e.g.
with dask.config.set(scheduler='threads'): register(...)
n_parallel_pairwise_regs : int, optional
Number of parallel pairwise registrations to run. Setting this is specifically
useful for limiting memory usage.
By default None (all pairwise registrations are run in parallel)
return_dict : bool, optional
If True, return a dict containing params, registration metrics and more, by default False
Returns
list of xr.DataArray Parameters mapping each view into a new extrinsic coordinate system or dict Dictionary containing the following keys: - 'params': Parameters mapping each view into a new extrinsic coordinate system - 'pairwise_registration': Dictionary containing the following - 'summary_plot': Tuple containing the figure and axis of the summary plot - 'graph': networkx graph of pairwise registrations - 'metrics': Dictionary containing the following metrics: - 'qualities': Edge registration qualities - 'groupwise_resolution': Dictionary containing the following - 'summary_plot': Tuple containing the figure and axis of the summary plot - 'metrics': Dictionary containing the following metrics: - 'edge_residuals': Dict[int, dict[tuple, float]] mapping timepoint index to edge residuals - 'used_edges': Dict[int, list[tuple]] mapping timepoint index to edges used by the resolution method
Source code in src/multiview_stitcher/registration.py
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 | |
registration_ITKElastix(fixed_data, moving_data, *, fixed_origin, moving_origin, fixed_spacing, moving_spacing, initial_affine, transform_types=None, **elastix_registration_kwargs)
Use ITKElastix to perform registration between two spatial images.
Parameters
transform_types : list of str, optional Sequence of transform types to apply in successive stages. Supported values: 'Translation', 'Rigid', 'Similarity', 'Affine'. By default ['Translation', 'Rigid', 'Similarity']. **elastix_registration_kwargs Additional keyword arguments. The following are handled explicitly and applied to the elastix parameter map for each stage:
number_of_resolutions : int, optional
Number of resolution levels in the multi-resolution scheme,
by default 2.
number_of_iterations : int, optional
Maximum number of optimizer iterations per resolution level.
If None, the elastix default for the chosen transform type is used.
metric : str, optional
Similarity metric used by elastix. If None, the elastix default
for the chosen transform type is used. Common values:
- 'AdvancedMattesMutualInformation' (default for most transforms)
- 'AdvancedMeanSquares'
- 'AdvancedNormalizedCorrelation'
- 'NormalizedMutualInformation'
Remaining kwargs are forwarded to ``itk.elastix_registration_method``
(e.g. ``log_to_console=True``).
Source code in src/multiview_stitcher/registration.py
1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 | |