Numan Saeed commited on
Commit
0f97254
·
1 Parent(s): cbd23a5

Fix GA biometry display for abdomen and femur views

Browse files
frontend/src/.DS_Store ADDED
Binary file (6.15 kB). View file
 
frontend/src/components/GAResultsCard.tsx CHANGED
@@ -5,6 +5,13 @@ interface GAResultsCardProps {
5
  isLoading: boolean;
6
  }
7
 
 
 
 
 
 
 
 
8
  export function GAResultsCard({ results, isLoading }: GAResultsCardProps) {
9
  if (isLoading) {
10
  return (
@@ -29,13 +36,24 @@ export function GAResultsCard({ results, isLoading }: GAResultsCardProps) {
29
  return (
30
  <div className="bg-white border border-dark-border rounded-xl p-8 text-center shadow-card">
31
  <p className="text-text-muted text-sm">
32
- Upload a fetal brain ultrasound and click "Estimate Age"
33
  </p>
34
  </div>
35
  );
36
  }
37
 
38
- const { gestational_age, head_circumference } = results;
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  return (
41
  <div className="space-y-3 animate-fade-in">
@@ -52,32 +70,34 @@ export function GAResultsCard({ results, isLoading }: GAResultsCardProps) {
52
  </p>
53
  </div>
54
 
55
- {/* Head Circumference Percentiles */}
56
- <div className="bg-white border border-dark-border rounded-xl p-4 shadow-card">
57
- <p className="text-[10px] uppercase tracking-wider text-text-muted mb-3">
58
- Head Circumference Percentiles
59
- </p>
60
- <div className="grid grid-cols-3 gap-3">
61
- <div className="bg-dark-input rounded-xl p-3 text-center">
62
- <p className="text-[10px] text-text-muted mb-1">2.5th</p>
63
- <p className="text-base font-semibold text-text-primary">
64
- {head_circumference.p2_5} mm
65
- </p>
66
- </div>
67
- <div className="bg-nvidia-green/10 rounded-xl p-3 text-center border-2 border-nvidia-green">
68
- <p className="text-[10px] text-nvidia-green mb-1 font-medium">50th</p>
69
- <p className="text-base font-bold text-nvidia-green">
70
- {head_circumference.p50} mm
71
- </p>
72
- </div>
73
- <div className="bg-dark-input rounded-xl p-3 text-center">
74
- <p className="text-[10px] text-text-muted mb-1">97.5th</p>
75
- <p className="text-base font-semibold text-text-primary">
76
- {head_circumference.p97_5} mm
77
- </p>
 
 
78
  </div>
79
  </div>
80
- </div>
81
  </div>
82
  );
83
  }
 
5
  isLoading: boolean;
6
  }
7
 
8
+ // Map view/biometry key to display label
9
+ const BIOMETRY_LABELS: Record<string, string> = {
10
+ head_circumference: 'Head Circumference',
11
+ abdominal_circumference: 'Abdominal Circumference',
12
+ femur_length: 'Femur Length',
13
+ };
14
+
15
  export function GAResultsCard({ results, isLoading }: GAResultsCardProps) {
16
  if (isLoading) {
17
  return (
 
36
  return (
37
  <div className="bg-white border border-dark-border rounded-xl p-8 text-center shadow-card">
38
  <p className="text-text-muted text-sm">
39
+ Upload a fetal ultrasound and click "Estimate Age"
40
  </p>
41
  </div>
42
  );
43
  }
44
 
45
+ const { gestational_age } = results;
46
+
47
+ // Get biometry data dynamically based on what the backend returned
48
+ const biometryData = results.head_circumference
49
+ || results.abdominal_circumference
50
+ || results.femur_length;
51
+
52
+ // Determine which biometry type we have
53
+ let biometryLabel = 'Biometry';
54
+ if (results.head_circumference) biometryLabel = BIOMETRY_LABELS.head_circumference;
55
+ else if (results.abdominal_circumference) biometryLabel = BIOMETRY_LABELS.abdominal_circumference;
56
+ else if (results.femur_length) biometryLabel = BIOMETRY_LABELS.femur_length;
57
 
58
  return (
59
  <div className="space-y-3 animate-fade-in">
 
70
  </p>
71
  </div>
72
 
73
+ {/* Biometry Percentiles - Dynamic based on view */}
74
+ {biometryData && (
75
+ <div className="bg-white border border-dark-border rounded-xl p-4 shadow-card">
76
+ <p className="text-[10px] uppercase tracking-wider text-text-muted mb-3">
77
+ {biometryLabel} Percentiles
78
+ </p>
79
+ <div className="grid grid-cols-3 gap-3">
80
+ <div className="bg-dark-input rounded-xl p-3 text-center">
81
+ <p className="text-[10px] text-text-muted mb-1">2.5th</p>
82
+ <p className="text-base font-semibold text-text-primary">
83
+ {biometryData.p2_5} mm
84
+ </p>
85
+ </div>
86
+ <div className="bg-nvidia-green/10 rounded-xl p-3 text-center border-2 border-nvidia-green">
87
+ <p className="text-[10px] text-nvidia-green mb-1 font-medium">50th</p>
88
+ <p className="text-base font-bold text-nvidia-green">
89
+ {biometryData.p50} mm
90
+ </p>
91
+ </div>
92
+ <div className="bg-dark-input rounded-xl p-3 text-center">
93
+ <p className="text-[10px] text-text-muted mb-1">97.5th</p>
94
+ <p className="text-base font-semibold text-text-primary">
95
+ {biometryData.p97_5} mm
96
+ </p>
97
+ </div>
98
  </div>
99
  </div>
100
+ )}
101
  </div>
102
  );
103
  }
frontend/src/lib/api.ts CHANGED
@@ -33,7 +33,18 @@ export interface GestationalAgeResponse {
33
  days: number;
34
  total_days: number;
35
  };
36
- head_circumference: {
 
 
 
 
 
 
 
 
 
 
 
37
  p2_5: number;
38
  p50: number;
39
  p97_5: number;
@@ -41,6 +52,7 @@ export interface GestationalAgeResponse {
41
  preprocessing: PreprocessingInfo;
42
  }
43
 
 
44
  export async function classifyImage(file: File, topK: number = 5): Promise<ClassificationResponse> {
45
  const formData = new FormData();
46
  formData.append('file', file);
 
33
  days: number;
34
  total_days: number;
35
  };
36
+ // Biometry - only one will be present based on view
37
+ head_circumference?: {
38
+ p2_5: number;
39
+ p50: number;
40
+ p97_5: number;
41
+ };
42
+ abdominal_circumference?: {
43
+ p2_5: number;
44
+ p50: number;
45
+ p97_5: number;
46
+ };
47
+ femur_length?: {
48
  p2_5: number;
49
  p50: number;
50
  p97_5: number;
 
52
  preprocessing: PreprocessingInfo;
53
  }
54
 
55
+
56
  export async function classifyImage(file: File, topK: number = 5): Promise<ClassificationResponse> {
57
  const formData = new FormData();
58
  formData.append('file', file);