Spaces:
Sleeping
Sleeping
Commit
·
2e24354
1
Parent(s):
b1a3cc1
update
Browse files
app.py
CHANGED
@@ -398,7 +398,7 @@ with gr.Blocks() as demo:
|
|
398 |
"input_montage" : filename1,
|
399 |
"mapped_montage" : filename2
|
400 |
})
|
401 |
-
|
402 |
unassigned_num = len(stage1_info["unassignedInputs"])
|
403 |
if unassigned_num == 0:
|
404 |
md = """
|
@@ -510,12 +510,10 @@ with gr.Blocks() as demo:
|
|
510 |
if selected_radio != []:
|
511 |
prev_target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
512 |
prev_target_idx = channel_info["templateDict"][prev_target_name]["index"]
|
513 |
-
|
514 |
-
# store the index of the in_channel
|
515 |
selected_idx = channel_info["inputDict"][selected_radio]["index"]
|
|
|
516 |
stage1_info["mappingData"][0]["newOrder"][prev_target_idx] = [selected_idx]
|
517 |
stage1_info["mappingData"][0]["fillFlags"][prev_target_idx] = False
|
518 |
-
# mark the in_channel as assigned and tpl_channel as matched
|
519 |
channel_info["templateDict"][prev_target_name]["matched"] = True
|
520 |
channel_info["inputDict"][selected_radio]["assigned"] = True
|
521 |
#print(prev_target_name, '<-', selected_radio)
|
@@ -607,10 +605,11 @@ with gr.Blocks() as demo:
|
|
607 |
"totalFillingNum" : len(stage1_info["missingTemplates"])
|
608 |
})
|
609 |
target_name = stage1_info["missingTemplates"][0]
|
|
|
|
|
610 |
target_idx = channel_info["templateDict"][target_name]["index"]
|
611 |
chkbox_value = stage1_info["mappingData"][0]["newOrder"][target_idx]
|
612 |
chkbox_value = [channel_info["inputOrder"][i] for i in chkbox_value]
|
613 |
-
chkbox_label = "{} (1/{})".format(target_name, stage1_info["totalFillingNum"])
|
614 |
|
615 |
stage1_info["state"] = "step3-2-selecting"
|
616 |
app_info["stage1"] = stage1_info
|
@@ -637,13 +636,12 @@ with gr.Blocks() as demo:
|
|
637 |
elif stage1_info["state"] == "step3-2-selecting":
|
638 |
|
639 |
# --------------------store information before the button click---------------------
|
640 |
-
# if the user didn't uncheck all in_channel checkboxes
|
641 |
if selected_chkbox != []:
|
642 |
prev_target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
643 |
prev_target_idx = channel_info["templateDict"][prev_target_name]["index"]
|
644 |
-
|
645 |
-
# store the indices of the in_channels
|
646 |
selected_indices = [channel_info["inputDict"][channel]["index"] for channel in selected_chkbox]
|
|
|
647 |
stage1_info["mappingData"][0]["newOrder"][prev_target_idx] = selected_indices
|
648 |
#print(f'{prev_target_name}({prev_target_idx}): {selected_indices}')
|
649 |
# ----------------------------------------------------------------------------------
|
@@ -723,12 +721,10 @@ with gr.Blocks() as demo:
|
|
723 |
if selected != []:
|
724 |
prev_target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
725 |
prev_target_idx = channel_info["templateDict"][prev_target_name]["index"]
|
726 |
-
|
727 |
-
# store the index of the selected in_channel
|
728 |
selected_idx = channel_info["inputDict"][selected]["index"]
|
|
|
729 |
stage1_info["mappingData"][0]["newOrder"][prev_target_idx] = [selected_idx]
|
730 |
stage1_info["mappingData"][0]["fillFlags"][prev_target_idx] = False
|
731 |
-
# mark the in_channel as assigned and tpl_channel as matched
|
732 |
channel_info["templateDict"][prev_target_name]["matched"] = True
|
733 |
channel_info["inputDict"][selected]["assigned"] = True
|
734 |
#print(prev_target_name, '<-', selected)
|
@@ -738,7 +734,7 @@ with gr.Blocks() as demo:
|
|
738 |
|
739 |
# update the list of unassignedInputs to exclude the selected in_channel of the previous round
|
740 |
stage1_info["unassignedInputs"] = app_utils.get_unassigned_inputs(channel_info["inputOrder"], channel_info["inputDict"])
|
741 |
-
|
742 |
target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
743 |
radio_label = "{} ({}/{})".format(target_name, stage1_info["fillingCount"], stage1_info["totalFillingNum"])
|
744 |
|
@@ -775,25 +771,24 @@ with gr.Blocks() as demo:
|
|
775 |
def update_chkbox(app_info, channel_info, selected):
|
776 |
stage1_info = app_info["stage1"]
|
777 |
# ----------------------store information before the button click-----------------------
|
778 |
-
# if the user didn't uncheck all in_channel checkboxes
|
779 |
if selected != []:
|
780 |
prev_target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
781 |
prev_target_idx = channel_info["templateDict"][prev_target_name]["index"]
|
782 |
-
|
783 |
-
# store the indices of the selected in_channels
|
784 |
selected_indices = [channel_info["inputDict"][channel]["index"] for channel in selected]
|
|
|
785 |
stage1_info["mappingData"][0]["newOrder"][prev_target_idx] = selected_indices
|
786 |
#print(f'{prev_target_name}({prev_target_idx}): {selected_indices}')
|
787 |
|
788 |
# ------------------------update information for the new round--------------------------
|
789 |
stage1_info["fillingCount"] += 1
|
790 |
|
791 |
-
# update the progress indication label
|
792 |
target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
|
|
|
|
793 |
target_idx = channel_info["templateDict"][target_name]["index"]
|
794 |
chkbox_value = stage1_info["mappingData"][0]["newOrder"][target_idx]
|
795 |
chkbox_value = [channel_info["inputOrder"][i] for i in chkbox_value]
|
796 |
-
chkbox_label = "{} ({}/{})".format(target_name, stage1_info["fillingCount"], stage1_info["totalFillingNum"])
|
797 |
|
798 |
app_info["stage1"] = stage1_info
|
799 |
# determine which button to display
|
@@ -870,7 +865,7 @@ with gr.Blocks() as demo:
|
|
870 |
filename = stage2_info["fileNames"]["input_data"]
|
871 |
new_filename = stage2_info["fileNames"]["output_data"]
|
872 |
|
873 |
-
break_flag = False #
|
874 |
for i in range(stage2_info["totalBatchNum"]):
|
875 |
# establish a temp folder
|
876 |
try:
|
|
|
398 |
"input_montage" : filename1,
|
399 |
"mapped_montage" : filename2
|
400 |
})
|
401 |
+
|
402 |
unassigned_num = len(stage1_info["unassignedInputs"])
|
403 |
if unassigned_num == 0:
|
404 |
md = """
|
|
|
510 |
if selected_radio != []:
|
511 |
prev_target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
512 |
prev_target_idx = channel_info["templateDict"][prev_target_name]["index"]
|
|
|
|
|
513 |
selected_idx = channel_info["inputDict"][selected_radio]["index"]
|
514 |
+
|
515 |
stage1_info["mappingData"][0]["newOrder"][prev_target_idx] = [selected_idx]
|
516 |
stage1_info["mappingData"][0]["fillFlags"][prev_target_idx] = False
|
|
|
517 |
channel_info["templateDict"][prev_target_name]["matched"] = True
|
518 |
channel_info["inputDict"][selected_radio]["assigned"] = True
|
519 |
#print(prev_target_name, '<-', selected_radio)
|
|
|
605 |
"totalFillingNum" : len(stage1_info["missingTemplates"])
|
606 |
})
|
607 |
target_name = stage1_info["missingTemplates"][0]
|
608 |
+
chkbox_label = "{} (1/{})".format(target_name, stage1_info["totalFillingNum"])
|
609 |
+
|
610 |
target_idx = channel_info["templateDict"][target_name]["index"]
|
611 |
chkbox_value = stage1_info["mappingData"][0]["newOrder"][target_idx]
|
612 |
chkbox_value = [channel_info["inputOrder"][i] for i in chkbox_value]
|
|
|
613 |
|
614 |
stage1_info["state"] = "step3-2-selecting"
|
615 |
app_info["stage1"] = stage1_info
|
|
|
636 |
elif stage1_info["state"] == "step3-2-selecting":
|
637 |
|
638 |
# --------------------store information before the button click---------------------
|
639 |
+
# check if the user didn't uncheck all in_channel checkboxes
|
640 |
if selected_chkbox != []:
|
641 |
prev_target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
642 |
prev_target_idx = channel_info["templateDict"][prev_target_name]["index"]
|
|
|
|
|
643 |
selected_indices = [channel_info["inputDict"][channel]["index"] for channel in selected_chkbox]
|
644 |
+
|
645 |
stage1_info["mappingData"][0]["newOrder"][prev_target_idx] = selected_indices
|
646 |
#print(f'{prev_target_name}({prev_target_idx}): {selected_indices}')
|
647 |
# ----------------------------------------------------------------------------------
|
|
|
721 |
if selected != []:
|
722 |
prev_target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
723 |
prev_target_idx = channel_info["templateDict"][prev_target_name]["index"]
|
|
|
|
|
724 |
selected_idx = channel_info["inputDict"][selected]["index"]
|
725 |
+
|
726 |
stage1_info["mappingData"][0]["newOrder"][prev_target_idx] = [selected_idx]
|
727 |
stage1_info["mappingData"][0]["fillFlags"][prev_target_idx] = False
|
|
|
728 |
channel_info["templateDict"][prev_target_name]["matched"] = True
|
729 |
channel_info["inputDict"][selected]["assigned"] = True
|
730 |
#print(prev_target_name, '<-', selected)
|
|
|
734 |
|
735 |
# update the list of unassignedInputs to exclude the selected in_channel of the previous round
|
736 |
stage1_info["unassignedInputs"] = app_utils.get_unassigned_inputs(channel_info["inputOrder"], channel_info["inputDict"])
|
737 |
+
|
738 |
target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
739 |
radio_label = "{} ({}/{})".format(target_name, stage1_info["fillingCount"], stage1_info["totalFillingNum"])
|
740 |
|
|
|
771 |
def update_chkbox(app_info, channel_info, selected):
|
772 |
stage1_info = app_info["stage1"]
|
773 |
# ----------------------store information before the button click-----------------------
|
774 |
+
# check if the user didn't uncheck all in_channel checkboxes
|
775 |
if selected != []:
|
776 |
prev_target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
777 |
prev_target_idx = channel_info["templateDict"][prev_target_name]["index"]
|
|
|
|
|
778 |
selected_indices = [channel_info["inputDict"][channel]["index"] for channel in selected]
|
779 |
+
|
780 |
stage1_info["mappingData"][0]["newOrder"][prev_target_idx] = selected_indices
|
781 |
#print(f'{prev_target_name}({prev_target_idx}): {selected_indices}')
|
782 |
|
783 |
# ------------------------update information for the new round--------------------------
|
784 |
stage1_info["fillingCount"] += 1
|
785 |
|
|
|
786 |
target_name = stage1_info["missingTemplates"][stage1_info["fillingCount"]-1]
|
787 |
+
chkbox_label = "{} ({}/{})".format(target_name, stage1_info["fillingCount"], stage1_info["totalFillingNum"])
|
788 |
+
|
789 |
target_idx = channel_info["templateDict"][target_name]["index"]
|
790 |
chkbox_value = stage1_info["mappingData"][0]["newOrder"][target_idx]
|
791 |
chkbox_value = [channel_info["inputOrder"][i] for i in chkbox_value]
|
|
|
792 |
|
793 |
app_info["stage1"] = stage1_info
|
794 |
# determine which button to display
|
|
|
865 |
filename = stage2_info["fileNames"]["input_data"]
|
866 |
new_filename = stage2_info["fileNames"]["output_data"]
|
867 |
|
868 |
+
break_flag = False # indicate if the process has been interrupted by the user
|
869 |
for i in range(stage2_info["totalBatchNum"]):
|
870 |
# establish a temp folder
|
871 |
try:
|