Skip to content

Register

To register real X-ray images with iterative pose refinement with differentiable rendering, use xvr register:

  • By passing a --labelpath and a space-separated set of --labels, registration will be performed with respect to specific structures.
  • If the model was trained with a coordinate frame different to that of the --imagepath, you can pass a --warp to rigidly realign the model's predictions to the new patient.

xvr register

$ xvr register --help
Usage: xvr register COMMAND

Use gradient-based optimization to register XRAY to a CT/MR.

Commands:
dicom    Register using an initial pose parsed from DICOM metadata.
fixed    Register using a fixed initial pose.
model    Register using a neural network initial pose estimate.
restart  Register by restarting optimization from a previous run's final pose.

xvr register dicom

$ xvr register dicom --help
Usage: xvr register dicom --files LIST[PATH] --imagepath STR [OPTIONS]

Register using an initial pose parsed from DICOM metadata.

Parameters:
* --files PATH...                X-ray images to register [required]

POSE:
  --orientation TEXT             Patient orientation for the DRR [choices: AP, PA]
                                 [default: AP]
  --reverse-x-axis               Horizontally flip the rendered DRRs [default: 
    --no-reverse-x-axis          False]

Data:
* --imagepath TEXT               Path to the CT image [required]
  --labelpath TEXT               Path to the segmentation label map. If None, uses
                                 the full image
  --labels INTEGER...            Label indices to include in the DRR. If None, uses
                                 all labels

Optimizer:
  --metric TEXT                  Image similarity metric [choices: mncc, gncc, 
                                 gmncc] [default: gmncc]
  --scales FLOAT...              Downsampling scale(s) for multiscale registration
                                 [default: [8.0]]
  --n-itrs INTEGER...            Number of optimization iterations per scale
                                 [default: [500]]
  --lr-rot FLOAT                 Learning rate for rotation parameters [default: 
                                 0.01]
  --lr-xyz FLOAT                 Learning rate for translation parameters [default: 
                                 1.0]
  --lr-reduce-factor FLOAT       Factor by which to reduce the learning rate on
                                 plateau [default: 0.1]
  --patience INTEGER...          Number of steps with no improvement before reducing
                                 the learning rate (one per scale) [default: [5]]
  --threshold FLOAT              Minimum change to qualify as an improvement
                                 [default: 0.0001]
  --max-n-plateaus INTEGER       Number of learning rate reductions before early
                                 stopping [default: 2]
  --parameterization TEXT        Parameterization of SO(3) for pose optimization
                                 [default: euler_angles]
  --convention TEXT              If parameterization='euler_angles', specify order
                                 [default: ZXY]
  --init-only --no-init-only     Return initial pose estimate result [default: 
                                 False]

Preprocessing:
  --crop INTEGER                 Number of pixels to crop from the image border
                                 [default: 0]
  --linearize --no-linearize     Convert image to linear attenuation values
                                 [default: True]
  --subtract-background          Subtract background from the image [default: False]
    --no-subtract-background     
  --equalize --no-equalize       Apply histogram equalization during optimization
                                 [default: False]
  --reducefn TEXT                Reduction function for multi-frame images [choices:
                                 max, sum] [default: max]

Miscellaneous:
  --device TEXT                  Torch device to run on [default: cuda]
  --savepath TEXT                Location to save the registration results
  --saveplot --no-saveplot       Save plots of registration results [default: False]

xvr register fixed

$ xvr register fixed --help
Usage: xvr register fixed --files LIST[PATH] --imagepath STR [OPTIONS] ROT XYZ

Register using a fixed initial pose.

Parameters:
* --files PATH...                X-ray images to register [required]

POSE:
* ROT --rot <FLOAT FLOAT         Rotations in degrees [required]
  FLOAT>...                      
* XYZ --xyz <FLOAT FLOAT         Translations in mm [required]
  FLOAT>...                      
  --orientation TEXT             Patient orientation for the DRR [choices: AP, PA]
                                 [default: AP]
  --reverse-x-axis               Horizontally flip the rendered DRRs [default: 
    --no-reverse-x-axis          False]

Data:
* --imagepath TEXT               Path to the CT image [required]
  --labelpath TEXT               Path to the segmentation label map. If None, uses
                                 the full image
  --labels INTEGER...            Label indices to include in the DRR. If None, uses
                                 all labels

Optimizer:
  --metric TEXT                  Image similarity metric [choices: mncc, gncc, 
                                 gmncc] [default: gmncc]
  --scales FLOAT...              Downsampling scale(s) for multiscale registration
                                 [default: [8.0]]
  --n-itrs INTEGER...            Number of optimization iterations per scale
                                 [default: [500]]
  --lr-rot FLOAT                 Learning rate for rotation parameters [default: 
                                 0.01]
  --lr-xyz FLOAT                 Learning rate for translation parameters [default: 
                                 1.0]
  --lr-reduce-factor FLOAT       Factor by which to reduce the learning rate on
                                 plateau [default: 0.1]
  --patience INTEGER...          Number of steps with no improvement before reducing
                                 the learning rate (one per scale) [default: [5]]
  --threshold FLOAT              Minimum change to qualify as an improvement
                                 [default: 0.0001]
  --max-n-plateaus INTEGER       Number of learning rate reductions before early
                                 stopping [default: 2]
  --parameterization TEXT        Parameterization of SO(3) for pose optimization
                                 [default: euler_angles]
  --convention TEXT              If parameterization='euler_angles', specify order
                                 [default: ZXY]
  --init-only --no-init-only     Return initial pose estimate result [default: 
                                 False]

Preprocessing:
  --crop INTEGER                 Number of pixels to crop from the image border
                                 [default: 0]
  --linearize --no-linearize     Convert image to linear attenuation values
                                 [default: True]
  --subtract-background          Subtract background from the image [default: False]
    --no-subtract-background     
  --equalize --no-equalize       Apply histogram equalization during optimization
                                 [default: False]
  --reducefn TEXT                Reduction function for multi-frame images [choices:
                                 max, sum] [default: max]

Miscellaneous:
  --device TEXT                  Torch device to run on [default: cuda]
  --savepath TEXT                Location to save the registration results
  --saveplot --no-saveplot       Save plots of registration results [default: False]

xvr register model

$ xvr register model --help
Usage: xvr register model --files LIST[PATH] --imagepath STR [OPTIONS] CKPT

Register using a neural network initial pose estimate.

Parameters:
* --files PATH...                X-ray images to register [required]

MODEL:
* CKPT --ckpt TEXT               Path to model checkpoint [required]
  --warp TEXT                    SimpleITK transform reframing a model's predicted
                                 pose
  --antipodal --no-antipodal     Initialize from the antipode of the predicted pose
                                 [default: False]

Data:
* --imagepath TEXT               Path to the CT image [required]
  --labelpath TEXT               Path to the segmentation label map. If None, uses
                                 the full image
  --labels INTEGER...            Label indices to include in the DRR. If None, uses
                                 all labels

Optimizer:
  --metric TEXT                  Image similarity metric [choices: mncc, gncc, 
                                 gmncc] [default: gmncc]
  --scales FLOAT...              Downsampling scale(s) for multiscale registration
                                 [default: [8.0]]
  --n-itrs INTEGER...            Number of optimization iterations per scale
                                 [default: [500]]
  --lr-rot FLOAT                 Learning rate for rotation parameters [default: 
                                 0.01]
  --lr-xyz FLOAT                 Learning rate for translation parameters [default: 
                                 1.0]
  --lr-reduce-factor FLOAT       Factor by which to reduce the learning rate on
                                 plateau [default: 0.1]
  --patience INTEGER...          Number of steps with no improvement before reducing
                                 the learning rate (one per scale) [default: [5]]
  --threshold FLOAT              Minimum change to qualify as an improvement
                                 [default: 0.0001]
  --max-n-plateaus INTEGER       Number of learning rate reductions before early
                                 stopping [default: 2]
  --parameterization TEXT        Parameterization of SO(3) for pose optimization
                                 [default: euler_angles]
  --convention TEXT              If parameterization='euler_angles', specify order
                                 [default: ZXY]
  --init-only --no-init-only     Return initial pose estimate result [default: 
                                 False]

Preprocessing:
  --crop INTEGER                 Number of pixels to crop from the image border
                                 [default: 0]
  --linearize --no-linearize     Convert image to linear attenuation values
                                 [default: True]
  --subtract-background          Subtract background from the image [default: False]
    --no-subtract-background     
  --equalize --no-equalize       Apply histogram equalization during optimization
                                 [default: False]
  --reducefn TEXT                Reduction function for multi-frame images [choices:
                                 max, sum] [default: max]

Miscellaneous:
  --device TEXT                  Torch device to run on [default: cuda]
  --savepath TEXT                Location to save the registration results
  --saveplot --no-saveplot       Save plots of registration results [default: False]

xvr register restart

$ xvr register restart --help
Usage: xvr register restart --files LIST[PATH] --imagepath STR [OPTIONS] CKPT

Register by restarting optimization from a previous run's final pose.

Parameters:
* --files PATH...                X-ray images to register [required]

POSE:
* CKPT --ckpt TEXT               Path to a previous run's saved .pth result
                                 [required]
  --orientation TEXT             Patient orientation for the DRR [choices: AP, PA]
                                 [default: AP]

Data:
* --imagepath TEXT               Path to the CT image [required]
  --labelpath TEXT               Path to the segmentation label map. If None, uses
                                 the full image
  --labels INTEGER...            Label indices to include in the DRR. If None, uses
                                 all labels

Optimizer:
  --metric TEXT                  Image similarity metric [choices: mncc, gncc, 
                                 gmncc] [default: gmncc]
  --scales FLOAT...              Downsampling scale(s) for multiscale registration
                                 [default: [8.0]]
  --n-itrs INTEGER...            Number of optimization iterations per scale
                                 [default: [500]]
  --lr-rot FLOAT                 Learning rate for rotation parameters [default: 
                                 0.01]
  --lr-xyz FLOAT                 Learning rate for translation parameters [default: 
                                 1.0]
  --lr-reduce-factor FLOAT       Factor by which to reduce the learning rate on
                                 plateau [default: 0.1]
  --patience INTEGER...          Number of steps with no improvement before reducing
                                 the learning rate (one per scale) [default: [5]]
  --threshold FLOAT              Minimum change to qualify as an improvement
                                 [default: 0.0001]
  --max-n-plateaus INTEGER       Number of learning rate reductions before early
                                 stopping [default: 2]
  --parameterization TEXT        Parameterization of SO(3) for pose optimization
                                 [default: euler_angles]
  --convention TEXT              If parameterization='euler_angles', specify order
                                 [default: ZXY]
  --init-only --no-init-only     Return initial pose estimate result [default: 
                                 False]

Preprocessing:
  --crop INTEGER                 Number of pixels to crop from the image border
                                 [default: 0]
  --linearize --no-linearize     Convert image to linear attenuation values
                                 [default: True]
  --subtract-background          Subtract background from the image [default: False]
    --no-subtract-background     
  --equalize --no-equalize       Apply histogram equalization during optimization
                                 [default: False]
  --reducefn TEXT                Reduction function for multi-frame images [choices:
                                 max, sum] [default: max]

Miscellaneous:
  --device TEXT                  Torch device to run on [default: cuda]
  --savepath TEXT                Location to save the registration results
  --saveplot --no-saveplot       Save plots of registration results [default: False]