retuve.keyphrases.subconfig

All the subconfigs for Retuve

  1# Copyright 2024 Adam McArthur
  2#
  3# Licensed under the Apache License, Version 2.0 (the "License");
  4# you may not use this file except in compliance with the License.
  5# You may obtain a copy of the License at
  6#
  7#     http://www.apache.org/licenses/LICENSE-2.0
  8#
  9# Unless required by applicable law or agreed to in writing, software
 10# distributed under the License is distributed on an "AS IS" BASIS,
 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12# See the License for the specific language governing permissions and
 13# limitations under the License.
 14
 15"""
 16All the subconfigs for Retuve
 17"""
 18
 19import os
 20import sys
 21from typing import Any, Dict, List, Literal, Union
 22
 23from PIL import ImageFont
 24from pyparsing import C
 25
 26from retuve.keyphrases.enums import (
 27    ACASplit,
 28    Colors,
 29    CRFem,
 30    Curvature,
 31    GrafSelectionMethod,
 32    HipMode,
 33    MetricUS,
 34    MidLineMove,
 35    Outputs,
 36)
 37from retuve.typehints import GeneralModeFuncType
 38from retuve.utils import RETUVE_DIR
 39
 40
 41class HipConfig:
 42    def __init__(
 43        self,
 44        midline_color: Colors,
 45        aca_split: ACASplit,
 46        cr_fem_pos: CRFem,
 47        fem_extention: float,
 48        midline_move_method: MidLineMove,
 49        curvature_method: Curvature,
 50        measurements: List[MetricUS],
 51        z_gap: float,
 52        display_frame_no: bool,
 53        display_side: bool,
 54        draw_midline: bool,
 55        display_fem_guess: bool,
 56        draw_side_metainfo: bool,
 57        allow_flipping: bool,
 58        display_bad_frame_reasons: bool,
 59        graf_selection_method: GrafSelectionMethod,
 60        graf_selection_func: Any,
 61        graf_selection_func_args: Dict[str, Any],
 62        display_graf_conf: bool,
 63        graf_algo_threshold: float,
 64    ):
 65        """
 66        The Hip Subconfig.
 67
 68        :param midline_color (Colors): The color of the midline.
 69        :param aca_split (ACASplit): The ACA split method.
 70        :param cr_fem_pos (CRFem): The CR Femoral position.
 71        :param fem_extention (float): The femoral extention length.
 72        :param midline_move_method (MidLineMove): The midline move method.
 73        :param curvature_method (Curvature): The curvature method.
 74        :param measurements (list): The measurements to calculate.
 75        :param z_gap (float): The z gap.
 76        :param display_frame_no (bool): Display the frame number.
 77        :param display_side (bool): Display the side.
 78        :param draw_midline (bool): Draw the midline.
 79        :param display_fem_guess (bool): Display the femoral guess.
 80        :param draw_side_metainfo (bool): Draw the side metainfo.
 81        :param allow_flipping (bool): Allow use of the 3D US Orientaition Algorithm.
 82        :param display_bad_frame_reasons (bool): Display the bad frame reasons.
 83        :param graf_selection_method (GrafSelectionMethod): The graf selection method.
 84        :param graf_selection_func (Any): The graf selection func, if needed.
 85        :param graf_selection_func_args (dict): The arguments to pass to the graf, if needed.
 86        :param display_graf_conf (bool): Display the graf confidence.
 87        :param graf_algo_threshold (float): The graf algorithm confidence threshold.
 88        """
 89        self.midline_color = midline_color
 90        self.aca_split = aca_split
 91        self.cr_fem_pos = cr_fem_pos
 92        self.fem_extention = fem_extention
 93        self.midline_move_method = midline_move_method
 94        self.curvature_method = curvature_method
 95        self.measurements = measurements
 96        self.z_gap = z_gap
 97        self.display_frame_no = display_frame_no
 98        self.display_side = display_side
 99        self.draw_midline = draw_midline
100        self.display_fem_guess = display_fem_guess
101        self.draw_side_metainfo = draw_side_metainfo
102        self.allow_flipping = allow_flipping
103        self.display_bad_frame_reasons = display_bad_frame_reasons
104        self.graf_selection_method = graf_selection_method
105        self.graf_selection_func = graf_selection_func
106        self.graf_selection_func_args = graf_selection_func_args
107        self.display_graf_conf = display_graf_conf
108        self.graf_algo_threshold = graf_algo_threshold
109
110
111class TrakConfig:
112    def __init__(
113        self,
114        datasets: List[str],
115    ):
116        """
117        Initialize TrakConfig.
118
119        :param datasets (list): The datasets to process.
120        """
121        self.datasets = datasets
122
123
124class BatchConfig:
125    def __init__(
126        self,
127        mode_func: GeneralModeFuncType,
128        mode_func_args: Dict[str, Any],
129        hip_mode: HipMode,
130        processes: int,
131        input_types: List[Literal[".dcm", ".jpg", ".png"]],
132        datasets: List[str],
133    ):
134        """
135        Initialize BatchConfig.
136
137        :param mode_func (callable): The mode function to use.
138        :param mode_func_args (dict): The arguments to pass to the mode function.
139        :param hip_mode (str): The mode of the hip us.
140        :param processes (int): The number of processes to use.
141        :param input_types (list): The type of input to use.
142        :param datasets (list): The datasets to process.
143
144        :attr outputs (list): The outputs to generate.
145        """
146        self.mode_func = mode_func
147        self.mode_func_args = mode_func_args
148        self.hip_mode = hip_mode
149        self.processes = processes
150        self.input_types = input_types
151        self.datasets = datasets
152
153        # set properly upon registration
154        self.outputs: List[Outputs] = [Outputs.METRICS]
155
156    def register(self):
157        if self.hip_mode == HipMode.US3D:
158            self.outputs.append(Outputs.VIDEO_CLIP)
159            self.outputs.append(Outputs.VISUAL3D)
160
161        elif self.hip_mode == HipMode.US2D:
162            self.outputs.append(Outputs.IMAGE)
163
164        elif self.hip_mode == HipMode.US2DSW:
165            self.outputs.append(Outputs.IMAGE)
166            self.outputs.append(Outputs.VIDEO_CLIP)
167
168        elif self.hip_mode == HipMode.XRAY:
169            self.outputs.append(Outputs.IMAGE)
170
171
172class APIConfig:
173    def __init__(
174        self,
175        savedir: str,
176        url: str,
177        db_path: str,
178        upload_dir: str,
179        hippa_logging_file: str,
180        api_token: str,
181        origins: List[str],
182        zero_trust: bool,
183        zero_trust_interval: int,
184        orthanc_url: str,
185        orthanc_username: str,
186        orthanc_password: str,
187    ):
188        """
189        Initialize APIConfig.
190
191        :param savedir (str): The save directory of results.
192        :param url (str): The url to serve the API.
193        :param db_path (str): The db path.
194        :param upload_dir (str): The upload directory.
195        :param hippa_logging_file (str): The logging file for HIPPA related logs.
196        :param api_token (str): The api token.
197        :param origins (list): The origins to allow.
198        :param zero_trust (bool): Zero trust mode.
199        :param zero_trust_interval (int): The zero trust interval.
200        :param orthanc_url (str): The orthanc url.
201        :param orthanc_username (str): The orthanc username.
202        :param orthanc_password (str): The orthanc password.
203        """
204        self.savedir = savedir
205        self.url = url
206        self.db_path = db_path
207        self.upload_dir = upload_dir
208        self.hippa_logging_file = hippa_logging_file
209        self.api_token = api_token
210        self.origins = origins
211        self.zero_trust = zero_trust
212        self.zero_trust_interval = zero_trust_interval
213        self.orthanc_url = orthanc_url
214        self.orthanc_username = orthanc_username
215        self.orthanc_password = orthanc_password
216
217
218class VisualsConfig:
219    def __init__(
220        self,
221        font_h1: Union[None, ImageFont.ImageFont],
222        font_h2: Union[None, ImageFont.ImageFont],
223        default_font_size: int,
224        seg_color: Colors,
225        seg_alpha: Colors,
226        hip_color: Colors,
227        bounding_box_color: Colors,
228        bounding_box_thickness: int,
229        text_color: Colors,
230        background_text_color: Colors,
231        points_color: Colors,
232        points_radius: int,
233        line_color: Colors,
234        line_thickness: int,
235        graf_color: Colors,
236        display_full_metric_names: bool,
237        display_boxes: bool,
238        display_segs: bool,
239        min_vid_fps: int,
240        min_vid_length: int,
241    ):
242        """
243        The Visuals Subconfig.
244
245        :param font_h1 (ImageFont): The font for the h1.
246        :param font_h2 (ImageFont): The font for the h2.
247        :param default_font_size (int): The default font size.
248        :param seg_color (Colors): The color of segmentations.
249        :param seg_alpha (Colors): The alpha of segmentations.
250        :param hip_color (Colors): The color of hips.
251        :param bounding_box_color (Colors): The color of bounding boxes.
252        :param bounding_box_thickness (int): The thickness of bounding boxes.
253        :param text_color (Colors): The color of text.
254        :param background_text_color (Colors): The background color of text.
255        :param points_color (Colors): The color of points.
256        :param points_radius (int): The radius of points.
257        :param line_color (Colors): The color of lines.
258        :param line_thickness (int): The thickness of lines.
259        :param graf_color (Colors): The color of grafs.
260        :param display_full_metric_names (bool): Display full metric names.
261        :param display_boxes (bool): Display boxes.
262        :param display_segs (bool): Display segmentations.
263        :param min_vid_fps (int): The minimum video fps.
264        :param min_vid_length (int): The minimum video length
265        """
266        self.seg_color = seg_color
267        self.seg_alpha = seg_alpha
268        self.hip_color = hip_color
269        self.bounding_box_color = bounding_box_color
270        self.bounding_box_thickness = bounding_box_thickness
271        self.text_color = text_color
272        self.background_text_color = background_text_color
273        self.points_color = points_color
274        self.points_radius = points_radius
275        self.line_color = line_color
276        self.line_thickness = line_thickness
277        self.graf_color = graf_color
278        self.display_full_metric_names = display_full_metric_names
279        self.display_boxes = display_boxes
280        self.display_segs = display_segs
281        self.min_vid_fps = min_vid_fps
282        self.min_vid_length = min_vid_length
283
284        self.font_h1 = font_h1
285        self.font_h2 = font_h2
286        self.default_font_size = default_font_size
287
288        if not font_h1:
289            self.font_h1 = ImageFont.truetype(
290                f"{RETUVE_DIR}/files/RobotoMono-Regular.ttf",
291                self.default_font_size,
292            )
293
294        if not font_h2:
295            self.font_h2 = ImageFont.truetype(
296                f"{RETUVE_DIR}/files/RobotoMono-Regular.ttf",
297                self.default_font_size,
298            )
class HipConfig:
 42class HipConfig:
 43    def __init__(
 44        self,
 45        midline_color: Colors,
 46        aca_split: ACASplit,
 47        cr_fem_pos: CRFem,
 48        fem_extention: float,
 49        midline_move_method: MidLineMove,
 50        curvature_method: Curvature,
 51        measurements: List[MetricUS],
 52        z_gap: float,
 53        display_frame_no: bool,
 54        display_side: bool,
 55        draw_midline: bool,
 56        display_fem_guess: bool,
 57        draw_side_metainfo: bool,
 58        allow_flipping: bool,
 59        display_bad_frame_reasons: bool,
 60        graf_selection_method: GrafSelectionMethod,
 61        graf_selection_func: Any,
 62        graf_selection_func_args: Dict[str, Any],
 63        display_graf_conf: bool,
 64        graf_algo_threshold: float,
 65    ):
 66        """
 67        The Hip Subconfig.
 68
 69        :param midline_color (Colors): The color of the midline.
 70        :param aca_split (ACASplit): The ACA split method.
 71        :param cr_fem_pos (CRFem): The CR Femoral position.
 72        :param fem_extention (float): The femoral extention length.
 73        :param midline_move_method (MidLineMove): The midline move method.
 74        :param curvature_method (Curvature): The curvature method.
 75        :param measurements (list): The measurements to calculate.
 76        :param z_gap (float): The z gap.
 77        :param display_frame_no (bool): Display the frame number.
 78        :param display_side (bool): Display the side.
 79        :param draw_midline (bool): Draw the midline.
 80        :param display_fem_guess (bool): Display the femoral guess.
 81        :param draw_side_metainfo (bool): Draw the side metainfo.
 82        :param allow_flipping (bool): Allow use of the 3D US Orientaition Algorithm.
 83        :param display_bad_frame_reasons (bool): Display the bad frame reasons.
 84        :param graf_selection_method (GrafSelectionMethod): The graf selection method.
 85        :param graf_selection_func (Any): The graf selection func, if needed.
 86        :param graf_selection_func_args (dict): The arguments to pass to the graf, if needed.
 87        :param display_graf_conf (bool): Display the graf confidence.
 88        :param graf_algo_threshold (float): The graf algorithm confidence threshold.
 89        """
 90        self.midline_color = midline_color
 91        self.aca_split = aca_split
 92        self.cr_fem_pos = cr_fem_pos
 93        self.fem_extention = fem_extention
 94        self.midline_move_method = midline_move_method
 95        self.curvature_method = curvature_method
 96        self.measurements = measurements
 97        self.z_gap = z_gap
 98        self.display_frame_no = display_frame_no
 99        self.display_side = display_side
100        self.draw_midline = draw_midline
101        self.display_fem_guess = display_fem_guess
102        self.draw_side_metainfo = draw_side_metainfo
103        self.allow_flipping = allow_flipping
104        self.display_bad_frame_reasons = display_bad_frame_reasons
105        self.graf_selection_method = graf_selection_method
106        self.graf_selection_func = graf_selection_func
107        self.graf_selection_func_args = graf_selection_func_args
108        self.display_graf_conf = display_graf_conf
109        self.graf_algo_threshold = graf_algo_threshold
HipConfig( midline_color: retuve.keyphrases.enums.Colors, aca_split: retuve.keyphrases.enums.ACASplit, cr_fem_pos: retuve.keyphrases.enums.CRFem, fem_extention: float, midline_move_method: retuve.keyphrases.enums.MidLineMove, curvature_method: retuve.keyphrases.enums.Curvature, measurements: List[retuve.keyphrases.enums.MetricUS], z_gap: float, display_frame_no: bool, display_side: bool, draw_midline: bool, display_fem_guess: bool, draw_side_metainfo: bool, allow_flipping: bool, display_bad_frame_reasons: bool, graf_selection_method: retuve.keyphrases.enums.GrafSelectionMethod, graf_selection_func: Any, graf_selection_func_args: Dict[str, Any], display_graf_conf: bool, graf_algo_threshold: float)
 43    def __init__(
 44        self,
 45        midline_color: Colors,
 46        aca_split: ACASplit,
 47        cr_fem_pos: CRFem,
 48        fem_extention: float,
 49        midline_move_method: MidLineMove,
 50        curvature_method: Curvature,
 51        measurements: List[MetricUS],
 52        z_gap: float,
 53        display_frame_no: bool,
 54        display_side: bool,
 55        draw_midline: bool,
 56        display_fem_guess: bool,
 57        draw_side_metainfo: bool,
 58        allow_flipping: bool,
 59        display_bad_frame_reasons: bool,
 60        graf_selection_method: GrafSelectionMethod,
 61        graf_selection_func: Any,
 62        graf_selection_func_args: Dict[str, Any],
 63        display_graf_conf: bool,
 64        graf_algo_threshold: float,
 65    ):
 66        """
 67        The Hip Subconfig.
 68
 69        :param midline_color (Colors): The color of the midline.
 70        :param aca_split (ACASplit): The ACA split method.
 71        :param cr_fem_pos (CRFem): The CR Femoral position.
 72        :param fem_extention (float): The femoral extention length.
 73        :param midline_move_method (MidLineMove): The midline move method.
 74        :param curvature_method (Curvature): The curvature method.
 75        :param measurements (list): The measurements to calculate.
 76        :param z_gap (float): The z gap.
 77        :param display_frame_no (bool): Display the frame number.
 78        :param display_side (bool): Display the side.
 79        :param draw_midline (bool): Draw the midline.
 80        :param display_fem_guess (bool): Display the femoral guess.
 81        :param draw_side_metainfo (bool): Draw the side metainfo.
 82        :param allow_flipping (bool): Allow use of the 3D US Orientaition Algorithm.
 83        :param display_bad_frame_reasons (bool): Display the bad frame reasons.
 84        :param graf_selection_method (GrafSelectionMethod): The graf selection method.
 85        :param graf_selection_func (Any): The graf selection func, if needed.
 86        :param graf_selection_func_args (dict): The arguments to pass to the graf, if needed.
 87        :param display_graf_conf (bool): Display the graf confidence.
 88        :param graf_algo_threshold (float): The graf algorithm confidence threshold.
 89        """
 90        self.midline_color = midline_color
 91        self.aca_split = aca_split
 92        self.cr_fem_pos = cr_fem_pos
 93        self.fem_extention = fem_extention
 94        self.midline_move_method = midline_move_method
 95        self.curvature_method = curvature_method
 96        self.measurements = measurements
 97        self.z_gap = z_gap
 98        self.display_frame_no = display_frame_no
 99        self.display_side = display_side
100        self.draw_midline = draw_midline
101        self.display_fem_guess = display_fem_guess
102        self.draw_side_metainfo = draw_side_metainfo
103        self.allow_flipping = allow_flipping
104        self.display_bad_frame_reasons = display_bad_frame_reasons
105        self.graf_selection_method = graf_selection_method
106        self.graf_selection_func = graf_selection_func
107        self.graf_selection_func_args = graf_selection_func_args
108        self.display_graf_conf = display_graf_conf
109        self.graf_algo_threshold = graf_algo_threshold

The Hip Subconfig.

Parameters
  • midline_color (Colors): The color of the midline.
  • aca_split (ACASplit): The ACA split method.
  • cr_fem_pos (CRFem): The CR Femoral position.
  • fem_extention (float): The femoral extention length.
  • midline_move_method (MidLineMove): The midline move method.
  • curvature_method (Curvature): The curvature method.
  • measurements (list): The measurements to calculate.
  • z_gap (float): The z gap.
  • display_frame_no (bool): Display the frame number.
  • display_side (bool): Display the side.
  • draw_midline (bool): Draw the midline.
  • display_fem_guess (bool): Display the femoral guess.
  • draw_side_metainfo (bool): Draw the side metainfo.
  • allow_flipping (bool): Allow use of the 3D US Orientaition Algorithm.
  • display_bad_frame_reasons (bool): Display the bad frame reasons.
  • graf_selection_method (GrafSelectionMethod): The graf selection method.
  • graf_selection_func (Any): The graf selection func, if needed.
  • graf_selection_func_args (dict): The arguments to pass to the graf, if needed.
  • display_graf_conf (bool): Display the graf confidence.
  • graf_algo_threshold (float): The graf algorithm confidence threshold.
midline_color
aca_split
cr_fem_pos
fem_extention
midline_move_method
curvature_method
measurements
z_gap
display_frame_no
display_side
draw_midline
display_fem_guess
draw_side_metainfo
allow_flipping
display_bad_frame_reasons
graf_selection_method
graf_selection_func
graf_selection_func_args
display_graf_conf
graf_algo_threshold
class TrakConfig:
112class TrakConfig:
113    def __init__(
114        self,
115        datasets: List[str],
116    ):
117        """
118        Initialize TrakConfig.
119
120        :param datasets (list): The datasets to process.
121        """
122        self.datasets = datasets
TrakConfig(datasets: List[str])
113    def __init__(
114        self,
115        datasets: List[str],
116    ):
117        """
118        Initialize TrakConfig.
119
120        :param datasets (list): The datasets to process.
121        """
122        self.datasets = datasets

Initialize TrakConfig.

Parameters
  • datasets (list): The datasets to process.
datasets
class BatchConfig:
125class BatchConfig:
126    def __init__(
127        self,
128        mode_func: GeneralModeFuncType,
129        mode_func_args: Dict[str, Any],
130        hip_mode: HipMode,
131        processes: int,
132        input_types: List[Literal[".dcm", ".jpg", ".png"]],
133        datasets: List[str],
134    ):
135        """
136        Initialize BatchConfig.
137
138        :param mode_func (callable): The mode function to use.
139        :param mode_func_args (dict): The arguments to pass to the mode function.
140        :param hip_mode (str): The mode of the hip us.
141        :param processes (int): The number of processes to use.
142        :param input_types (list): The type of input to use.
143        :param datasets (list): The datasets to process.
144
145        :attr outputs (list): The outputs to generate.
146        """
147        self.mode_func = mode_func
148        self.mode_func_args = mode_func_args
149        self.hip_mode = hip_mode
150        self.processes = processes
151        self.input_types = input_types
152        self.datasets = datasets
153
154        # set properly upon registration
155        self.outputs: List[Outputs] = [Outputs.METRICS]
156
157    def register(self):
158        if self.hip_mode == HipMode.US3D:
159            self.outputs.append(Outputs.VIDEO_CLIP)
160            self.outputs.append(Outputs.VISUAL3D)
161
162        elif self.hip_mode == HipMode.US2D:
163            self.outputs.append(Outputs.IMAGE)
164
165        elif self.hip_mode == HipMode.US2DSW:
166            self.outputs.append(Outputs.IMAGE)
167            self.outputs.append(Outputs.VIDEO_CLIP)
168
169        elif self.hip_mode == HipMode.XRAY:
170            self.outputs.append(Outputs.IMAGE)
BatchConfig( mode_func: Callable[[Union[BinaryIO, PIL.Image.Image, pydicom.dataset.FileDataset], Union[str, List[str]], Dict[str, Any]], Union[Tuple[List[retuve.hip_xray.classes.LandmarksXRay], List[retuve.classes.seg.SegFrameObjects]], List[retuve.classes.seg.SegFrameObjects]]], mode_func_args: Dict[str, Any], hip_mode: retuve.keyphrases.enums.HipMode, processes: int, input_types: List[Literal['.dcm', '.jpg', '.png']], datasets: List[str])
126    def __init__(
127        self,
128        mode_func: GeneralModeFuncType,
129        mode_func_args: Dict[str, Any],
130        hip_mode: HipMode,
131        processes: int,
132        input_types: List[Literal[".dcm", ".jpg", ".png"]],
133        datasets: List[str],
134    ):
135        """
136        Initialize BatchConfig.
137
138        :param mode_func (callable): The mode function to use.
139        :param mode_func_args (dict): The arguments to pass to the mode function.
140        :param hip_mode (str): The mode of the hip us.
141        :param processes (int): The number of processes to use.
142        :param input_types (list): The type of input to use.
143        :param datasets (list): The datasets to process.
144
145        :attr outputs (list): The outputs to generate.
146        """
147        self.mode_func = mode_func
148        self.mode_func_args = mode_func_args
149        self.hip_mode = hip_mode
150        self.processes = processes
151        self.input_types = input_types
152        self.datasets = datasets
153
154        # set properly upon registration
155        self.outputs: List[Outputs] = [Outputs.METRICS]

Initialize BatchConfig.

Parameters
  • mode_func (callable): The mode function to use.
  • mode_func_args (dict): The arguments to pass to the mode function.
  • hip_mode (str): The mode of the hip us.
  • processes (int): The number of processes to use.
  • input_types (list): The type of input to use.
  • datasets (list): The datasets to process.

:attr outputs (list): The outputs to generate.

mode_func
mode_func_args
hip_mode
processes
input_types
datasets
def register(self):
157    def register(self):
158        if self.hip_mode == HipMode.US3D:
159            self.outputs.append(Outputs.VIDEO_CLIP)
160            self.outputs.append(Outputs.VISUAL3D)
161
162        elif self.hip_mode == HipMode.US2D:
163            self.outputs.append(Outputs.IMAGE)
164
165        elif self.hip_mode == HipMode.US2DSW:
166            self.outputs.append(Outputs.IMAGE)
167            self.outputs.append(Outputs.VIDEO_CLIP)
168
169        elif self.hip_mode == HipMode.XRAY:
170            self.outputs.append(Outputs.IMAGE)
class APIConfig:
173class APIConfig:
174    def __init__(
175        self,
176        savedir: str,
177        url: str,
178        db_path: str,
179        upload_dir: str,
180        hippa_logging_file: str,
181        api_token: str,
182        origins: List[str],
183        zero_trust: bool,
184        zero_trust_interval: int,
185        orthanc_url: str,
186        orthanc_username: str,
187        orthanc_password: str,
188    ):
189        """
190        Initialize APIConfig.
191
192        :param savedir (str): The save directory of results.
193        :param url (str): The url to serve the API.
194        :param db_path (str): The db path.
195        :param upload_dir (str): The upload directory.
196        :param hippa_logging_file (str): The logging file for HIPPA related logs.
197        :param api_token (str): The api token.
198        :param origins (list): The origins to allow.
199        :param zero_trust (bool): Zero trust mode.
200        :param zero_trust_interval (int): The zero trust interval.
201        :param orthanc_url (str): The orthanc url.
202        :param orthanc_username (str): The orthanc username.
203        :param orthanc_password (str): The orthanc password.
204        """
205        self.savedir = savedir
206        self.url = url
207        self.db_path = db_path
208        self.upload_dir = upload_dir
209        self.hippa_logging_file = hippa_logging_file
210        self.api_token = api_token
211        self.origins = origins
212        self.zero_trust = zero_trust
213        self.zero_trust_interval = zero_trust_interval
214        self.orthanc_url = orthanc_url
215        self.orthanc_username = orthanc_username
216        self.orthanc_password = orthanc_password
APIConfig( savedir: str, url: str, db_path: str, upload_dir: str, hippa_logging_file: str, api_token: str, origins: List[str], zero_trust: bool, zero_trust_interval: int, orthanc_url: str, orthanc_username: str, orthanc_password: str)
174    def __init__(
175        self,
176        savedir: str,
177        url: str,
178        db_path: str,
179        upload_dir: str,
180        hippa_logging_file: str,
181        api_token: str,
182        origins: List[str],
183        zero_trust: bool,
184        zero_trust_interval: int,
185        orthanc_url: str,
186        orthanc_username: str,
187        orthanc_password: str,
188    ):
189        """
190        Initialize APIConfig.
191
192        :param savedir (str): The save directory of results.
193        :param url (str): The url to serve the API.
194        :param db_path (str): The db path.
195        :param upload_dir (str): The upload directory.
196        :param hippa_logging_file (str): The logging file for HIPPA related logs.
197        :param api_token (str): The api token.
198        :param origins (list): The origins to allow.
199        :param zero_trust (bool): Zero trust mode.
200        :param zero_trust_interval (int): The zero trust interval.
201        :param orthanc_url (str): The orthanc url.
202        :param orthanc_username (str): The orthanc username.
203        :param orthanc_password (str): The orthanc password.
204        """
205        self.savedir = savedir
206        self.url = url
207        self.db_path = db_path
208        self.upload_dir = upload_dir
209        self.hippa_logging_file = hippa_logging_file
210        self.api_token = api_token
211        self.origins = origins
212        self.zero_trust = zero_trust
213        self.zero_trust_interval = zero_trust_interval
214        self.orthanc_url = orthanc_url
215        self.orthanc_username = orthanc_username
216        self.orthanc_password = orthanc_password

Initialize APIConfig.

Parameters
  • savedir (str): The save directory of results.
  • url (str): The url to serve the API.
  • db_path (str): The db path.
  • upload_dir (str): The upload directory.
  • hippa_logging_file (str): The logging file for HIPPA related logs.
  • api_token (str): The api token.
  • origins (list): The origins to allow.
  • zero_trust (bool): Zero trust mode.
  • zero_trust_interval (int): The zero trust interval.
  • orthanc_url (str): The orthanc url.
  • orthanc_username (str): The orthanc username.
  • orthanc_password (str): The orthanc password.
savedir
url
db_path
upload_dir
hippa_logging_file
api_token
origins
zero_trust
zero_trust_interval
orthanc_url
orthanc_username
orthanc_password
class VisualsConfig:
219class VisualsConfig:
220    def __init__(
221        self,
222        font_h1: Union[None, ImageFont.ImageFont],
223        font_h2: Union[None, ImageFont.ImageFont],
224        default_font_size: int,
225        seg_color: Colors,
226        seg_alpha: Colors,
227        hip_color: Colors,
228        bounding_box_color: Colors,
229        bounding_box_thickness: int,
230        text_color: Colors,
231        background_text_color: Colors,
232        points_color: Colors,
233        points_radius: int,
234        line_color: Colors,
235        line_thickness: int,
236        graf_color: Colors,
237        display_full_metric_names: bool,
238        display_boxes: bool,
239        display_segs: bool,
240        min_vid_fps: int,
241        min_vid_length: int,
242    ):
243        """
244        The Visuals Subconfig.
245
246        :param font_h1 (ImageFont): The font for the h1.
247        :param font_h2 (ImageFont): The font for the h2.
248        :param default_font_size (int): The default font size.
249        :param seg_color (Colors): The color of segmentations.
250        :param seg_alpha (Colors): The alpha of segmentations.
251        :param hip_color (Colors): The color of hips.
252        :param bounding_box_color (Colors): The color of bounding boxes.
253        :param bounding_box_thickness (int): The thickness of bounding boxes.
254        :param text_color (Colors): The color of text.
255        :param background_text_color (Colors): The background color of text.
256        :param points_color (Colors): The color of points.
257        :param points_radius (int): The radius of points.
258        :param line_color (Colors): The color of lines.
259        :param line_thickness (int): The thickness of lines.
260        :param graf_color (Colors): The color of grafs.
261        :param display_full_metric_names (bool): Display full metric names.
262        :param display_boxes (bool): Display boxes.
263        :param display_segs (bool): Display segmentations.
264        :param min_vid_fps (int): The minimum video fps.
265        :param min_vid_length (int): The minimum video length
266        """
267        self.seg_color = seg_color
268        self.seg_alpha = seg_alpha
269        self.hip_color = hip_color
270        self.bounding_box_color = bounding_box_color
271        self.bounding_box_thickness = bounding_box_thickness
272        self.text_color = text_color
273        self.background_text_color = background_text_color
274        self.points_color = points_color
275        self.points_radius = points_radius
276        self.line_color = line_color
277        self.line_thickness = line_thickness
278        self.graf_color = graf_color
279        self.display_full_metric_names = display_full_metric_names
280        self.display_boxes = display_boxes
281        self.display_segs = display_segs
282        self.min_vid_fps = min_vid_fps
283        self.min_vid_length = min_vid_length
284
285        self.font_h1 = font_h1
286        self.font_h2 = font_h2
287        self.default_font_size = default_font_size
288
289        if not font_h1:
290            self.font_h1 = ImageFont.truetype(
291                f"{RETUVE_DIR}/files/RobotoMono-Regular.ttf",
292                self.default_font_size,
293            )
294
295        if not font_h2:
296            self.font_h2 = ImageFont.truetype(
297                f"{RETUVE_DIR}/files/RobotoMono-Regular.ttf",
298                self.default_font_size,
299            )
VisualsConfig( font_h1: Optional[PIL.ImageFont.ImageFont], font_h2: Optional[PIL.ImageFont.ImageFont], default_font_size: int, seg_color: retuve.keyphrases.enums.Colors, seg_alpha: retuve.keyphrases.enums.Colors, hip_color: retuve.keyphrases.enums.Colors, bounding_box_color: retuve.keyphrases.enums.Colors, bounding_box_thickness: int, text_color: retuve.keyphrases.enums.Colors, background_text_color: retuve.keyphrases.enums.Colors, points_color: retuve.keyphrases.enums.Colors, points_radius: int, line_color: retuve.keyphrases.enums.Colors, line_thickness: int, graf_color: retuve.keyphrases.enums.Colors, display_full_metric_names: bool, display_boxes: bool, display_segs: bool, min_vid_fps: int, min_vid_length: int)
220    def __init__(
221        self,
222        font_h1: Union[None, ImageFont.ImageFont],
223        font_h2: Union[None, ImageFont.ImageFont],
224        default_font_size: int,
225        seg_color: Colors,
226        seg_alpha: Colors,
227        hip_color: Colors,
228        bounding_box_color: Colors,
229        bounding_box_thickness: int,
230        text_color: Colors,
231        background_text_color: Colors,
232        points_color: Colors,
233        points_radius: int,
234        line_color: Colors,
235        line_thickness: int,
236        graf_color: Colors,
237        display_full_metric_names: bool,
238        display_boxes: bool,
239        display_segs: bool,
240        min_vid_fps: int,
241        min_vid_length: int,
242    ):
243        """
244        The Visuals Subconfig.
245
246        :param font_h1 (ImageFont): The font for the h1.
247        :param font_h2 (ImageFont): The font for the h2.
248        :param default_font_size (int): The default font size.
249        :param seg_color (Colors): The color of segmentations.
250        :param seg_alpha (Colors): The alpha of segmentations.
251        :param hip_color (Colors): The color of hips.
252        :param bounding_box_color (Colors): The color of bounding boxes.
253        :param bounding_box_thickness (int): The thickness of bounding boxes.
254        :param text_color (Colors): The color of text.
255        :param background_text_color (Colors): The background color of text.
256        :param points_color (Colors): The color of points.
257        :param points_radius (int): The radius of points.
258        :param line_color (Colors): The color of lines.
259        :param line_thickness (int): The thickness of lines.
260        :param graf_color (Colors): The color of grafs.
261        :param display_full_metric_names (bool): Display full metric names.
262        :param display_boxes (bool): Display boxes.
263        :param display_segs (bool): Display segmentations.
264        :param min_vid_fps (int): The minimum video fps.
265        :param min_vid_length (int): The minimum video length
266        """
267        self.seg_color = seg_color
268        self.seg_alpha = seg_alpha
269        self.hip_color = hip_color
270        self.bounding_box_color = bounding_box_color
271        self.bounding_box_thickness = bounding_box_thickness
272        self.text_color = text_color
273        self.background_text_color = background_text_color
274        self.points_color = points_color
275        self.points_radius = points_radius
276        self.line_color = line_color
277        self.line_thickness = line_thickness
278        self.graf_color = graf_color
279        self.display_full_metric_names = display_full_metric_names
280        self.display_boxes = display_boxes
281        self.display_segs = display_segs
282        self.min_vid_fps = min_vid_fps
283        self.min_vid_length = min_vid_length
284
285        self.font_h1 = font_h1
286        self.font_h2 = font_h2
287        self.default_font_size = default_font_size
288
289        if not font_h1:
290            self.font_h1 = ImageFont.truetype(
291                f"{RETUVE_DIR}/files/RobotoMono-Regular.ttf",
292                self.default_font_size,
293            )
294
295        if not font_h2:
296            self.font_h2 = ImageFont.truetype(
297                f"{RETUVE_DIR}/files/RobotoMono-Regular.ttf",
298                self.default_font_size,
299            )

The Visuals Subconfig.

Parameters
  • font_h1 (ImageFont): The font for the h1.
  • font_h2 (ImageFont): The font for the h2.
  • default_font_size (int): The default font size.
  • seg_color (Colors): The color of segmentations.
  • seg_alpha (Colors): The alpha of segmentations.
  • hip_color (Colors): The color of hips.
  • bounding_box_color (Colors): The color of bounding boxes.
  • bounding_box_thickness (int): The thickness of bounding boxes.
  • text_color (Colors): The color of text.
  • background_text_color (Colors): The background color of text.
  • points_color (Colors): The color of points.
  • points_radius (int): The radius of points.
  • line_color (Colors): The color of lines.
  • line_thickness (int): The thickness of lines.
  • graf_color (Colors): The color of grafs.
  • display_full_metric_names (bool): Display full metric names.
  • display_boxes (bool): Display boxes.
  • display_segs (bool): Display segmentations.
  • min_vid_fps (int): The minimum video fps.
  • min_vid_length (int): The minimum video length
seg_color
seg_alpha
hip_color
bounding_box_color
bounding_box_thickness
text_color
background_text_color
points_color
points_radius
line_color
line_thickness
graf_color
display_full_metric_names
display_boxes
display_segs
min_vid_fps
min_vid_length
font_h1
font_h2
default_font_size