scil_tractogram_fix_trk.py

usage: __main__.py [-h] [--software string] [--cut_invalid | --remove_invalid]
                   [--in_dsi_fa IN_DSI_FA] [--in_native_fa IN_NATIVE_FA]
                   [--auto_crop] [--save_transfo FILE | --load_transfo FILE]
                   [--reference REFERENCE] [--no_bbox_check]
                   [-v [{DEBUG,INFO,WARNING}]] [-f]
                   in_tractogram out_tractogram

This script is made to fix DSI-Studio or Startrack TRK file
(unknown space/convention) to make it compatible with TrackVis,
MI-Brain, Dipy Horizon (Stateful Tractogram).

DSI-Studio
==========

The script either make it match with an anatomy from DSI-Studio (AC-PC aligned,
sometimes flipped) or if --in_native_fa is provided it moves it back to native
DWI space (this involved registration).

Since DSI-Studio sometimes leaves some skull around the brain, the --auto_crop
aims to stabilize registration. If this option fails, manually BET both FA.
Registration is more robust at resolution above 2mm (iso), be careful.

If you are fixing bundles, use this script once with --save_transfo and verify
results. Once satisfied, call the scripts on bundles using a bash for loop with
--load_transfo to save computation.

We recommand the --cut_invalid to remove invalid points of streamlines rather
removing entire streamlines.

This script was tested on various datasets and worked on all of them. However,
always verify the results and if a specific case does not work. Open an issue
on the Scilpy GitHub repository.

Startrack
==========

The script will create a new stateful tractogram using the reference in
order to fix the missing information in the header of the trk.

WARNING: This script is still experimental, DSI-Studio and Startrack
evolve quickly and results may vary depending on the data itself
as well as DSI-studio/Startrack version.

Formerly: scil_fix_dsi_studio_trk.py

positional arguments:
  in_tractogram         Path of the input tractogram file from DSI studio (.trk).
  out_tractogram        Path of the output tractogram file.

options:
  -h, --help            show this help message and exit
  --software string     Software used to create in_tractogram.
                        Choices: ['dsi_studio', 'startrack']
  --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.
  --no_bbox_check       Activate to ignore validity of the bounding box during loading / saving of
                        tractograms (ignores the presence of invalid streamlines).
  -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.

DSI options:
  --in_dsi_fa IN_DSI_FA
                        Path of the input FA from DSI Studio (.nii.gz).
  --in_native_fa IN_NATIVE_FA
                        Path of the input FA from Dipy/MRtrix (.nii.gz).
                        Move the tractogram back to a "proper" space, include registration.
  --auto_crop           If both FA are not already BET, perform registration
                        using a centered-cube crop to ignore the skull.
                        A good BET for both is more robust.
  --save_transfo FILE   Save estimated transformation to avoid recomputing (.txt).
  --load_transfo FILE   Load estimated transformation to apply to other files (.txt).

StarTrack options:
  --reference REFERENCE
                        Reference anatomy (.nii or .nii.gz).