Susanne Schmid commited on
Commit
c71fa8b
1 Parent(s): 43339b0

Removed Info pop ups and updated description

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -112,7 +112,7 @@ def Norm_image(vol_path,normalization_technique):
112
 
113
  img_load = LoadImage(pathName)
114
  imglist.append(img_load.flatten())
115
- gr.Info('The volumes are succesfully loaded.')
116
 
117
  if 'MinMax' in normalization_technique:
118
  imgNlist.append(NormalizeMinMax(img_load).flatten())
@@ -126,12 +126,13 @@ def Norm_image(vol_path,normalization_technique):
126
  if 'Percentile (10th - 90th)' in normalization_technique:
127
  imgNPlist.append(NormalizePercentile(img_load, 10, 90).flatten())
128
 
129
- gr.Info('The different normalization techniques are calculted.')
130
 
 
131
  plt.figure(11)
132
  fig, ax = plt.subplots(1,1)
133
  for i, file in enumerate(vol_path):
134
- sns.histplot(data=imglist[i].flatten(), kde=False, label=os.path.basename(file.name)[0:25], log_scale=False,element="step", fill=False,bins=500,legend=True).set(title='Original')
135
  ax.legend()
136
  plt.savefig("Original.png")
137
  plots=["Original.png"]
@@ -139,7 +140,7 @@ def Norm_image(vol_path,normalization_technique):
139
  if 'MinMax' in normalization_technique:
140
  fig, ax = plt.subplots(1,1)
141
  for i, file in enumerate(vol_path):
142
- sns.histplot(data=imgNlist[i].flatten(), kde=False, label=os.path.basename(file.name)[0:25], log_scale=False,element="step", fill=False,bins=500,legend=True).set(title='Min-Max')
143
  ax.legend()
144
  plt.savefig("MinMax.png")
145
  plots.append("MinMax.png")
@@ -147,7 +148,7 @@ def Norm_image(vol_path,normalization_technique):
147
  if 'Z-Score' in normalization_technique:
148
  fig, ax = plt.subplots(1,1)
149
  for i, file in enumerate(vol_path):
150
- sns.histplot(data=imgNZlist[i].flatten(), kde=False, label=os.path.basename(file.name)[0:25], log_scale=False,element="step", fill=False,bins=500,legend=True).set(title='Z-Score')
151
  ax.legend()
152
  plt.savefig("Zscore.png")
153
  plots.append("Zscore.png")
@@ -156,7 +157,7 @@ def Norm_image(vol_path,normalization_technique):
156
  if 'Percentile (2th - 98th)'in normalization_technique:
157
  fig, ax = plt.subplots(1,1)
158
  for i, file in enumerate(vol_path):
159
- sns.histplot(data=imgNPer98list[i].flatten(), kde=False, label=os.path.basename(file.name)[0:25], log_scale=False,element="step", fill=False,bins=500,legend=True).set(title='Percentile 2-98')
160
  ax.legend()
161
  plt.savefig("Per98.png")
162
  plots.append("Per98.png")
@@ -164,17 +165,19 @@ def Norm_image(vol_path,normalization_technique):
164
  if 'Percentile (10th - 90th)' in normalization_technique:
165
  fig, ax = plt.subplots(1,1)
166
  for i, file in enumerate(vol_path):
167
- sns.histplot(data=imgNPlist[i].flatten(), kde=False, label=os.path.basename(file.name)[0:25], log_scale=False,element="step", fill=False,bins=500,legend=True).set(title='Percentile 10 - 90')
168
  ax.legend()
169
  plt.savefig("Per90.png")
170
  plots.append("Per90.png")
171
 
172
- gr.Info('The histograms are produced.')
173
 
174
  return plots
175
 
176
 
177
- description = 'You can upload mutiple image volumes (recommonded 3-5) in *.nii or *.nii.gz to see their histograms for multiple normalization techniques. Depending on file size and selected techniques it might take a while to do the calculations. \n The uploaded data is not stored and gets deleted once closing the window. '
 
 
178
 
179
  inputs = [gr.File(file_count="multiple", label=None),gr.CheckboxGroup(["MinMax", "Z-Score", "Percentile (2th - 98th)", "Percentile (10th - 90th)"])]
180
  demo = gr.Interface(fn=Norm_image,
 
112
 
113
  img_load = LoadImage(pathName)
114
  imglist.append(img_load.flatten())
115
+
116
 
117
  if 'MinMax' in normalization_technique:
118
  imgNlist.append(NormalizeMinMax(img_load).flatten())
 
126
  if 'Percentile (10th - 90th)' in normalization_technique:
127
  imgNPlist.append(NormalizePercentile(img_load, 10, 90).flatten())
128
 
129
+ gr.Info('The volumes are loaded succesfully and different normalization techniques are calculted.')
130
 
131
+ log_scale = False
132
  plt.figure(11)
133
  fig, ax = plt.subplots(1,1)
134
  for i, file in enumerate(vol_path):
135
+ sns.histplot(data=imglist[i].flatten(), kde=False, label=os.path.basename(file.name)[0:25], log_scale=log_scale,element="step", fill=False,bins=500,legend=True).set(title='Original')
136
  ax.legend()
137
  plt.savefig("Original.png")
138
  plots=["Original.png"]
 
140
  if 'MinMax' in normalization_technique:
141
  fig, ax = plt.subplots(1,1)
142
  for i, file in enumerate(vol_path):
143
+ sns.histplot(data=imgNlist[i].flatten(), kde=False, label=os.path.basename(file.name)[0:25], log_scale=log_scale,element="step", fill=False,bins=500,legend=True).set(title='Min-Max')
144
  ax.legend()
145
  plt.savefig("MinMax.png")
146
  plots.append("MinMax.png")
 
148
  if 'Z-Score' in normalization_technique:
149
  fig, ax = plt.subplots(1,1)
150
  for i, file in enumerate(vol_path):
151
+ sns.histplot(data=imgNZlist[i].flatten(), kde=False, label=os.path.basename(file.name)[0:25], log_scale=log_scale,element="step", fill=False,bins=500,legend=True).set(title='Z-Score')
152
  ax.legend()
153
  plt.savefig("Zscore.png")
154
  plots.append("Zscore.png")
 
157
  if 'Percentile (2th - 98th)'in normalization_technique:
158
  fig, ax = plt.subplots(1,1)
159
  for i, file in enumerate(vol_path):
160
+ sns.histplot(data=imgNPer98list[i].flatten(), kde=False, label=os.path.basename(file.name)[0:25], log_scale=log_scale,element="step", fill=False,bins=500,legend=True).set(title='Percentile 2-98')
161
  ax.legend()
162
  plt.savefig("Per98.png")
163
  plots.append("Per98.png")
 
165
  if 'Percentile (10th - 90th)' in normalization_technique:
166
  fig, ax = plt.subplots(1,1)
167
  for i, file in enumerate(vol_path):
168
+ sns.histplot(data=imgNPlist[i].flatten(), kde=False, label=os.path.basename(file.name)[0:25], log_scale=log_scale,element="step", fill=False,bins=500,legend=True).set(title='Percentile 10 - 90')
169
  ax.legend()
170
  plt.savefig("Per90.png")
171
  plots.append("Per90.png")
172
 
173
+
174
 
175
  return plots
176
 
177
 
178
+ description = 'You can upload mutiple image volumes (recommonded 3-5). The files get read by ITK so mulitple different file formats are possible (e.g. *.nii , *.nii.gz, png,..). You need to wait until the data is uploaded. \
179
+ Once pressing submit the histograms for multiple normalization techniques are calculated. Depending on file size and selected techniques it might take a while to do the calculations. \
180
+ \n The uploaded data is not stored and is deleted once the window is closed. '
181
 
182
  inputs = [gr.File(file_count="multiple", label=None),gr.CheckboxGroup(["MinMax", "Z-Score", "Percentile (2th - 98th)", "Percentile (10th - 90th)"])]
183
  demo = gr.Interface(fn=Norm_image,