API 参考
注意(私有元素)
此模块包含以下划线开头的“私有”类/函数。默认情况下,它们的详细信息不会包含在文档中。
完整包
ISD 读取器包
此包解析 ISD 文件夹中的 Description.xml 文件,并将相应的二进制图像数据转换为具有相应数据类型(uint8/16/32)的 NumPy 二维数组。
此包包含: - IsdReader:读取 ISD 数据集的主要入口点,即包含 ISD 数据本身的对象类。 - 用于处理各种错误的异常类
使用示例:
from isdreader import IsdReader isd = IsdReader(isd_path="/path/to/folder.isd") ch = isd.GetCh(1) dg = ch.GetDataGate(2) img = dg.GetImage("AP") arr = img.load_image() 其中,arr 是一个 NumPy 二维数组。
BinaryFileNotFound
Bases: Exception
如果在 ISD 文件夹中找不到指定的二进制文件,则会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
55 56 57 58 59 | |
DescriptionNotFound
Bases: Exception
如果在 ISD 文件夹中找不到 Description.xml 文件,则会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
41 42 43 44 45 | |
InvalidChannel
Bases: Exception
当指定的通道索引无效时,会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
13 14 15 16 17 | |
InvalidDataGate
Bases: Exception
当指定的数据门索引无效时,会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
20 21 22 23 24 | |
IsdNotFound
Bases: Exception
当指定的 ISD 文件夹不存在时,会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
34 35 36 37 38 | |
IsdReader
代表整个 ISD 文件夹的根类 此类是访问 ISD 采集数据集中所有通道、数据门和图像的主要入口点。 换句话说,它是一个包含整个 ISD 数据的对象类。 属性: path:要包含的 ISD 文件夹的路径 description_path:Description.xml 文件的路径(位于 ISD 文件夹下) logger:此对象的日志记录器实例
Source code in .build\zh\isdreader\isd_root.py
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 | |
GetCh(ch=None)
获取 ChChunk 实例或列出所有频道。 参数: ch:None 或指定的 ChChunk 编号 返回值: 如果 ch 为 None,则返回可用频道编号列表;否则,返回指定的 ChChunk 或 None。
Source code in .build\zh\isdreader\isd_root.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
GetImage(*, ch, gate, image_type, slice_no=1)
直接检索 ImageChunk 的方法 参数: ch:通道号(1 为起始值) gate:数据门编号(1 为起始值) image_type:图像类型(缩写或全称) slice_no:切片编号(1 为起始值,默认值:1) 返回值: 找到符合指定条件的 ImageChunk 实例;否则,返回 None
Source code in .build\zh\isdreader\isd_root.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
__init__(*, isd_path, logger=None)
根据 ISD 文件夹参数初始化 IsdReader 对象。 参数: isd_path:ISD 文件夹的路径(字符串或 pathlib.Path)。 logger:可选的日志记录器实例。如果为 None,则使用默认日志记录器。 异常: TypeError:如果 isd_path 不是字符串或 Path 类型。 IsdNotFound:如果 ISD 文件夹不存在。 DescriptionNotFound:如果在 ISD 文件夹中找不到 Description.xml 文件。
Source code in .build\zh\isdreader\isd_root.py
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 | |
__repr__()
此函数返回 IsdReader 的字符串摘要。 返回值: 包含大小和可用通道数的字符串。
Source code in .build\zh\isdreader\isd_root.py
85 86 87 88 89 90 91 92 93 94 95 96 97 | |
主要模块
ChChunk
表示一个通道的类,该通道可能包含多个数据门。 此类对应于采集系统中的物理超声通道。
Source code in .build\zh\isdreader\chunks.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
GetDataGate(data_gate=None)
检索 DataGateChunk 实例或列出所有 DataGate。 参数: data_gate:如果为 None,则列出 DataGate 编号;否则,返回相应的 DataGateChunk。 返回值: 如果 data_gate 为 None,则返回 DataGate 编号列表;否则,返回 DataGateChunk 实例或 None。
Source code in .build\zh\isdreader\chunks.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
__init__(root_elem, ch_elem, isd_root, width, height)
初始化 ChChunk 实例。 参数: root_elem:Description.xml 的根 XML 元素 ch_elem:通道 XML 元素 isd_root:ISD 文件夹根路径 width:图像宽度(像素) height:图像高度(像素)
Source code in .build\zh\isdreader\chunks.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
__repr__()
返回此 ChChunk 的字符串摘要。 返回值: 包含通道号、名称和数据门的字符串表示形式。
Source code in .build\zh\isdreader\chunks.py
401 402 403 404 405 406 407 | |
list_datagates()
列出所有可用的 DataGate 编号。 返回值: DataGate 编号列表(1 个来源)
Source code in .build\zh\isdreader\chunks.py
377 378 379 380 381 382 383 | |
DataGateChunk
表示通道内数据门的类。 请注意,一个数据门可以包含多个切片图像。
Source code in .build\zh\isdreader\chunks.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
GetImage(image_type, slice_no=1)
返回指定类型和切片的 ImageChunk 实例。 参数: image_type:图像类型(缩写或全称) slice_no:切片编号(1 为默认值,默认值为 1) 返回值: 如果找到 ImageChunk 实例,则返回该实例;否则返回 None。
Source code in .build\zh\isdreader\chunks.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |
GetSlice(slice_no=None)
列出所有切片。 参数: slice_no:如果为 None,则列出所有切片编号;否则,将发生 TypeError。 返回值: 如果 slice_no 为 None,则列出切片编号。 异常: TypeError:如果指定了 slice_no。
Source code in .build\zh\isdreader\chunks.py
288 289 290 291 292 293 294 295 296 297 298 299 300 | |
ImageTypes()
返回一个描述可用图像类型的字符串。 返回值: 以逗号分隔的图像类型缩写和全称字符串。
Source code in .build\zh\isdreader\chunks.py
302 303 304 305 306 307 308 | |
__init__(root_elem, ch_elem, dg_elem, isd_root, ch_public, ch_name, width, height, sampling_freq_mhz)
初始化 DataGateChunk 实例 参数: root_elem:Description.xml 的根 XML 元素 ch_elem:通道 XML 元素 dg_elem:数据门 XML 元素 isd_root:ISD 文件夹根路径 ch_public:公共通道号(1 为起始值) ch_name:通道名称 width:图像宽度(像素) height:图像高度(像素) sampling_freq_mhz:采样频率(MHz)
Source code in .build\zh\isdreader\chunks.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
__repr__()
此函数返回此 DataGateChunk 的字符串摘要。 返回值: 包含 ID、名称和可用图像的字符串表示形式。
Source code in .build\zh\isdreader\chunks.py
329 330 331 332 333 334 335 336 337 | |
list_images()
列出所有可用的切片编号(从 1 个原点开始)。 返回值: 切片编号列表。
Source code in .build\zh\isdreader\chunks.py
274 275 276 277 278 279 280 281 282 283 284 285 286 | |
ImageChunk
一个包含 DataGate 中单个图像数据(包括元数据)的类。 此类保存所有元数据,并提供对二进制图像数据的访问。
Source code in .build\zh\isdreader\chunks.py
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 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
img_array
property
访问已加载的图像数组。 返回值: 已加载的二维 NumPy 数组 异常: MiscellaneousError:如果图像尚未加载。
__init__(root_elem, ch_elem, dg_elem, img_elem, isd_root, ch_public, dg_xml_id, type_abbr, type_elem)
初始化此 ImageChunk 实例。 参数: root_elem:Description.xml 的根 XML 元素 ch_elem:通道 XML 元素 dg_elem:数据门 XML 元素 img_elem:图像 XML 元素 isd_root:ISD 文件夹根目录的路径 ch_public:公共通道号(1 源) dg_xml_id:数据门 XML ID 属性 type_abbr:图像类型缩写(例如“PP”、“AP”等) type_elem:特定图像类型的 XML 元素
Source code in .build\zh\isdreader\chunks.py
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 | |
__repr__()
此操作返回此 ImageChunk 的字符串摘要。 返回值: 包含所有注入属性的字符串表示形式。
Source code in .build\zh\isdreader\chunks.py
181 182 183 184 185 186 187 188 189 190 191 192 193 | |
build_metadata_args()
从 ImageChunk 属性构造要传递给 binary_loader 的参数。 返回值: 用于二进制加载的 (width, height, data_size) 元组。
Source code in .build\zh\isdreader\chunks.py
123 124 125 126 127 128 129 130 131 132 | |
load_image(y_flipped=True)
读取二进制图像数据并将其作为二维 NumPy 数组返回。 参数: y_flipped:如果为 True,则读取的图像将垂直翻转(默认值:True) 返回值: 二维 NumPy 图像数组 异常: MiscellaneousError:如果找不到图像文件名 BinaryFileNotFound:如果二进制文件不存在
Source code in .build\zh\isdreader\chunks.py
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 | |
CH_NUM_TO_LETTER = {1: 'A', 2: 'B', 3: 'C', 4: 'D'}
module-attribute
将缩写图像类型映射到全称
BinaryFileNotFound
Bases: Exception
如果在 ISD 文件夹中找不到指定的二进制文件,则会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
55 56 57 58 59 | |
DescriptionNotFound
Bases: Exception
如果在 ISD 文件夹中找不到 Description.xml 文件,则会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
41 42 43 44 45 | |
InsufficientMetaData
Bases: Exception
当元数据不足以继续处理时,会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
48 49 50 51 52 | |
InvalidChannel
Bases: Exception
当指定的通道索引无效时,会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
13 14 15 16 17 | |
InvalidDataGate
Bases: Exception
当指定的数据门索引无效时,会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
20 21 22 23 24 | |
InvalidSliceNo
Bases: Exception
当指定的切片编号无效时,会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
27 28 29 30 31 | |
IsdNotFound
Bases: Exception
当指定的 ISD 文件夹不存在时,会发生异常。
Source code in .build\zh\isdreader\isd_helper.py
34 35 36 37 38 | |
MiscellaneousError
Bases: Exception
因其他未知原因导致的例外情况
Source code in .build\zh\isdreader\isd_helper.py
62 63 64 65 66 | |
IsdReader
代表整个 ISD 文件夹的根类 此类是访问 ISD 采集数据集中所有通道、数据门和图像的主要入口点。 换句话说,它是一个包含整个 ISD 数据的对象类。 属性: path:要包含的 ISD 文件夹的路径 description_path:Description.xml 文件的路径(位于 ISD 文件夹下) logger:此对象的日志记录器实例
Source code in .build\zh\isdreader\isd_root.py
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 | |
GetCh(ch=None)
获取 ChChunk 实例或列出所有频道。 参数: ch:None 或指定的 ChChunk 编号 返回值: 如果 ch 为 None,则返回可用频道编号列表;否则,返回指定的 ChChunk 或 None。
Source code in .build\zh\isdreader\isd_root.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
GetImage(*, ch, gate, image_type, slice_no=1)
直接检索 ImageChunk 的方法 参数: ch:通道号(1 为起始值) gate:数据门编号(1 为起始值) image_type:图像类型(缩写或全称) slice_no:切片编号(1 为起始值,默认值:1) 返回值: 找到符合指定条件的 ImageChunk 实例;否则,返回 None
Source code in .build\zh\isdreader\isd_root.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
__init__(*, isd_path, logger=None)
根据 ISD 文件夹参数初始化 IsdReader 对象。 参数: isd_path:ISD 文件夹的路径(字符串或 pathlib.Path)。 logger:可选的日志记录器实例。如果为 None,则使用默认日志记录器。 异常: TypeError:如果 isd_path 不是字符串或 Path 类型。 IsdNotFound:如果 ISD 文件夹不存在。 DescriptionNotFound:如果在 ISD 文件夹中找不到 Description.xml 文件。
Source code in .build\zh\isdreader\isd_root.py
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 | |
__repr__()
此函数返回 IsdReader 的字符串摘要。 返回值: 包含大小和可用通道数的字符串。
Source code in .build\zh\isdreader\isd_root.py
85 86 87 88 89 90 91 92 93 94 95 96 97 | |