HeshamAI commited on
Commit
033b0a1
·
verified ·
1 Parent(s): a072333

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -131,7 +131,7 @@ class DicomAnalyzer:
131
  # Get image dimensions
132
  height, width = raw_image.shape[:2]
133
 
134
- # Get clicked coordinates and adjust for ImageJ alignment
135
  clicked_x = evt.index[0]
136
  clicked_y = evt.index[1]
137
 
@@ -145,8 +145,8 @@ class DicomAnalyzer:
145
  y = clicked_y
146
 
147
  # Apply ImageJ coordinate system correction
148
- x_offset = -2 # Adjust this value
149
- y_offset = -2 # Adjust this value
150
 
151
  x = x + x_offset
152
  y = y + y_offset
@@ -172,10 +172,9 @@ class DicomAnalyzer:
172
  area_pixels = np.sum(mask)
173
  area_mm2 = area_pixels * (pixel_spacing ** 2)
174
 
175
- # Apply ImageJ-like scaling to match results
176
- scaling_factor = 0.3 # Adjust this value to match ImageJ scaling
177
- mean = np.mean(roi_pixels) * scaling_factor
178
- stddev = np.std(roi_pixels) * scaling_factor
179
  min_val = np.min(roi_pixels)
180
  max_val = np.max(roi_pixels)
181
 
@@ -204,8 +203,7 @@ class DicomAnalyzer:
204
  except Exception as e:
205
  print(f"Error analyzing ROI: {str(e)}")
206
  return self.display_image, f"Error analyzing ROI: {str(e)}"
207
-
208
- def update_display(self):
209
  try:
210
  if self.original_display is None:
211
  return None
 
131
  # Get image dimensions
132
  height, width = raw_image.shape[:2]
133
 
134
+ # Get clicked coordinates
135
  clicked_x = evt.index[0]
136
  clicked_y = evt.index[1]
137
 
 
145
  y = clicked_y
146
 
147
  # Apply ImageJ coordinate system correction
148
+ x_offset = 4 # Adjusted offset
149
+ y_offset = 4 # Adjusted offset
150
 
151
  x = x + x_offset
152
  y = y + y_offset
 
172
  area_pixels = np.sum(mask)
173
  area_mm2 = area_pixels * (pixel_spacing ** 2)
174
 
175
+ # Calculate raw statistics without scaling
176
+ mean = np.mean(roi_pixels)
177
+ stddev = np.std(roi_pixels)
 
178
  min_val = np.min(roi_pixels)
179
  max_val = np.max(roi_pixels)
180
 
 
203
  except Exception as e:
204
  print(f"Error analyzing ROI: {str(e)}")
205
  return self.display_image, f"Error analyzing ROI: {str(e)}"
206
+ def update_display(self):
 
207
  try:
208
  if self.original_display is None:
209
  return None