-
Notifications
You must be signed in to change notification settings - Fork 7
/
config.py
170 lines (136 loc) · 6.45 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Copyright 2022 SECTRA AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Optional
from PIL import Image as Pillow
class Settings:
"""Class containing settings. Settings are to be accessed through the
global variable settings."""
def __init__(self) -> None:
self._strict_uid_check = False
self._strict_tile_size_check = True
self._strict_attribute_check = False
self._strict_specimen_identifier_check = True
self._focal_plane_distance_threshold = 0.000001
self._pyramids_origin_threshold = 0.02
self._prefered_decoder: Optional[str] = None
self._open_web_theads: Optional[int] = None
self._pillow_resampling_filter = Pillow.Resampling.BILINEAR
self._ignore_specimen_preparation_step_on_validation_error = True
self._truncate_long_dicom_strings = False
self._decoded_frame_cache_size = 1000
self._encoded_frame_cache_size = 1000
@property
def strict_uid_check(self) -> bool:
"""If frame of reference uid needs to match."""
return self._strict_uid_check
@strict_uid_check.setter
def strict_uid_check(self, value: bool) -> None:
self._strict_uid_check = value
@property
def strict_attribute_check(self) -> bool:
"""If attribute marked with Requirement.STRICT is required."""
return self._strict_attribute_check
@strict_attribute_check.setter
def strict_attribute_check(self, value: bool) -> None:
self._strict_attribute_check = value
@property
def strict_specimen_identifier_check(self) -> bool:
"""If `True` the issuer of two specimen identifiers needs to match or both be
None for the identifiers to match. If `False` the identifiers will match also if
either issuer is None. Either way the identifier needs to match."""
return self._strict_specimen_identifier_check
@strict_specimen_identifier_check.setter
def strict_specimen_identifier_check(self, value: bool) -> None:
self._strict_specimen_identifier_check = value
@property
def strict_tile_size_check(self) -> bool:
"""If tile size need to match for levels. If `False` the tile size accross
levels are allowed to be non-uniform."""
return self._strict_tile_size_check
@strict_tile_size_check.setter
def strict_tile_size_check(self, value: bool) -> None:
self._strict_tile_size_check = value
@property
def focal_plane_distance_threshold(self) -> float:
"""Threshold in mm for which distances between focal planes are
considered to be equal. Default is 1 nm, as distance between focal
planes are likely larger than this.
"""
return self._focal_plane_distance_threshold
@focal_plane_distance_threshold.setter
def focal_plane_distance_threshold(self, value: float) -> None:
self._focal_plane_distance_threshold = value
@property
def pyramids_origin_threshold(self) -> float:
"""Threshold in mm for the distance between origins of instances
to group them into the same pyramid. Default is 0.02 mm.
"""
return self._pyramids_origin_threshold
@pyramids_origin_threshold.setter
def pyramids_origin_threshold(self, value: float) -> None:
self._pyramids_origin_threshold = value
@property
def prefered_decoder(self) -> Optional[str]:
"""Name of preferred decoder to use."""
return self._prefered_decoder
@prefered_decoder.setter
def prefered_decoder(self, value: Optional[str]) -> None:
self._prefered_decoder = value
@property
def open_web_theads(self) -> Optional[int]:
"""Number of threads to use when opening web instances."""
return self._open_web_theads
@open_web_theads.setter
def open_web_theads(self, value: Optional[int]) -> None:
self._open_web_theads = value
@property
def pillow_resampling_filter(self) -> Pillow.Resampling:
"""The resampling filter to use when rescaling images."""
return self._pillow_resampling_filter
@pillow_resampling_filter.setter
def pillow_resampling_filter(self, value: Pillow.Resampling) -> None:
self._pillow_resampling_filter = value
@property
def ignore_specimen_preparation_step_on_validation_error(self) -> bool:
"""If ignore specimen preparation steps that fails to validate. If false all
steps will be ignored if one fails to validate."""
return self._ignore_specimen_preparation_step_on_validation_error
@ignore_specimen_preparation_step_on_validation_error.setter
def ignore_specimen_preparation_step_on_validation_error(self, value: bool) -> None:
self._ignore_specimen_preparation_step_on_validation_error = value
@property
def truncate_long_dicom_strings_on_validation_error(self) -> bool:
"""If long DICOM strings should be truncated. This is only used if
`pydicom.settings.writing_validation_mode` is set to `pydicom.config.RAISE`. If
set to `True` long strings will be truncated if needed to pass validation."""
return self._truncate_long_dicom_strings
@truncate_long_dicom_strings_on_validation_error.setter
def truncate_long_dicom_strings_on_validation_error(self, value: bool) -> None:
self._truncate_long_dicom_strings = value
@property
def decoded_frame_cache_size(self) -> int:
"""Size of the decoded frame cache."""
return self._decoded_frame_cache_size
@decoded_frame_cache_size.setter
def decoded_frame_cache_size(self, value: int) -> None:
self._decoded_frame_cache_size = value
@property
def encoded_frame_cache_size(self) -> int:
"""Size of the encoded frame cache."""
return self._encoded_frame_cache_size
@encoded_frame_cache_size.setter
def encoded_frame_cache_size(self, value: int) -> None:
self._encoded_frame_cache_size = value
settings = Settings()
"""Global settings variable."""