Skip to content

Commit

Permalink
Edit viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
gurayerus committed Dec 9, 2024
1 parent adfe1c8 commit 0576ff5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
13 changes: 11 additions & 2 deletions src/viewer/pages/plot_sMRI_vars_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def panel_incsv() -> None:
st.session_state.paths["file_search_dir"],
)

print(f'aaaa {st.session_state.is_updated["csv_plot"]}')

if os.path.exists(st.session_state.paths["csv_plot"]):
p_plot = st.session_state.paths["csv_plot"]
st.success(f"Data is ready ({p_plot})", icon=":material/thumb_up:")
Expand All @@ -103,6 +105,7 @@ def panel_incsv() -> None:
st.session_state.is_updated["csv_plot"] = False

# Show input data
if os.path.exists(st.session_state.paths["csv_plot"]):
with st.expander('Show input data', expanded=False):
st.dataframe(st.session_state.plot_var["df_data"])

Expand Down Expand Up @@ -188,6 +191,10 @@ def panel_select() -> None:

df = st.session_state.plot_var["df_data"]

if 'MRID' not in df.columns:
st.warning('The data file does not contain the required "MRID" column. The operation cannot proceed.')
return

with open(st.session_state.dict_categories, "r") as f:
dict_categories = json.load(f)

Expand Down Expand Up @@ -247,11 +254,13 @@ def panel_select() -> None:
sel_vars = sel_vars + vars_cent
st.session_state.plot_sel_vars = sel_vars

print(f'sss {vars_cent} nnnn {sel_vars}')

df = df[st.session_state.plot_sel_vars]
st.session_state.plot_var["df_data"] = df

with st.expander('Show selected data', expanded=False):
st.dataframe(st.session_state.plot_var["df_data"])


col1, col2 = st.columns([0.5, 0.1])
with col2:
if st.button("Revert to initial data", use_container_width=True):
Expand Down
24 changes: 11 additions & 13 deletions src/viewer/utils/utils_st.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ def util_panel_workingdir(app_type: str) -> None:
utilses.update_default_paths()
utilses.reset_flags()


def copy_uploaded_to_dir() -> None:
# Copies files to local storage
if len(st.session_state["uploaded_input"]) > 0:
Expand Down Expand Up @@ -312,11 +311,6 @@ def util_upload_file(
Upload user data to target folder
Input data is a single file
"""
# Set target path
if not flag_disabled:
if not os.path.exists(os.path.dirname(out_file)):
os.makedirs(os.path.dirname(out_file))

# Upload input
in_file = st.file_uploader(
title_txt,
Expand All @@ -325,14 +319,18 @@ def util_upload_file(
disabled=flag_disabled,
label_visibility=label_visibility,
)
if in_file is None:
return False

# Copy to target
if not os.path.exists(out_file):
utilio.copy_uploaded_file(in_file, out_file)
return True

return False

# Create parent dir of out file
if not os.path.exists(os.path.dirname(out_file)):
os.makedirs(os.path.dirname(out_file))
# Remove existing output file
if os.path.exists(out_file):
os.remove(out_file)
# Copy selected input file to destination
utilio.copy_uploaded_file(in_file, out_file)
return True

def util_select_folder(
key_selector: str,
Expand Down

0 comments on commit 0576ff5

Please sign in to comment.