ziq commited on
Commit
24b5b70
·
1 Parent(s): d77fe25

Update RSNA-ATD2023.py

Browse files
Files changed (1) hide show
  1. RSNA-ATD2023.py +6 -9
RSNA-ATD2023.py CHANGED
@@ -62,20 +62,17 @@ class RSNAATD(datasets.GeneratorBasedBuilder):
62
  ),
63
  ]
64
 
65
- # def sort(self, x):
66
- # return
 
 
 
67
 
68
  def _generate_examples(self, images, masks, metadata):
69
  df = pd.read_csv(metadata)
70
 
71
  for idx, ((image_path, image), (mask_path, mask)) in enumerate(
72
- sorted(
73
- zip(images, masks),
74
- key=lambda x: x[0]["image_path"]
75
- .replace("images/", "")
76
- .replace(".png", "")
77
- .split("_"),
78
- )
79
  ):
80
  row = df.loc[df["path"] == image_path.lower().replace("images/", "")]
81
 
 
62
  ),
63
  ]
64
 
65
+ def sort_key(self, x):
66
+ patient_id, series_id, frame_id = (
67
+ x[0][0].replace("images/", "").replace(".png", "").split("_")
68
+ )
69
+ return int(patient_id), int(series_id), int(frame_id)
70
 
71
  def _generate_examples(self, images, masks, metadata):
72
  df = pd.read_csv(metadata)
73
 
74
  for idx, ((image_path, image), (mask_path, mask)) in enumerate(
75
+ sorted(zip(images, masks), key=self.sort_key)
 
 
 
 
 
 
76
  ):
77
  row = df.loc[df["path"] == image_path.lower().replace("images/", "")]
78