Spaces:
Sleeping
Sleeping
Commit
·
65075f3
1
Parent(s):
3e5ef51
update
Browse files
app.py
CHANGED
@@ -127,8 +127,7 @@ init_js = """
|
|
127 |
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
128 |
}
|
129 |
}
|
130 |
-
if(exist == 0)
|
131 |
-
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
132 |
}
|
133 |
"""
|
134 |
|
@@ -340,13 +339,26 @@ with gr.Blocks() as demo:
|
|
340 |
# stage1-1
|
341 |
def mapping_result(app_state, channel_info, raw_loc):
|
342 |
filepath = app_state["filepath"]
|
343 |
-
|
344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
|
346 |
raw_montage = read_custom_montage(raw_loc)
|
347 |
raw_fig = raw_montage.plot()
|
348 |
raw_fig.set_size_inches(5.6, 5.6)
|
349 |
-
raw_fig.savefig(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
|
351 |
# ------------------determine the next step-----------------------
|
352 |
|
@@ -362,7 +374,7 @@ with gr.Blocks() as demo:
|
|
362 |
return {app_state_json : app_state,
|
363 |
desc_md : gr.Markdown("### Step1: Mapping result", visible=True),
|
364 |
tpl_montage : gr.Image(visible=True),
|
365 |
-
in_montage : gr.Image(value=
|
366 |
run_btn : gr.Button(interactive=True)}
|
367 |
|
368 |
# if matched channels < 30, and there're still some unmatched input channels
|
@@ -378,7 +390,7 @@ with gr.Blocks() as demo:
|
|
378 |
return {app_state_json : app_state,
|
379 |
desc_md : gr.Markdown("### Step1: Mapping result", visible=True),
|
380 |
tpl_montage : gr.Image(visible=True),
|
381 |
-
in_montage : gr.Image(value=
|
382 |
next_btn : gr.Button("Next step", visible=True)}
|
383 |
|
384 |
map_btn.click(
|
|
|
127 |
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
128 |
}
|
129 |
}
|
130 |
+
if(exist == 0) styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
|
|
131 |
}
|
132 |
"""
|
133 |
|
|
|
339 |
# stage1-1
|
340 |
def mapping_result(app_state, channel_info, raw_loc):
|
341 |
filepath = app_state["filepath"]
|
342 |
+
filename1 = filepath+"raw_montage_"+str(random.randint(1,10000))+".png"
|
343 |
+
filename2 = filepath+"mapped_montage_"+str(random.randint(1,10000))+".png"
|
344 |
+
|
345 |
+
#app_state["filenames"]["raw_montage"] = filename1
|
346 |
+
app_state["filenames"].update({
|
347 |
+
"raw_montage" : filename1,
|
348 |
+
"mapped_montage" : filename2
|
349 |
+
})
|
350 |
|
351 |
raw_montage = read_custom_montage(raw_loc)
|
352 |
raw_fig = raw_montage.plot()
|
353 |
raw_fig.set_size_inches(5.6, 5.6)
|
354 |
+
raw_fig.savefig(filename1, pad_inches=0)
|
355 |
+
|
356 |
+
# plot red dots on unmatched input channels
|
357 |
+
ax = raw_fig.axes[0]
|
358 |
+
coords = ax.collections[0].get_offsets().data
|
359 |
+
idx = [channel_info["inputByName"][channel]["index"] for channel in app_state["stage1UnassignedInputs"]]
|
360 |
+
ax.scatter(coords[idx,0]-0.0001, coords[idx,1]+0.0001, color='red')
|
361 |
+
raw_fig.savefig(filename2, pad_inches=0)
|
362 |
|
363 |
# ------------------determine the next step-----------------------
|
364 |
|
|
|
374 |
return {app_state_json : app_state,
|
375 |
desc_md : gr.Markdown("### Step1: Mapping result", visible=True),
|
376 |
tpl_montage : gr.Image(visible=True),
|
377 |
+
in_montage : gr.Image(value=filename2, visible=True),
|
378 |
run_btn : gr.Button(interactive=True)}
|
379 |
|
380 |
# if matched channels < 30, and there're still some unmatched input channels
|
|
|
390 |
return {app_state_json : app_state,
|
391 |
desc_md : gr.Markdown("### Step1: Mapping result", visible=True),
|
392 |
tpl_montage : gr.Image(visible=True),
|
393 |
+
in_montage : gr.Image(value=filename2, visible=True),
|
394 |
next_btn : gr.Button("Next step", visible=True)}
|
395 |
|
396 |
map_btn.click(
|