voxelmorph.py.generators
Data generators for medical image registration.
conditional_template_creation
conditional_template_creation(vol_names, atlas, attributes, batch_size=1, np_var='vol', pad_shape=None, add_feat_axis=True)
Generator for conditional template creation.
Parameters: vol_names: List of volume files to load, or list of preloaded volumes. atlas: Atlas input volume data. attributes: Dictionary of phenotype data for each vol name. batch_size: Batch size. Default is 1. np_var: Name of the volume variable if loading npz files. Default is 'vol'. pad_shape: Zero-pads loaded volumes to a given shape. Default is None. add_feat_axis: Load volume arrays with added feature axis. Default is True.
Source code in voxelmorph/py/generators.py
scan_to_atlas
Generator for scan-to-atlas registration.
TODO: This could be merged into scan_to_scan() by adding an optional atlas argument like in semisupervised().
Parameters: vol_names: List of volume files to load, or list of preloaded volumes. atlas: Atlas volume data. bidir: Yield input image as output for bidirectional models. Default is False. batch_size: Batch size. Default is 1. no_warp: Excludes null warp in output list if set to True (for affine training). Default is False. segs: Load segmentations as output, for supervised training. Forwarded to the internal volgen generator. Default is None. kwargs: Forwarded to the internal volgen generator.
Source code in voxelmorph/py/generators.py
scan_to_scan
Generator for scan-to-scan registration.
Parameters: vol_names: List of volume files to load, or list of preloaded volumes. bidir: Yield input image as output for bidirectional models. Default is False. batch_size: Batch size. Default is 1. prob_same: Induced probability that source and target inputs are the same. Default is 0. no_warp: Excludes null warp in output list if set to True (for affine training). Default if False. kwargs: Forwarded to the internal volgen generator.
Source code in voxelmorph/py/generators.py
semisupervised
Generator for semi-supervised registration training using ground truth segmentations. Scan-to-atlas training can be enabled by providing the atlas_file argument.
Parameters: vol_names: List of volume files to load, or list of preloaded volumes. seg_names: List of corresponding seg files to load, or list of preloaded volumes. labels: Array of discrete label values to use in training. atlas_file: Atlas npz file for scan-to-atlas training. Default is None. downsize: Downsize factor for segmentations. Default is 2.
Source code in voxelmorph/py/generators.py
surf_semisupervised
surf_semisupervised(vol_names, atlas_vol, atlas_seg, nb_surface_pts, labels=None, batch_size=1, surf_bidir=True, surface_pts_upsample_factor=2, smooth_seg_std=1, nb_labels_sample=None, sdt_vol_resize=1, align_segs=False, add_feat_axis=True)
Scan-to-atlas generator for semi-supervised learning using surface point clouds from segmentations.
Parameters: vol_names: List of volume files to load. atlas_vol: Atlas volume array. atlas_seg: Atlas segmentation array. nb_surface_pts: Total number surface points for all structures. labels: Label list to include. If None, all labels in atlas_seg are used. Default is None. batch_size: Batch size. NOTE some features only implemented for 1. Default is 1. surf_bidir: Train with bidirectional surface distance. Default is True. surface_pts_upsample_factor: Upsample factor for surface pointcloud. Default is 2. smooth_seg_std: Segmentation smoothness sigma. Default is 1. nb_labels_sample: Number of labels to sample. Default is None. sdt_vol_resize: Resize factor for signed distance transform volumes. Default is 1. align_segs: Whether to pass in segmentation image instead. Default is False. add_feat_axis: Load volume arrays with added feature axis. Default is True.
Source code in voxelmorph/py/generators.py
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 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | |
synthmorph
Generator for SynthMorph registration.
Parameters: labels_maps: List of preloaded ND label maps without batch or feature dimension. batch_size: Batch size. same_subj: Return the same label map both as source and target. flip: Randomly flip the same axes of the source and target label maps.
Yields: Source and target label maps as a tuple and "true" dummy value that SynthMorph training will ignore, as it is unsupervised.
Source code in voxelmorph/py/generators.py
template_creation
Generator for unconditional template creation.
Parameters: vol_names: List of volume files to load, or list of preloaded volumes. bidir: Yield input image as output for bidirectional models. Default is False. batch_size: Batch size. Default is 1. kwargs: Forwarded to the internal volgen generator.
Source code in voxelmorph/py/generators.py
volgen
volgen(vol_names, batch_size=1, segs=None, np_var='vol', pad_shape=None, resize_factor=1, add_feat_axis=True)
Base generator for random volume loading. Volumes can be passed as a path to
the parent directory, a glob pattern, a list of file paths, or a list of
preloaded volumes. Corresponding segmentations are additionally loaded if
segs is provided as a list (of file paths or preloaded segmentations) or set
to True. If segs is True, npz files with variable names 'vol' and 'seg' are
expected. Passing in preloaded volumes (with optional preloaded segmentations)
allows volumes preloaded in memory to be passed to a generator.
Parameters: vol_names: Path, glob pattern, list of volume files to load, or list of preloaded volumes. batch_size: Batch size. Default is 1. segs: Loads corresponding segmentations. Default is None. np_var: Name of the volume variable if loading npz files. Default is 'vol'. pad_shape: Zero-pads loaded volumes to a given shape. Default is None. resize_factor: Volume resize factor. Default is 1. add_feat_axis: Load volume arrays with added feature axis. Default is True.