From c113dede49e28b4634d932b0f2b10b1e05955786 Mon Sep 17 00:00:00 2001 From: hh_itx_win10 Date: Thu, 4 Apr 2024 09:28:59 -0700 Subject: [PATCH 1/2] fix: parsing date_str --- code/Home.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/Home.py b/code/Home.py index 2aa0dfe..bf25496 100644 --- a/code/Home.py +++ b/code/Home.py @@ -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) From eb0eb6493aa9aae268f15b8bd29c3a451dd0c8f1 Mon Sep 17 00:00:00 2001 From: hh_itx_win10 Date: Thu, 4 Apr 2024 09:41:59 -0700 Subject: [PATCH 2/2] feat: show number of sessions to draw --- code/Home.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/code/Home.py b/code/Home.py index bf25496..3591785 100644 --- a/code/Home.py +++ b/code/Home.py @@ -323,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 @@ -333,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( @@ -351,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