Skip to content

oxytcmri.interface.controllers

Classes:

Name Description
Controller

Controller(persistence_gateway, importers, listeners=None, overwrite_database=False)

Initialize the controller.

Parameters:

persistence_gateway: DataBaseGateway The persistence gateway for database operations. importers: list[Importer] List of importers to use for importing data. listeners: list[Listener], optional List of listeners for event dispatching. overwrite_database: bool, optional If True, the database will be overwritten with the imported data. Default is False.

Methods:

Name Description
compute_normative_dti_values
segment_dti_abnormal_values

Segment DTI abnormal values using the C3DSTAPLE algorithm.

compute_brain_lesions_volumes

Compute brain lesions volumes for the specified DTI metrics and MRI exam.

Attributes:

Name Type Description
overwrite_database
event_dispatcher
repository_registry
Source code in oxytcmri/interface/controllers.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def __init__(self,
             persistence_gateway: DataBaseGateway,
             importers: list[Importer],
             listeners: Optional[list[Listener]] = None,
             overwrite_database: bool = False):
    """
    Initialize the controller.

    Parameters:
    -----------
    persistence_gateway: DataBaseGateway
        The persistence gateway for database operations.
    importers: list[Importer]
        List of importers to use for importing data.
    listeners: list[Listener], optional
        List of listeners for event dispatching.
    overwrite_database: bool, optional
        If True, the database will be overwritten with the imported data.
        Default is False.
    """
    self.overwrite_database = overwrite_database

    # event dispatcher
    self.event_dispatcher = EventDispatcher()
    if listeners is not None:
        for listener in listeners:
            self.event_dispatcher.register(listener)

    # create repositories
    self.repository_registry = DataBaseRepositoriesRegistry(persistence_gateway)

    # import data from files
    for importer in importers:
        importer.register_repository(self.repository_registry.list_all_repositories())
        importer.import_data()

overwrite_database = overwrite_database instance-attribute

event_dispatcher = EventDispatcher() instance-attribute

repository_registry = DataBaseRepositoriesRegistry(persistence_gateway) instance-attribute

compute_normative_dti_values(dti_metrics=None, statistics_strategies=None)

Source code in oxytcmri/interface/controllers.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def compute_normative_dti_values(self,
                                 dti_metrics: Optional[list[DTIMetric]] = None,
                                 statistics_strategies: Optional[list[StatisticStrategy]] = None):

    # default values
    dti_metrics = dti_metrics or list(DTIMetric)
    statistics_strategies = statistics_strategies or StatisticsStrategies.all()
    compute_normative_dti_values = ComputeDTINormativeValues(
        repositories_registry=self.repository_registry,
        dispatcher=self.event_dispatcher
    )
    compute_normative_dti_values(
        dti_metrics=dti_metrics,
        statistics_strategies=statistics_strategies,)

segment_dti_abnormal_values(dti_metrics=None, mri_exam_id=None)

Segment DTI abnormal values using the C3DSTAPLE algorithm.

Parameters:

dti_metrics: Optional[list[DTIMetric]] List of DTI metrics to segment. If None, all available metrics will be used. mri_exam_id: Optional[MRIExamId] ID of the MRI exam to segment. If None, all available exams will be used.

Source code in oxytcmri/interface/controllers.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
def segment_dti_abnormal_values(self,
                                dti_metrics: Optional[list[DTIMetric]] = None,
                                mri_exam_id: Optional[MRIExamId] = None):
    """
    Segment DTI abnormal values using the C3DSTAPLE algorithm.

    Parameters:
    ----------
    dti_metrics: Optional[list[DTIMetric]]
        List of DTI metrics to segment. If None, all available metrics will be used.
    mri_exam_id: Optional[MRIExamId]
        ID of the MRI exam to segment. If None, all available exams will be used.
    """
    # create the use case
    segment_dti_abnormal_values = SegmentDTIAbnormalValues(
        repositories_registry=self.repository_registry,
        segmentation_merger=C3DSTAPLESegmentationMerger(),
        dispatcher=self.event_dispatcher
    )

    # run the use case
    segment_dti_abnormal_values(
        dti_metrics=dti_metrics,
        mri_exam_id=mri_exam_id
    )

compute_brain_lesions_volumes(dti_metrics=None, mri_exam_id=None, regions_of_interest=None)

Compute brain lesions volumes for the specified DTI metrics and MRI exam.

Source code in oxytcmri/interface/controllers.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def compute_brain_lesions_volumes(self,
                                  dti_metrics: Optional[list[DTIMetric]] = None,
                                  mri_exam_id: Optional[MRIExamId] = None,
                                  regions_of_interest: Optional[list[RegionOfInterest]] = None):
    """
    Compute brain lesions volumes for the specified DTI metrics and MRI exam.
    """
    # create the use case
    compute_brain_lesions_volumes = ComputeBrainLesionsVolumes(
        repositories_registry=self.repository_registry,
        dispatcher=self.event_dispatcher
    )

    # run the use case
    compute_brain_lesions_volumes(
        dti_metrics=dti_metrics,
        mri_exam_id=mri_exam_id,
        regions_of_interest=regions_of_interest
    )