Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- centerline_extraction.py +4 -2
- server.py +10 -0
centerline_extraction.py
CHANGED
|
@@ -1024,8 +1024,10 @@ def parse_segments(centerlines):
|
|
| 1024 |
# Filter zero-length segments (noise)
|
| 1025 |
length = calculate_length(segment_points)
|
| 1026 |
if length > 0.0:
|
| 1027 |
-
|
| 1028 |
-
|
|
|
|
|
|
|
| 1029 |
segments.append({
|
| 1030 |
'label': 'Aorta',
|
| 1031 |
'points': segment_points,
|
|
|
|
| 1024 |
# Filter zero-length segments (noise)
|
| 1025 |
length = calculate_length(segment_points)
|
| 1026 |
if length > 0.0:
|
| 1027 |
+
# Map ALL points to their containing segment (not just start/end)
|
| 1028 |
+
# This ensures bifurcation points (interior to cells) can find connected segments in identify_abdominal_arteries
|
| 1029 |
+
for pt_entry in segment_points:
|
| 1030 |
+
point_to_segments[pt_entry['id']].append(seg_idx)
|
| 1031 |
segments.append({
|
| 1032 |
'label': 'Aorta',
|
| 1033 |
'points': segment_points,
|
server.py
CHANGED
|
@@ -61,6 +61,16 @@ def extract():
|
|
| 61 |
# Extract labelled segments and artery bifurcation data
|
| 62 |
data = extract_centerline_data(centerlines)
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
return jsonify({"status": "success", "data": data})
|
| 65 |
|
| 66 |
except Exception as e:
|
|
|
|
| 61 |
# Extract labelled segments and artery bifurcation data
|
| 62 |
data = extract_centerline_data(centerlines)
|
| 63 |
|
| 64 |
+
# Include the NRRD image's physical extent so the frontend can normalize the centerline
|
| 65 |
+
dims = image.GetDimensions()
|
| 66 |
+
spacing = image.GetSpacing()
|
| 67 |
+
phys_size = [dims[i] * spacing[i] for i in range(3)]
|
| 68 |
+
phys_center = [origin[i] + phys_size[i] / 2.0 for i in range(3)]
|
| 69 |
+
data['volume_info'] = {
|
| 70 |
+
'center': {'x': phys_center[0], 'y': phys_center[1], 'z': phys_center[2]},
|
| 71 |
+
'size': {'x': phys_size[0], 'y': phys_size[1], 'z': phys_size[2]},
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
return jsonify({"status": "success", "data": data})
|
| 75 |
|
| 76 |
except Exception as e:
|