-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_excluded_grouping.py
More file actions
150 lines (125 loc) Β· 5.51 KB
/
test_excluded_grouping.py
File metadata and controls
150 lines (125 loc) Β· 5.51 KB
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
"""
Test script to demonstrate the Excluded Files group in the file tree
"""
import sys
import os
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from core.models import PatientData, FileData, DataType
def test_excluded_files_grouping():
"""Test that excluded files are grouped separately"""
print("=" * 70)
print("Testing Excluded Files Grouping")
print("=" * 70)
print()
# Create test patient data with mixed excluded/normal files
patient = PatientData(
patient_id="TEST_GROUPING",
folder_path="C:/test"
)
# CBCT files - one normal, one excluded
patient.cbct_files = [
FileData(path="C:/test/cbct1.dcm", data_type=DataType.CBCT_DICOM),
FileData(path="C:/test/cbct2.dcm", data_type=DataType.EXCLUDE),
FileData(path="C:/test/cbct3.dcm", data_type=DataType.CBCT_DICOM),
]
# IOS files
patient.ios_upper = FileData(path="C:/test/upper.stl", data_type=DataType.IOS_UPPER)
patient.ios_lower = FileData(path="C:/test/lower.stl", data_type=DataType.EXCLUDE)
# Intraoral photos - mix of normal and excluded
patient.intraoral_photos = [
FileData(path="C:/test/photo1.jpg", data_type=DataType.INTRAORAL_PHOTO),
FileData(path="C:/test/photo2.jpg", data_type=DataType.INTRAORAL_PHOTO),
FileData(path="C:/test/photo3.jpg", data_type=DataType.EXCLUDE),
FileData(path="C:/test/photo4.jpg", data_type=DataType.INTRAORAL_PHOTO),
FileData(path="C:/test/photo5.jpg", data_type=DataType.EXCLUDE),
]
# Teleradiography - excluded
patient.teleradiography = FileData(path="C:/test/xray.jpg", data_type=DataType.EXCLUDE)
# Orthopantomography - normal
patient.orthopantomography = FileData(path="C:/test/panoramic.jpg", data_type=DataType.ORTHOPANTOMOGRAPHY)
# Simulate the filtering logic from populate_files_tree
print("π File Distribution Analysis:")
print("-" * 70)
# Count files by category
regular_groups = {
"π¦· CBCT DICOM": [],
"π IOS Upper": [],
"π½ IOS Lower": [],
"πΈ Intraoral Photos": [],
"π» Teleradiography": [],
"π¬ Orthopantomography": []
}
excluded_files = []
# Process CBCT
for cbct in patient.cbct_files:
if cbct.data_type == DataType.EXCLUDE:
excluded_files.append(("CBCT", cbct.path))
else:
regular_groups["π¦· CBCT DICOM"].append(cbct.path)
# Process IOS
if patient.ios_upper:
if patient.ios_upper.data_type == DataType.EXCLUDE:
excluded_files.append(("IOS Upper", patient.ios_upper.path))
else:
regular_groups["π IOS Upper"].append(patient.ios_upper.path)
if patient.ios_lower:
if patient.ios_lower.data_type == DataType.EXCLUDE:
excluded_files.append(("IOS Lower", patient.ios_lower.path))
else:
regular_groups["π½ IOS Lower"].append(patient.ios_lower.path)
# Process intraoral photos
for photo in patient.intraoral_photos:
if photo.data_type == DataType.EXCLUDE:
excluded_files.append(("Intraoral Photo", photo.path))
else:
regular_groups["πΈ Intraoral Photos"].append(photo.path)
# Process teleradiography
if patient.teleradiography:
if patient.teleradiography.data_type == DataType.EXCLUDE:
excluded_files.append(("Teleradiography", patient.teleradiography.path))
else:
regular_groups["π» Teleradiography"].append(patient.teleradiography.path)
# Process orthopantomography
if patient.orthopantomography:
if patient.orthopantomography.data_type == DataType.EXCLUDE:
excluded_files.append(("Orthopantomography", patient.orthopantomography.path))
else:
regular_groups["π¬ Orthopantomography"].append(patient.orthopantomography.path)
# Display regular groups
print("\nπ REGULAR FILE GROUPS:")
print("-" * 70)
total_regular = 0
for group_name, files in regular_groups.items():
if files:
print(f"\n{group_name} ({len(files)} files):")
for file_path in files:
print(f" β {os.path.basename(file_path)}")
total_regular += len(files)
# Display excluded group
print("\n\nπ« EXCLUDED FILES GROUP:")
print("-" * 70)
if excluded_files:
print(f"\nπ« Excluded Files ({len(excluded_files)} files):")
for original_type, file_path in excluded_files:
print(f" π« {os.path.basename(file_path):20} (was: {original_type})")
else:
print(" (No excluded files)")
print("\n" + "=" * 70)
print("π SUMMARY:")
print("-" * 70)
print(f" Regular Files: {total_regular} files (will be uploaded)")
print(f" Excluded Files: {len(excluded_files)} files (will NOT be uploaded)")
print(f" Total Files: {total_regular + len(excluded_files)} files")
print("=" * 70)
print()
print("β¨ Key Benefits of Separate Excluded Group:")
print("-" * 70)
print(" 1. Clear visual separation of excluded vs. active files")
print(" 2. Easy to see how many files are excluded at a glance")
print(" 3. Grouped by exclusion status rather than original type")
print(" 4. Cleaner display - no 'EXCLUDED' labels in regular groups")
print(" 5. All excluded files in one place for review")
print("-" * 70)
if __name__ == "__main__":
test_excluded_files_grouping()