Neemah commited on
Commit
a0ab22a
·
verified ·
1 Parent(s): 480399f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -1
app.py CHANGED
@@ -52,7 +52,34 @@ def run_generate(sequence_images):
52
  if not sequence_images:
53
  return "", gr.DownloadButton(visible=False)
54
 
55
- images = [s[1] for s in sequence_images]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  report = generate_report(images)
57
 
58
  return report, gr.DownloadButton(visible=True)
 
52
  if not sequence_images:
53
  return "", gr.DownloadButton(visible=False)
54
 
55
+ PRIORITY_KEYWORDS = [
56
+ "flair", "tirm", # T2 FLAIR — highest priority
57
+ "dwi", "diff", # DWI
58
+ "t1_se_tra_320+fs", # T1 + Contrast (has 'C' in name)
59
+ "t1", # T1
60
+ "t2_tse_tra", "t2_tra", # T2 axial
61
+ ]
62
+
63
+ # Cap at 5
64
+ selected = sorted_sequences[:5]
65
+
66
+ # Score each sequence by priority
67
+ def get_priority(name_img_tuple):
68
+ name = name_img_tuple[0].lower()
69
+ for i, keyword in enumerate(PRIORITY_KEYWORDS):
70
+ if keyword in name:
71
+ return i
72
+ return 999 # unknown sequences go last
73
+
74
+ # Sort by priority and take top 4
75
+ sorted_sequences = sorted(sequence_images, key=get_priority)
76
+ selected = sorted_sequences[:4]
77
+
78
+ print("Sequences sent to model:")
79
+ for name, _ in selected:
80
+ print(f" - {name}")
81
+
82
+ images = [img for _, img in selected]
83
  report = generate_report(images)
84
 
85
  return report, gr.DownloadButton(visible=True)