retuve.hip_us.classes.dev

Developer metrics for Ultrasound Analysis

 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"""
16Developer metrics for Ultrasound Analysis
17"""
18
19from typing import Dict, List
20
21
22class DevMetricsUS:
23    def __init__(self):
24        """
25        Class to store the metrics of the development of the US segmentation
26
27        :attr os_ichium_detected: bool: True if the os_ichium is detected
28        :attr no_frames_segmented: int: Number of frames segmented
29        :attr no_frames_marked: int: Number of frames marked
30        :attr graf_frame: int: Frame where the Graf angle is calculated
31        :attr acetabular_mid_frame: int: Frame where the acetabular midline is calculated
32        :attr fem_mid_frame: int: Frame where the femoral midline is calculated
33        :attr critial_error: bool: True if a critical error is detected
34        :attr cr_points: list: List of critical points detected
35        :attr total_frames: int: Total number of frames in
36        """
37        self.os_ichium_detected = False
38        self.no_frames_segmented = 0
39        self.no_frames_marked = 0
40        self.graf_frame = 0
41        self.acetabular_mid_frame = 0
42        self.fem_mid_frame = 0
43        self.critial_error = False
44        self.cr_points = []
45        self.total_frames = 0
46
47    def __repr__(self) -> str:
48        return (
49            f"DevMetricsUS(os_ichium_detected={self.os_ichium_detected}, "
50            f"no_frames_segmented={self.no_frames_segmented}, "
51            f"no_frames_marked={self.no_frames_marked}, "
52            f"graf_frame={self.graf_frame}, "
53            f"acetabular_mid_frame={self.acetabular_mid_frame}, "
54            f"fem_mid_frame={self.fem_mid_frame}, "
55            f"critial_error={self.critial_error}, "
56            f"cr_points={self.cr_points}, "
57            f"total_frames={self.total_frames})"
58        )
59
60    def data(self) -> List:
61        """
62        Return the data of the class
63
64        :return: List of the data of the class
65        """
66        return [
67            self.os_ichium_detected,
68            self.no_frames_segmented,
69            self.no_frames_marked,
70            self.graf_frame,
71            self.acetabular_mid_frame,
72            self.fem_mid_frame,
73            self.critial_error,
74            self.cr_points,
75            self.total_frames,
76        ]
77
78    def json_dump(self) -> Dict[str, List]:
79        """
80        Return the data of the class in a dictionary
81
82        Useful for saving the data in a json file, or the return of an API call.
83
84        :return: Dictionary of the data of the class
85        """
86        return {
87            "os_ichium_detected": self.os_ichium_detected,
88            "no_frames_segmented": self.no_frames_segmented,
89            "no_frames_marked": self.no_frames_marked,
90            "graf_frame": self.graf_frame,
91            "acetabular_mid_frame": self.acetabular_mid_frame,
92            "fem_mid_frame": self.fem_mid_frame,
93            "critial_error": self.critial_error,
94            "cr_points": self.cr_points,
95            "total_frames": self.total_frames,
96        }
class DevMetricsUS:
23class DevMetricsUS:
24    def __init__(self):
25        """
26        Class to store the metrics of the development of the US segmentation
27
28        :attr os_ichium_detected: bool: True if the os_ichium is detected
29        :attr no_frames_segmented: int: Number of frames segmented
30        :attr no_frames_marked: int: Number of frames marked
31        :attr graf_frame: int: Frame where the Graf angle is calculated
32        :attr acetabular_mid_frame: int: Frame where the acetabular midline is calculated
33        :attr fem_mid_frame: int: Frame where the femoral midline is calculated
34        :attr critial_error: bool: True if a critical error is detected
35        :attr cr_points: list: List of critical points detected
36        :attr total_frames: int: Total number of frames in
37        """
38        self.os_ichium_detected = False
39        self.no_frames_segmented = 0
40        self.no_frames_marked = 0
41        self.graf_frame = 0
42        self.acetabular_mid_frame = 0
43        self.fem_mid_frame = 0
44        self.critial_error = False
45        self.cr_points = []
46        self.total_frames = 0
47
48    def __repr__(self) -> str:
49        return (
50            f"DevMetricsUS(os_ichium_detected={self.os_ichium_detected}, "
51            f"no_frames_segmented={self.no_frames_segmented}, "
52            f"no_frames_marked={self.no_frames_marked}, "
53            f"graf_frame={self.graf_frame}, "
54            f"acetabular_mid_frame={self.acetabular_mid_frame}, "
55            f"fem_mid_frame={self.fem_mid_frame}, "
56            f"critial_error={self.critial_error}, "
57            f"cr_points={self.cr_points}, "
58            f"total_frames={self.total_frames})"
59        )
60
61    def data(self) -> List:
62        """
63        Return the data of the class
64
65        :return: List of the data of the class
66        """
67        return [
68            self.os_ichium_detected,
69            self.no_frames_segmented,
70            self.no_frames_marked,
71            self.graf_frame,
72            self.acetabular_mid_frame,
73            self.fem_mid_frame,
74            self.critial_error,
75            self.cr_points,
76            self.total_frames,
77        ]
78
79    def json_dump(self) -> Dict[str, List]:
80        """
81        Return the data of the class in a dictionary
82
83        Useful for saving the data in a json file, or the return of an API call.
84
85        :return: Dictionary of the data of the class
86        """
87        return {
88            "os_ichium_detected": self.os_ichium_detected,
89            "no_frames_segmented": self.no_frames_segmented,
90            "no_frames_marked": self.no_frames_marked,
91            "graf_frame": self.graf_frame,
92            "acetabular_mid_frame": self.acetabular_mid_frame,
93            "fem_mid_frame": self.fem_mid_frame,
94            "critial_error": self.critial_error,
95            "cr_points": self.cr_points,
96            "total_frames": self.total_frames,
97        }
DevMetricsUS()
24    def __init__(self):
25        """
26        Class to store the metrics of the development of the US segmentation
27
28        :attr os_ichium_detected: bool: True if the os_ichium is detected
29        :attr no_frames_segmented: int: Number of frames segmented
30        :attr no_frames_marked: int: Number of frames marked
31        :attr graf_frame: int: Frame where the Graf angle is calculated
32        :attr acetabular_mid_frame: int: Frame where the acetabular midline is calculated
33        :attr fem_mid_frame: int: Frame where the femoral midline is calculated
34        :attr critial_error: bool: True if a critical error is detected
35        :attr cr_points: list: List of critical points detected
36        :attr total_frames: int: Total number of frames in
37        """
38        self.os_ichium_detected = False
39        self.no_frames_segmented = 0
40        self.no_frames_marked = 0
41        self.graf_frame = 0
42        self.acetabular_mid_frame = 0
43        self.fem_mid_frame = 0
44        self.critial_error = False
45        self.cr_points = []
46        self.total_frames = 0

Class to store the metrics of the development of the US segmentation

:attr os_ichium_detected: bool: True if the os_ichium is detected :attr no_frames_segmented: int: Number of frames segmented :attr no_frames_marked: int: Number of frames marked :attr graf_frame: int: Frame where the Graf angle is calculated :attr acetabular_mid_frame: int: Frame where the acetabular midline is calculated :attr fem_mid_frame: int: Frame where the femoral midline is calculated :attr critial_error: bool: True if a critical error is detected :attr cr_points: list: List of critical points detected :attr total_frames: int: Total number of frames in

os_ichium_detected
no_frames_segmented
no_frames_marked
graf_frame
acetabular_mid_frame
fem_mid_frame
critial_error
cr_points
total_frames
def data(self) -> List:
61    def data(self) -> List:
62        """
63        Return the data of the class
64
65        :return: List of the data of the class
66        """
67        return [
68            self.os_ichium_detected,
69            self.no_frames_segmented,
70            self.no_frames_marked,
71            self.graf_frame,
72            self.acetabular_mid_frame,
73            self.fem_mid_frame,
74            self.critial_error,
75            self.cr_points,
76            self.total_frames,
77        ]

Return the data of the class

Returns

List of the data of the class

def json_dump(self) -> Dict[str, List]:
79    def json_dump(self) -> Dict[str, List]:
80        """
81        Return the data of the class in a dictionary
82
83        Useful for saving the data in a json file, or the return of an API call.
84
85        :return: Dictionary of the data of the class
86        """
87        return {
88            "os_ichium_detected": self.os_ichium_detected,
89            "no_frames_segmented": self.no_frames_segmented,
90            "no_frames_marked": self.no_frames_marked,
91            "graf_frame": self.graf_frame,
92            "acetabular_mid_frame": self.acetabular_mid_frame,
93            "fem_mid_frame": self.fem_mid_frame,
94            "critial_error": self.critial_error,
95            "cr_points": self.cr_points,
96            "total_frames": self.total_frames,
97        }

Return the data of the class in a dictionary

Useful for saving the data in a json file, or the return of an API call.

Returns

Dictionary of the data of the class