-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp-amid.py
73 lines (56 loc) · 1.85 KB
/
app-amid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 13 13:47:18 2021
@author: mmemc
"""
from amid import AMID
import streamlit as st
import tkinter as tk
from tkinter import filedialog
import bokeh as bk
import numpy as np
from pathlib import Path
@st.cache(persist=True)
def read_data(bytesIO, dstdir, cell_label):
return AMID(dstdir, "", "", cell_label, bytesIO=bytesIO)
@st.cache(persist=True, suppress_st_warning=True)
def dstdir_button():
return st.button('Select DST')
@st.cache(persist=True, suppress_st_warning=True)
def output_dir(clicked):
if clicked is True:
dstdir = filedialog.askdirectory(master=root)
#dstdir = st.text_input('Selected DST folder:', filedialog.askdirectory(master=root))
return dstdir
else:
return "./"
st.write("""
# Welcome to the AMID!
""")
bytesIO = st.file_uploader("Load your UHPC file here!")
# Set up tkinter
root = tk.Tk()
root.withdraw()
# Make folder picker dialog appear on top of other windows
root.wm_attributes('-topmost', 1)
# Folder picker button
st.title('Set output folder.')
st.write('Where would you like graphs and datafiles saved?')
clicked = st.button('Select DST')
#clicked = dstdir_button()
dstdir = output_dir(clicked)
st.text_input('Selected DST folder:', dstdir)
#dstdir = './'
#if clicked:
# dstdir = st.text_input('Selected DST folder:', filedialog.askdirectory(master=root))
cell_label = st.text_input('Cell Label')
plot_protocol = st.sidebar.button("Plot Protocol")
if plot_protocol:
save_protocol = st.sidebar.button("Save Protocol")
if bytesIO is not None:
amid_data = read_data(bytesIO, dstdir, cell_label)
#amid_data = AMID(dstdir, "", "", cell_label, bytesIO=fdata)
if plot_protocol:
pro_fig = amid_data.plot_protocol(save=save_protocol, return_fig=True)
st.pyplot(fig=pro_fig)