Skip to content

Commit bafef2a

Browse files
authored
Create read.py
wrap readFileOpt in a python function
1 parent 67d837d commit bafef2a

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

octdata4python/core/read.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from pathlib import Path
2+
from typing import Literal
3+
from .octdata4python import readFileOpt
4+
5+
def read_file(
6+
path: str | Path,
7+
fill_empty_pixel_white: bool = True,
8+
register_bscans: bool = True,
9+
rotate_slo: bool = False,
10+
hold_raw_data: bool = False,
11+
load_ref_files: bool = True,
12+
read_bscans: bool = True,
13+
read_bscan_num: int = -1,
14+
e2e_gray_transform: Literal["nativ", "u16", "vol", "xml"] = "xml",
15+
xor_test: list | None = None,
16+
) -> None:
17+
"""
18+
Reads an OCT (Optical Coherence Tomography) data file using `octdata4python.readFileOpt`.
19+
20+
Parameters
21+
----------
22+
path : str or Path
23+
Path to the OCT data file.
24+
25+
fill_empty_pixel_white : bool, optional
26+
Whether to fill empty pixels with white (True by default).
27+
28+
register_bscans : bool, optional
29+
??? (True by default).
30+
31+
rotate_slo : bool, optional
32+
Whether to rotate SLO image. Applies **only** when reading .e2e or .sdb formats (False by default).
33+
34+
hold_raw_data : bool, optional
35+
??? (False by default).
36+
37+
load_ref_files : bool, optional
38+
Param unused by backend lib (True by default).
39+
40+
read_bscans : bool, optional
41+
Whether to read B-scan data (True by default).
42+
43+
read_bscan_num : int, optional
44+
Index of a specific B-scan to read. Applies **only** when reading dicoms (default is -1).
45+
46+
e2e_gray_transform : {"nativ", "u16", "vol", "xml"}, optional
47+
Method used to perform grayscale transformation for .e2e and .sdb formats. Default is "xml".
48+
49+
xor_test : list, optional
50+
Optional list of XOR values for test or debug purposes. If None, an empty list is used.
51+
"""
52+
if not xor_test:
53+
xor_test = []
54+
return readFileOpt(
55+
str(Path(path)),
56+
{
57+
"fillEmptyPixelWhite": fill_empty_pixel_white,
58+
"registerBScanns": register_bscans,
59+
"rotateSlo": rotate_slo,
60+
"holdRawData": hold_raw_data,
61+
"loadRefFiles": load_ref_files,
62+
"readBScans": read_bscans,
63+
"readBScanNum": read_bscan_num,
64+
"e2eGrayTransform": e2e_gray_transform,
65+
"xor_test": xor_test,
66+
},
67+
)

0 commit comments

Comments
 (0)