Skip to content

Commit

Permalink
Merge pull request #102 from AllenNeuralDynamics/han_add_metrics_dist…
Browse files Browse the repository at this point in the history
…ribution_across_stage

feat: add metrics distributions of different training stages
  • Loading branch information
hanhou authored Dec 5, 2024
2 parents a481ad3 + 784f06b commit 92bcac6
Show file tree
Hide file tree
Showing 6 changed files with 495 additions and 220 deletions.
49 changes: 28 additions & 21 deletions code/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def show_curriculums():
pass

# ------- Layout starts here -------- #
def init():
def init(if_load_docDB=True):

# Clear specific session state and all filters
for key in st.session_state:
Expand Down Expand Up @@ -385,6 +385,11 @@ def _get_data_source(rig):
_df.loc[_df['water_in_session_manual'] > 100,
['water_in_session_manual', 'water_in_session_total', 'water_after_session']] = np.nan

_df.loc[(_df['duration_iti_median'] < 0) | (_df['duration_iti_mean'] < 0),
['duration_iti_median', 'duration_iti_mean', 'duration_iti_std', 'duration_iti_min', 'duration_iti_max']] = np.nan

_df.loc[_df['invalid_lick_ratio'] < 0,
['invalid_lick_ratio']]= np.nan

# # add something else
# add abs(bais) to all terms that have 'bias' in name
Expand Down Expand Up @@ -449,21 +454,22 @@ def _get_data_source(rig):


# --- Load data from docDB ---
_df = merge_in_df_docDB(_df)

# add docDB_status column
_df["docDB_status"] = _df.apply(
lambda row: (
"0_not uploaded"
if pd.isnull(row["session_loc"])
else (
"1_uploaded but not processed"
if pd.isnull(row["processed_session_loc"])
else "2_uploaded and processed"
)
),
axis=1,
)
if if_load_docDB:
_df = merge_in_df_docDB(_df)

# add docDB_status column
_df["docDB_status"] = _df.apply(
lambda row: (
"0_not uploaded"
if pd.isnull(row["session_loc"])
else (
"1_uploaded but not processed"
if pd.isnull(row["processed_session_loc"])
else "2_uploaded and processed"
)
),
axis=1,
)

st.session_state.df['sessions_bonsai'] = _df # Somehow _df loses the reference to the original dataframe
st.session_state.session_stats_names = [keys for keys in _df.keys()]
Expand Down Expand Up @@ -753,9 +759,10 @@ def app():

# st.dataframe(st.session_state.df_session_filtered, use_container_width=True, height=1000)

ok = True
if 'df' not in st.session_state or 'sessions_bonsai' not in st.session_state.df.keys():
ok = init()
if __name__ == "__main__":
ok = True
if 'df' not in st.session_state or 'sessions_bonsai' not in st.session_state.df.keys():
ok = init()

if ok:
app()
if ok:
app()
2 changes: 1 addition & 1 deletion code/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__ver__ = 'v2.5.5'
__ver__ = 'v2.5.6'
Loading

0 comments on commit 92bcac6

Please sign in to comment.