Skip to content

Commit 149ed67

Browse files
committed
add warning
1 parent c2487ce commit 149ed67

2 files changed

Lines changed: 99 additions & 2 deletions

File tree

src/cardiotensor/__init__.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
"""
2+
cardiotensor — 3D cardiomyocyte orientation analysis from volumetric imaging.
3+
4+
Core usage
5+
----------
6+
>>> from cardiotensor import compute_orientation, DataReader
7+
>>> reader = DataReader("path/to/images")
8+
>>> compute_orientation("path/to/images", output_dir="output", sigma=3.0, rho=1.0)
9+
10+
Sub-module imports
11+
------------------
12+
For tractography::
13+
14+
from cardiotensor.tractography import (
15+
generate_streamlines_from_vector_field,
16+
generate_streamlines_from_params,
17+
)
18+
19+
For I/O utilities::
20+
21+
from cardiotensor.utils import (
22+
read_conf_file,
23+
load_npz_streamlines,
24+
load_trk_streamlines,
25+
write_spatialgraph_am,
26+
export_vector_field_to_vtk,
27+
)
28+
29+
For analysis::
30+
31+
from cardiotensor.analysis import calculate_intensities, find_end_points
32+
33+
For visualization (requires a display)::
34+
35+
from cardiotensor.visualization import visualize_streamlines, visualize_vector_field
36+
"""
37+
38+
# --- Core ---
39+
from cardiotensor.orientation.orientation_computation_pipeline import compute_orientation
40+
from cardiotensor.utils.DataReader import DataReader
41+
from cardiotensor.utils.utils import convert_to_8bit, read_conf_file
42+
43+
# --- Orientation ---
44+
from cardiotensor.orientation.orientation_computation_functions import (
45+
calculate_structure_tensor,
46+
compute_fraction_anisotropy,
47+
compute_helix_and_transverse_angles,
48+
)
49+
50+
# --- Tractography ---
51+
from cardiotensor.tractography.generate_streamlines import (
52+
generate_streamlines_from_params,
53+
generate_streamlines_from_vector_field,
54+
)
55+
56+
# --- I/O ---
57+
from cardiotensor.utils.am_utils import write_spatialgraph_am
58+
from cardiotensor.utils.streamlines_io_utils import (
59+
load_npz_streamlines,
60+
load_trk_streamlines,
61+
)
62+
from cardiotensor.utils.vector_vtk_export import export_vector_field_to_vtk
63+
64+
# --- Analysis ---
65+
from cardiotensor.analysis.analysis_functions import (
66+
calculate_intensities,
67+
find_end_points,
68+
save_intensity,
69+
)
70+
71+
__all__ = [
72+
# Core
73+
"compute_orientation",
74+
"DataReader",
75+
"read_conf_file",
76+
"convert_to_8bit",
77+
# Orientation
78+
"calculate_structure_tensor",
79+
"compute_fraction_anisotropy",
80+
"compute_helix_and_transverse_angles",
81+
# Tractography
82+
"generate_streamlines_from_vector_field",
83+
"generate_streamlines_from_params",
84+
# I/O
85+
"write_spatialgraph_am",
86+
"load_npz_streamlines",
87+
"load_trk_streamlines",
88+
"export_vector_field_to_vtk",
89+
# Analysis
90+
"calculate_intensities",
91+
"find_end_points",
92+
"save_intensity",
93+
]

src/cardiotensor/utils/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,15 @@ def parse_coordinates(section: str, option: str, fallback: str = ""):
121121
}
122122

123123

124-
# Function to remove files smaller than 1KB
125124
def remove_corrupted_files(file_paths, size_threshold=200):
125+
import warnings
126126
for file_path in file_paths:
127127
if os.path.exists(file_path) and os.path.getsize(file_path) < size_threshold:
128-
print("Corrupted file removed:", file_path)
128+
warnings.warn(
129+
f"Removing potentially corrupted file (size < {size_threshold} bytes): {file_path}",
130+
UserWarning,
131+
stacklevel=2,
132+
)
129133
os.remove(file_path)
130134

131135

0 commit comments

Comments
 (0)