Skip to content

Commit

Permalink
Merge pull request #52 from AllenNeuralDynamics/han_fix_51
Browse files Browse the repository at this point in the history
fix: issue 51
  • Loading branch information
hanhou authored Apr 4, 2024
2 parents 7910723 + eb0eb64 commit 9deda25
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions code/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,13 @@ def _fetch_img(glob_patterns, crop=None):

# @st.cache_data(ttl=24*3600, max_entries=20)
def show_session_level_img_by_key_and_prefix(key, prefix, column=None, other_patterns=[''], crop=None, caption=True, **kwargs):
try:
date_str = key["session_date"].strftime(r'%Y-%m-%d')
except:
date_str = key["session_date"].split("T")[0]

# Convert session_date to 2024-04-01 format
subject_session_date_str = f"{key['subject_id']}_{key['session_date'].strftime(r'%Y-%m-%d')}_{key['nwb_suffix']}".split('_0')[0]
subject_session_date_str = f"{key['subject_id']}_{date_str}_{key['nwb_suffix']}".split('_0')[0]
glob_patterns = [cache_folder + f"{subject_session_date_str}/{subject_session_date_str}_{prefix}*"]

img, f_name = _fetch_img(glob_patterns, crop)
Expand Down Expand Up @@ -319,7 +323,7 @@ def session_plot_settings(need_click=True):
cols = st.columns([2, 1])

session_plot_modes = [f'sessions selected from table or plot', f'all sessions filtered from sidebar']
st.session_state.selected_draw_sessions = cols[0].selectbox('Which session(s) to draw?',
st.session_state.selected_draw_sessions = cols[0].selectbox(f'Which session(s) to draw?',
session_plot_modes,
index=session_plot_modes.index(st.session_state['session_plot_mode'])
if 'session_plot_mode' in st.session_state else
Expand All @@ -329,7 +333,12 @@ def session_plot_settings(need_click=True):
key='session_plot_mode',
)

st.session_state.num_cols = cols[1].number_input('Number of columns', 1, 10,
n_session_to_draw = len(st.session_state.df_selected_from_plotly) \
if 'selected from table or plot' in st.session_state.selected_draw_sessions \
else len(st.session_state.df_session_filtered)
st.markdown(f'{n_session_to_draw} sessions to draw')

st.session_state.num_cols = cols[1].number_input('number of columns', 1, 10,
3 if 'num_cols' not in st.session_state else st.session_state.num_cols)

st.markdown(
Expand All @@ -347,7 +356,7 @@ def session_plot_settings(need_click=True):
if 'selected_draw_types' not in st.session_state else
st.session_state.selected_draw_types)
if need_click:
draw_it = st.button('Show me all sessions!', use_container_width=True)
draw_it = st.button(f'Show me all {n_session_to_draw} sessions!', use_container_width=True)
else:
draw_it = True
return draw_it
Expand Down

0 comments on commit 9deda25

Please sign in to comment.