retuve.keyphrases.enums

All the Configuration-based Enums

  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 Configuration-based Enums
 17"""
 18
 19import os
 20
 21from PIL import ImageColor
 22
 23
 24class Colors:
 25    """
 26    Class for managing common colors.
 27    """
 28
 29    WHITE = (255, 255, 255)
 30    RED = (255, 84, 115)
 31    GREEN = (0, 255, 0)
 32    BLUE = (17, 60, 130)
 33    BLACK = (0, 0, 0)
 34    GREY = (128, 128, 128)
 35    DARK_RED = (139, 0, 0)
 36    LIGHT_BLUE = (113, 194, 245)
 37    PURPLE = (215, 84, 255)
 38    GOLD = ImageColor.getcolor("#78620A", "RGB")
 39
 40    def __init__(self, rgb=None):
 41        self.rgb = rgb
 42
 43    def rgba(self, alpha=1):
 44        """
 45        Get the color with alpha.
 46
 47        :param alpha: The alpha value
 48        """
 49        return (*self.rgb, int(alpha * 255))
 50
 51    def bgr(self):
 52        """
 53        Get the color in BGR format.
 54        """
 55        return self.rgb[::-1]
 56
 57    def __repr__(self) -> str:
 58        return f"Color({self.rgb})"
 59
 60
 61class ACASplit:
 62    """
 63    Options for ACA split.
 64
 65    :attr THIRDS: Split into thirds equally
 66    :attr GRAFS: Split using the grafs plane as the divider
 67
 68    :attr OPTIONS: List of acceptable options
 69    """
 70
 71    THIRDS = "thirds"
 72    GRAFS = "grafs"
 73
 74    OPTIONS = [THIRDS, GRAFS]
 75
 76
 77class CRFem:
 78    """
 79    Options for Femoral Head Center position.
 80
 81    :attr GRAFS: Use the GRAFS method
 82    :attr CENTER: Use the CENTER method
 83
 84    :attr OPTIONS: List of acceptable options
 85    """
 86
 87    GRAFS = "grafs"
 88    CENTER = "center"
 89
 90    OPTIONS = [GRAFS, CENTER]
 91
 92
 93class MidLineMove:
 94    """
 95    Options for midline move method.
 96
 97    :attr BASIC: Use the most basic method.
 98    """
 99
100    BASIC = "basic"
101
102
103class Curvature:
104    """
105    Options for curvature method.
106
107    :attr Radist: Use the radist method.
108    """
109
110    RADIST = "radist"
111
112
113class MetricUS:
114    """
115    The Ultrasound Metric types.
116
117    :attr ALPHA: The alpha angle
118    :attr COVERAGE: The coverage
119    :attr CURVATURE: The curvature
120    :attr CENTERING_RATIO: The centering ratio
121    :attr ACA: The Acetabular Coverage Angle
122    """
123
124    ALPHA = "alpha"
125    COVERAGE = "coverage"
126    CURVATURE = "curvature"
127    CENTERING_RATIO = "cen. ratio"
128    ACA = "aca"
129
130    @classmethod
131    def ALL(cls):
132        return [
133            cls.ALPHA,
134            cls.COVERAGE,
135            cls.CURVATURE,
136            cls.CENTERING_RATIO,
137            cls.ACA,
138        ]
139
140
141class OperationType:
142    """
143    Operation type of the AI Model being used.
144
145    :attr SEG: The model is a segmentation model
146    :attr LANDMARK: The model is a landmark model
147    """
148
149    SEG = "seg"
150    LANDMARK = "landmark"
151
152
153class HipMode:
154    """
155    Hip US modes.
156
157    :attr US3D: 3D Ultrasound
158    :attr US2D: 2D Ultrasound
159    :attr US2DSW: 2D Sweep Ultrasound
160    :attr XRAY: X-Ray
161    """
162
163    US3D = "us3d"
164    US2D = "us2d"
165    US2DSW = "us2dsw"
166    XRAY = "xray"
167
168
169class Outputs:
170    """
171    Output Extensions.
172
173    """
174
175    IMAGE = "img.jpg"
176    METRICS = "metrics.json"
177    VIDEO_CLIP = "video.mp4"
178    VISUAL3D = "visual_3d.html"
179
180
181class GrafSelectionMethod:
182    """
183    Graf Frame Selection Methods.
184    """
185
186    MANUAL_FEATURES = "manual_features"
187    OBJ_CLASSIFY = "obj_classify"
class Colors:
25class Colors:
26    """
27    Class for managing common colors.
28    """
29
30    WHITE = (255, 255, 255)
31    RED = (255, 84, 115)
32    GREEN = (0, 255, 0)
33    BLUE = (17, 60, 130)
34    BLACK = (0, 0, 0)
35    GREY = (128, 128, 128)
36    DARK_RED = (139, 0, 0)
37    LIGHT_BLUE = (113, 194, 245)
38    PURPLE = (215, 84, 255)
39    GOLD = ImageColor.getcolor("#78620A", "RGB")
40
41    def __init__(self, rgb=None):
42        self.rgb = rgb
43
44    def rgba(self, alpha=1):
45        """
46        Get the color with alpha.
47
48        :param alpha: The alpha value
49        """
50        return (*self.rgb, int(alpha * 255))
51
52    def bgr(self):
53        """
54        Get the color in BGR format.
55        """
56        return self.rgb[::-1]
57
58    def __repr__(self) -> str:
59        return f"Color({self.rgb})"

Class for managing common colors.

Colors(rgb=None)
41    def __init__(self, rgb=None):
42        self.rgb = rgb
WHITE = (255, 255, 255)
RED = (255, 84, 115)
GREEN = (0, 255, 0)
BLUE = (17, 60, 130)
BLACK = (0, 0, 0)
GREY = (128, 128, 128)
DARK_RED = (139, 0, 0)
LIGHT_BLUE = (113, 194, 245)
PURPLE = (215, 84, 255)
GOLD = (120, 98, 10)
rgb
def rgba(self, alpha=1):
44    def rgba(self, alpha=1):
45        """
46        Get the color with alpha.
47
48        :param alpha: The alpha value
49        """
50        return (*self.rgb, int(alpha * 255))

Get the color with alpha.

Parameters
  • alpha: The alpha value
def bgr(self):
52    def bgr(self):
53        """
54        Get the color in BGR format.
55        """
56        return self.rgb[::-1]

Get the color in BGR format.

class ACASplit:
62class ACASplit:
63    """
64    Options for ACA split.
65
66    :attr THIRDS: Split into thirds equally
67    :attr GRAFS: Split using the grafs plane as the divider
68
69    :attr OPTIONS: List of acceptable options
70    """
71
72    THIRDS = "thirds"
73    GRAFS = "grafs"
74
75    OPTIONS = [THIRDS, GRAFS]

Options for ACA split.

:attr THIRDS: Split into thirds equally :attr GRAFS: Split using the grafs plane as the divider

:attr OPTIONS: List of acceptable options

THIRDS = 'thirds'
GRAFS = 'grafs'
OPTIONS = ['thirds', 'grafs']
class CRFem:
78class CRFem:
79    """
80    Options for Femoral Head Center position.
81
82    :attr GRAFS: Use the GRAFS method
83    :attr CENTER: Use the CENTER method
84
85    :attr OPTIONS: List of acceptable options
86    """
87
88    GRAFS = "grafs"
89    CENTER = "center"
90
91    OPTIONS = [GRAFS, CENTER]

Options for Femoral Head Center position.

:attr GRAFS: Use the GRAFS method :attr CENTER: Use the CENTER method

:attr OPTIONS: List of acceptable options

GRAFS = 'grafs'
CENTER = 'center'
OPTIONS = ['grafs', 'center']
class MidLineMove:
 94class MidLineMove:
 95    """
 96    Options for midline move method.
 97
 98    :attr BASIC: Use the most basic method.
 99    """
100
101    BASIC = "basic"

Options for midline move method.

:attr BASIC: Use the most basic method.

BASIC = 'basic'
class Curvature:
104class Curvature:
105    """
106    Options for curvature method.
107
108    :attr Radist: Use the radist method.
109    """
110
111    RADIST = "radist"

Options for curvature method.

:attr Radist: Use the radist method.

RADIST = 'radist'
class MetricUS:
114class MetricUS:
115    """
116    The Ultrasound Metric types.
117
118    :attr ALPHA: The alpha angle
119    :attr COVERAGE: The coverage
120    :attr CURVATURE: The curvature
121    :attr CENTERING_RATIO: The centering ratio
122    :attr ACA: The Acetabular Coverage Angle
123    """
124
125    ALPHA = "alpha"
126    COVERAGE = "coverage"
127    CURVATURE = "curvature"
128    CENTERING_RATIO = "cen. ratio"
129    ACA = "aca"
130
131    @classmethod
132    def ALL(cls):
133        return [
134            cls.ALPHA,
135            cls.COVERAGE,
136            cls.CURVATURE,
137            cls.CENTERING_RATIO,
138            cls.ACA,
139        ]

The Ultrasound Metric types.

:attr ALPHA: The alpha angle :attr COVERAGE: The coverage :attr CURVATURE: The curvature :attr CENTERING_RATIO: The centering ratio :attr ACA: The Acetabular Coverage Angle

ALPHA = 'alpha'
COVERAGE = 'coverage'
CURVATURE = 'curvature'
CENTERING_RATIO = 'cen. ratio'
ACA = 'aca'
@classmethod
def ALL(cls):
131    @classmethod
132    def ALL(cls):
133        return [
134            cls.ALPHA,
135            cls.COVERAGE,
136            cls.CURVATURE,
137            cls.CENTERING_RATIO,
138            cls.ACA,
139        ]
class OperationType:
142class OperationType:
143    """
144    Operation type of the AI Model being used.
145
146    :attr SEG: The model is a segmentation model
147    :attr LANDMARK: The model is a landmark model
148    """
149
150    SEG = "seg"
151    LANDMARK = "landmark"

Operation type of the AI Model being used.

:attr SEG: The model is a segmentation model :attr LANDMARK: The model is a landmark model

SEG = 'seg'
LANDMARK = 'landmark'
class HipMode:
154class HipMode:
155    """
156    Hip US modes.
157
158    :attr US3D: 3D Ultrasound
159    :attr US2D: 2D Ultrasound
160    :attr US2DSW: 2D Sweep Ultrasound
161    :attr XRAY: X-Ray
162    """
163
164    US3D = "us3d"
165    US2D = "us2d"
166    US2DSW = "us2dsw"
167    XRAY = "xray"

Hip US modes.

:attr US3D: 3D Ultrasound :attr US2D: 2D Ultrasound :attr US2DSW: 2D Sweep Ultrasound :attr XRAY: X-Ray

US3D = 'us3d'
US2D = 'us2d'
US2DSW = 'us2dsw'
XRAY = 'xray'
class Outputs:
170class Outputs:
171    """
172    Output Extensions.
173
174    """
175
176    IMAGE = "img.jpg"
177    METRICS = "metrics.json"
178    VIDEO_CLIP = "video.mp4"
179    VISUAL3D = "visual_3d.html"

Output Extensions.

IMAGE = 'img.jpg'
METRICS = 'metrics.json'
VIDEO_CLIP = 'video.mp4'
VISUAL3D = 'visual_3d.html'
class GrafSelectionMethod:
182class GrafSelectionMethod:
183    """
184    Graf Frame Selection Methods.
185    """
186
187    MANUAL_FEATURES = "manual_features"
188    OBJ_CLASSIFY = "obj_classify"

Graf Frame Selection Methods.

MANUAL_FEATURES = 'manual_features'
OBJ_CLASSIFY = 'obj_classify'