Scripting in Python
TARDIS-em library can be use to simply and fast script your own workflows.
More examples can be find in: tardis_em/examples/TARDIS_em_Script.ipynb
Example
from tardis_em.utils.predictor import GeneralPredictor
predictor = GeneralPredictor(
predict: str,
dir_s: Union[str, tuple[np.ndarray], np.ndarray],
binary_mask: bool,
output_format: str,
patch_size: int,
convolution_nn: str,
cnn_threshold: float,
dist_threshold: float,
points_in_patch: int,
predict_with_rotation: bool,
instances: bool,
device_s: str,
debug: bool,
checkpoint: Optional[list] = None,
correct_px: float = None,
amira_prefix: str = None,
filter_by_length: int = None,
connect_splines: int = None,
connect_cylinder: int = None,
amira_compare_distance: int = None,
amira_inter_probability: float = None,
tardis_logo: bool = True,
)
semantic, instance, instance_filter = predictor()
predict
: File directory to visualize.Allowed options: Microtubule, Membrane2D, Membrane
-dir_s
: Directory to a single file, folder with files or numpy array with tomogram/micrograph.Allowed options: str, np.ndarray
-binary_mask
: If True, Predictor assume, that input images are binary mask. The semantic segmentation step would be skipped and only instance segmentation results will be produce.Allowed options: bool
-output_format
: Two output format for semantic and instance prediction.Tips: Define as semantic_instance format. For example to output semantic segmentation mask as .mrc file format, and instance segmentation as .csv file. Type mrc_csv
Allowed options Semantics: None, am, mrc, tif, npy
Allowed options Instances: None, am, mrc, tif, npy, amSG, csv, stl
-patch_size
: Image crop size used during semantic segmentation.Allowed options: int
-convolution_nn
: Type of pre-train CNN model.Allowed options: unet, fnet_attn
-cnn_threshold
: Threshold for CNN model. Used during semantic segmentation.Allowed options: float
-dist_threshold
: Threshold for DIST model. Used during instance segmentation.Allowed options: float
-points_in_patch
: Maximum number of points per patched point cloud.Tip: About 1000 points require ~ 12Gb of GPU or RAM (if device == ‘cpu’)
Allowed options: int
-predict_with_rotation
: If True, CNN predict with 4 90* rotations.Allowed options: bool
-instances`
: If True, run instance segmentation after semantic.Allowed options: bool
-device_s
: Device on which prediction will take place.Allowed options: cpu, gpu or number between 0-9 indicating gpu id
-debug
: If True, enable debugging mode which save all intermediate files.Allowed options: bool
-checkpoint
: List of model checkpoints for semantic and instance segmentation. If its None, TARDIS retrieves weights from AWS.Default: None
Allowed options: list[str], list[dict]
-correct_px
: Indicate correct pixel size for image data. If its None, TARDIS retrieves pixels size from the file header.Default: None
Allowed options: float, None
-amira_prefix`
: Optional, Amira file prefix name used for spatial graph comparison.Default: None
Allowed options: str, None
-filter_by_length
: Optional, filter setting for filtering short splines. Value given in Angstrom.Default: None
Allowed options: int, None
-connect_splines
: Optional, filter setting for connecting near splines. Value given in Angstrom.Default: None
Allowed options: int, None
-connect_cylinder
: Optional, filter setting for connecting splines withing cylinder radius. Value given in Angstrom.Default: None
Allowed options: int, None
-amira_compare_distance
: Optional, compare setting, max distance between two splines to consider them as the same. Value given in Angstrom.Default: None
Allowed options: int, None
-amira_inter_probability
: Optional, compare setting, portability threshold to define comparison class. Value given between 0-1 as a probability.Default: None
Allowed options: float, None
-tardis_logo
: If True, GeneralPredictor will display terminal or command-line logs.Default: True
Allowed options: bool