scil_tractogram_apply_transform.py

usage: __main__.py [-h] [--inverse] [--in_deformation file]
                   [--reverse_operation]
                   [--cut_invalid | --remove_invalid | --keep_invalid]
                   [--no_empty] [--reference REFERENCE]
                   [-v [{DEBUG,INFO,WARNING}]] [-f]
                   in_moving_tractogram in_target_file in_transfo
                   out_tractogram

Transform a tractogram using an affine/rigid transformation and nonlinear
deformation (optional).

For more information on how to use the registration script, follow this link:
https://scilpy.readthedocs.io/en/latest/documentation/tractogram_registration.html

Applying transformation to a tractogram can lead to invalid streamlines (out of
the bounding box), and thus three strategies are available:
1) Do nothing, may crash at saving if invalid streamlines are present.
   [This is the default]
2) --keep_invalid, save invalid streamlines. Leave it to the user to run
    scil_tractogram_remove_invalid.py if needed.
3) --remove_invalid, automatically remove invalid streamlines before saving.
    Should not remove more than a few streamlines. Typically, the streamlines
    that are rejected are the ones reaching the limits of the brain, ex, near
    the pons.
4) --cut_invalid, automatically cut invalid streamlines before saving, i.e. the
   streamlines are kept but the points out of the bounding box are cut.

Example:
To apply a transformation from ANTs to a tractogram, if the ANTs command was
MOVING->REFERENCE...
1) To apply the original transformation:
scil_tractogram_apply_transform.py ${MOVING_FILE} ${REFERENCE_FILE}
                                   0GenericAffine.mat ${OUTPUT_NAME}
                                   --inverse
                                   --in_deformation 1InverseWarp.nii.gz

2) To apply the inverse transformation, i.e. REFERENCE->MOVING:
scil_tractogram_apply_transform.py ${MOVING_FILE} ${REFERENCE_FILE}
                                   0GenericAffine.mat ${OUTPUT_NAME}
                                   --in_deformation 1Warp.nii.gz
                                   --reverse_operation

Formerly: scil_apply_transform_to_tractogram.py

positional arguments:
  in_moving_tractogram  Path of the tractogram to be transformed.
                        Bounding box validity will not be checked (could
                        contain invalid streamlines).
  in_target_file        Path of the reference target file (trk or nii).
  in_transfo            Path of the file containing the 4x4
                        transformation, matrix (.txt, .npy or .mat).
  out_tractogram        Output tractogram filename (transformed data).

options:
  -h, --help            show this help message and exit
  --no_empty            Do not write file if there is no streamline.
                        You may save an empty file if you use remove_invalid.
  --reference REFERENCE
                        Reference anatomy for tck/vtk/fib/dpy file
                        support (.nii or .nii.gz).
  -v [{DEBUG,INFO,WARNING}]
                        Produces verbose output depending on the provided level.
                        Default level is warning, default when using -v is info.
  -f                    Force overwriting of the output files.

Transformation options:
  --inverse             Apply the inverse linear transformation.
  --in_deformation file
                        Path to the file containing a deformation field.
  --reverse_operation   Apply the transformation in reverse (see doc), warp
                        first, then linear.

Management of invalid streamlines:
  --cut_invalid         Cut invalid streamlines rather than removing them.
                        Keep the longest segment only.
  --remove_invalid      Remove the streamlines landing out of the bounding box.
  --keep_invalid        Keep the streamlines landing out of the bounding box.