scil_tractogram_filter_by_roi.py

usage: __main__.py [-h] [--drawn_roi DRAWN_ROI [DRAWN_ROI ...]]
                   [--atlas_roi ATLAS_ROI [ATLAS_ROI ...]]
                   [--bdo BDO [BDO ...]] [--x_plane X_PLANE [X_PLANE ...]]
                   [--y_plane Y_PLANE [Y_PLANE ...]]
                   [--z_plane Z_PLANE [Z_PLANE ...]]
                   [--filtering_list FILTERING_LIST]
                   [--overwrite_distance OVERWRITE_DISTANCE [OVERWRITE_DISTANCE ...]]
                   [--extract_masks_atlas_roi] [--no_empty] [--display_counts]
                   [--save_rejected FILENAME] [--indent INDENT] [--sort_keys]
                   [--reference REFERENCE] [-v [{DEBUG,INFO,WARNING}]] [-f]
                   in_tractogram out_tractogram

Now supports sequential filtering condition and mixed filtering object.
For example, --atlas_roi ROI_NAME ID MODE CRITERIA DISTANCE
- ROI_NAME is the filename of a Nifti
- ID is one or multiple integer values in the atlas. If multiple values,
    ID needs to be between quotes.
    Example: "1:6 9 10:15" will use values between 1 and 6 and values
                           between 10 and 15 included as well as value 9.
- MODE must be one of these values: ['any', 'all', 'either_end', 'both_ends']
- CRITERIA must be one of these values: ['include', 'exclude']
- DISTANCE must be a int and is optional

If any meant any part of the streamline must be in the mask, all means that
all part of the streamline must be in the mask.

When used with exclude, it means that a streamline entirely in the mask will
be excluded. Using all it with x/y/z plane works but makes very little sense.

In terms of nifti mask, --drawn_roi MASK.nii.gz all include is
equivalent to --drawn_roi INVERSE_MASK.nii.gz any exclude
For example, this allows to find out all streamlines entirely in the WM in
one command (without manually inverting the mask first) or
to remove any streamlines staying in GM without getting out.

Multiple filtering tuples can be used and options mixed.
A logical AND is the only behavior available. All theses filtering
conditions will be sequentially applied.

WARNING: DISTANCE is optional and it should be used carefully with large
voxel size (e.g > 2.5mm). The value is in voxel for ROIs and in mm for
bounding box. Anisotropic data will affect each direction differently

Formerly: scil_filter_tractogram.py

positional arguments:
  in_tractogram         Path of the input tractogram file.
  out_tractogram        Path of the output tractogram file.

options:
  -h, --help            show this help message and exit
  --drawn_roi DRAWN_ROI [DRAWN_ROI ...]
                        ROI_NAME MODE CRITERIA DISTANCE (distance in voxel is optional)
                        Filename of a hand drawn ROI (.nii or .nii.gz).
  --atlas_roi ATLAS_ROI [ATLAS_ROI ...]
                        ROI_NAME ID MODE CRITERIA DISTANCE (distance in voxel is optional)
                        Filename of an atlas (.nii or .nii.gz).
  --bdo BDO [BDO ...]   BDO_NAME MODE CRITERIA DISTANCE (distance in mm is optional)
                        Filename of a bounding box (bdo) file from MI-Brain.
  --x_plane X_PLANE [X_PLANE ...]
                        PLANE MODE CRITERIA DISTANCE (distance in voxel is optional)
                        Slice number in X, in voxel space.
  --y_plane Y_PLANE [Y_PLANE ...]
                        PLANE MODE CRITERIA DISTANCE (distance in voxel is optional)
                        Slice number in Y, in voxel space.
  --z_plane Z_PLANE [Z_PLANE ...]
                        PLANE MODE CRITERIA DISTANCE (distance in voxel is optional)
                        Slice number in Z, in voxel space.
  --filtering_list FILTERING_LIST
                        Text file containing one rule per line
                        (i.e. drawn_roi mask.nii.gz both_ends include 1).
  --overwrite_distance OVERWRITE_DISTANCE [OVERWRITE_DISTANCE ...]
                        MODE CRITERIA DISTANCE (distance in voxel for ROIs and in mm for bounding box).
                        If set, it will overwrite the distance associated to a specific mode/criteria.
  --extract_masks_atlas_roi
                        Extract atlas roi masks.
  --no_empty            Do not write file if there is no streamline.
  --display_counts      Print streamline count before and after filtering
  --save_rejected FILENAME
                        Save rejected streamlines to output tractogram.
  --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.

Json options:
  --indent INDENT       Indent for json pretty print.
  --sort_keys           Sort keys in output json.