YongchengYAO commited on
Commit
da10203
·
verified ·
1 Parent(s): 2b29e54

Update get_dataset.py

Browse files
Files changed (1) hide show
  1. get_dataset.py +12 -12
get_dataset.py CHANGED
@@ -162,22 +162,22 @@ def process_landmarks_data(
162
  # Assuming an image with height and width:
163
  # - The data array read from bmp file is of size (height, width) -- dim1 is height, dim2 is width
164
  # - The landmark coordinates are defined as the indices in width (coordinate 1) and height (coordinate 2) directions
165
- idx_dim2, idx_dim1 = map(int, line.split(","))
166
 
167
  # Apply transformations
168
  # Note: this is definitely correct
169
  # This "mismatch" indices in "idx_dim1 = img_sizes[0] - idx_dim1" is due to the way the manual landmarks are defined
170
  # DO NOT SWAP the order of transformations
171
  if flip_dim0:
172
- idx_dim1 = img_sizes[0] - idx_dim1
173
  if flip_dim1:
174
- idx_dim2 = img_sizes[1] - idx_dim2
175
  if swap_dim01: # this line should be AFTER slip_x and slip_y
176
- idx_dim1, idx_dim2 = idx_dim2, idx_dim1
177
 
178
  # Save landmark coordinates in 0-based indices
179
  landmarks[f"P{i+1}"] = [
180
- coord - 1 for coord in [1, idx_dim1, idx_dim2]
181
  ]
182
 
183
  # This data structure is designed to be compatible with biometric data constructed from segmentation masks
@@ -229,26 +229,26 @@ def plot_sagittal_slice_with_landmarks(
229
  ) # the transpose is necessary only for visualization
230
 
231
  # Extract and plot landmark coordinates
232
- x_coords = []
233
- y_coords = []
234
  landmarks = landmarks_json["slice_landmarks_x"][0]["landmarks"]
235
  for point_id, coords in landmarks.items():
236
  if len(coords) == 3: # Check for valid [1, x, y] format
237
  # Note: this is definitely correct, DO NOT SWAP coords[1] and coords[2]
238
- x_coords.append(coords[1])
239
- y_coords.append(coords[2])
240
 
241
  # Add landmarks and labels
242
  plt.scatter(
243
- x_coords,
244
- y_coords,
245
  facecolors="#18A727",
246
  edgecolors="black",
247
  marker="o",
248
  s=80,
249
  linewidth=1.5,
250
  )
251
- for i, (x, y) in enumerate(zip(x_coords, y_coords), 1):
252
  plt.annotate(
253
  f"$\\mathbf{{{i}}}$",
254
  (x, y),
 
162
  # Assuming an image with height and width:
163
  # - The data array read from bmp file is of size (height, width) -- dim1 is height, dim2 is width
164
  # - The landmark coordinates are defined as the indices in width (coordinate 1) and height (coordinate 2) directions
165
+ idx_dim1, idx_dim0 = map(int, line.split(","))
166
 
167
  # Apply transformations
168
  # Note: this is definitely correct
169
  # This "mismatch" indices in "idx_dim1 = img_sizes[0] - idx_dim1" is due to the way the manual landmarks are defined
170
  # DO NOT SWAP the order of transformations
171
  if flip_dim0:
172
+ idx_dim0 = img_sizes[0] - idx_dim0
173
  if flip_dim1:
174
+ idx_dim1 = img_sizes[1] - idx_dim1
175
  if swap_dim01: # this line should be AFTER slip_x and slip_y
176
+ idx_dim0, idx_dim1 = idx_dim1, idx_dim0
177
 
178
  # Save landmark coordinates in 0-based indices
179
  landmarks[f"P{i+1}"] = [
180
+ coord - 1 for coord in [1, idx_dim0, idx_dim1]
181
  ]
182
 
183
  # This data structure is designed to be compatible with biometric data constructed from segmentation masks
 
229
  ) # the transpose is necessary only for visualization
230
 
231
  # Extract and plot landmark coordinates
232
+ coords_dim0 = []
233
+ coords_dim1 = []
234
  landmarks = landmarks_json["slice_landmarks_x"][0]["landmarks"]
235
  for point_id, coords in landmarks.items():
236
  if len(coords) == 3: # Check for valid [1, x, y] format
237
  # Note: this is definitely correct, DO NOT SWAP coords[1] and coords[2]
238
+ coords_dim0.append(coords[1])
239
+ coords_dim1.append(coords[2])
240
 
241
  # Add landmarks and labels
242
  plt.scatter(
243
+ coords_dim0,
244
+ coords_dim1,
245
  facecolors="#18A727",
246
  edgecolors="black",
247
  marker="o",
248
  s=80,
249
  linewidth=1.5,
250
  )
251
+ for i, (x, y) in enumerate(zip(coords_dim0, coords_dim1), 1):
252
  plt.annotate(
253
  f"$\\mathbf{{{i}}}$",
254
  (x, y),