lyimo commited on
Commit
b3f74df
·
verified ·
1 Parent(s): 4750b07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -39
app.py CHANGED
@@ -115,51 +115,41 @@ def analyze_ecg_image(image):
115
 
116
  # Create prompt for GPT-4.1
117
  vision_prompt = f"""Analyze this ECG image carefully. You are a cardiologist analyzing an electrocardiogram (ECG).
118
-
119
- CRITICALLY IMPORTANT: Only report what you can actually see in this specific ECG image. Do not provide any predefined values or information not visible in the screen. If something cannot be determined from the image, explicitly state "Not determinable from image".
120
-
121
- Extract and report all visible parameters including:
122
- - Heart rate
123
- - Rhythm
124
- - PR Interval
125
- - QRS Duration
126
- - QT/QTc Interval
127
- - Axis
128
- - P Waves characteristics
129
- - ST Segment findings
130
- - T Waves characteristics
131
- - Any other measurements or values visible on the ECG
132
-
133
- Report exact numerical values where visible. If a range is shown, report the range.
134
-
135
- Format your response strictly like this example:
136
  <h3>ECG Report</h3>
137
  <ul>
138
  <li><strong>Analysis Time:</strong> {timestamp}</li>
139
- <li><strong>Heart Rate:</strong> [visible value] bpm (or 'Not determinable from image')</li>
140
- <li><strong>Rhythm:</strong> [description] (or 'Not determinable from image')</li>
141
- <li><strong>PR Interval:</strong> [visible value] ms (or 'Not determinable from image')</li>
142
- <li><strong>QRS Duration:</strong> [visible value] ms (or 'Not determinable from image')</li>
143
- <li><strong>QT/QTc Interval:</strong> [visible value]/[visible value] ms (or 'Not determinable from image')</li>
144
- <li><strong>Axis:</strong> [description] (or 'Not determinable from image')</li>
145
- <li><strong>P Waves:</strong> [description of what's visible]</li>
146
- <li><strong>ST Segment:</strong> [description of what's visible]</li>
147
- <li><strong>T Waves:</strong> [description of what's visible]</li>
148
- <!-- Add other relevant findings visible in the image -->
149
  </ul>
150
- <h3>Key Observations Based Only on What's Visible</h3>
151
  <ul>
152
- <li>[Only observations from what you can see in the image]</li>
153
- <li>[Use <span style="color:red"> for critical visible findings only]</li>
154
  </ul>
155
- <h3>Impression Based on Visible Findings</h3>
156
- <p>[Provide a brief summary based ONLY on the visible findings in this ECG image]</p>
157
-
158
- Important formatting instructions:
159
- - Use EXACTLY the HTML structure shown
160
- - Do NOT use markdown formatting
161
- - For urgent visible findings, wrap in <span style="color:red">text</span>
162
- - Only comment on what you can actually see in the provided image
 
163
  """
164
 
165
  # Generate content using GPT-4.1
 
115
 
116
  # Create prompt for GPT-4.1
117
  vision_prompt = f"""Analyze this ECG image carefully. You are a cardiologist analyzing an electrocardiogram (ECG).
118
+
119
+ IMPORTANT: Only report what you can actually see clearly displayed in this specific ECG screen. Do not include any measurements or values that are not visible or not displayed digitally in the image. Only create sections for values that are actually shown in the image.
120
+
121
+ Look for and extract visible measurements from the ECG display, which may include:
122
+ - Heart rate (if displayed digitally)
123
+ - Any numeric measurements shown on the screen
124
+ - Visible rhythm patterns
125
+ - Any clearly labeled values or measurements
126
+
127
+ Report exact numerical values where visible. If a value is not displayed or not visible, DO NOT include that section at all in your response.
128
+
129
+ Format your response strictly like this:
 
 
 
 
 
 
130
  <h3>ECG Report</h3>
131
  <ul>
132
  <li><strong>Analysis Time:</strong> {timestamp}</li>
133
+ <!-- Only include the following if they are visible in the image -->
134
+ <!-- If Heart Rate is displayed: -->
135
+ <li><strong>Heart Rate:</strong> [visible value] bpm</li>
136
+ <!-- If other measurements are visible: -->
137
+ <!-- Add only visible measurements as list items -->
 
 
 
 
 
138
  </ul>
139
+ <h3>Visible Findings</h3>
140
  <ul>
141
+ <li>[Only observations of what is actually visible in the waveform]</li>
142
+ <li>[Only visible abnormalities, if any]</li>
143
  </ul>
144
+ <h3>Visual Assessment</h3>
145
+ <p>[Brief summary based ONLY on what is visible in this specific ECG display]</p>
146
+
147
+ Critical rules:
148
+ - Do NOT add sections for measurements not visible in the image
149
+ - Do NOT write "Not determinable from image" for any parameter
150
+ - Only include data that you can actually see in this ECG screen
151
+ - Report only the exact values or descriptions visible in the image
152
+ - If certain standard ECG parameters are not shown, simply don't include them
153
  """
154
 
155
  # Generate content using GPT-4.1