@@ -280,7 +280,7 @@ def show_curriculums():
280280 pass
281281
282282# ------- Layout starts here -------- #
283- def init ():
283+ def init (if_load_docDB = True ):
284284
285285 # Clear specific session state and all filters
286286 for key in st .session_state :
@@ -385,6 +385,11 @@ def _get_data_source(rig):
385385 _df .loc [_df ['water_in_session_manual' ] > 100 ,
386386 ['water_in_session_manual' , 'water_in_session_total' , 'water_after_session' ]] = np .nan
387387
388+ _df .loc [(_df ['duration_iti_median' ] < 0 ) | (_df ['duration_iti_mean' ] < 0 ),
389+ ['duration_iti_median' , 'duration_iti_mean' , 'duration_iti_std' , 'duration_iti_min' , 'duration_iti_max' ]] = np .nan
390+
391+ _df .loc [_df ['invalid_lick_ratio' ] < 0 ,
392+ ['invalid_lick_ratio' ]]= np .nan
388393
389394 # # add something else
390395 # add abs(bais) to all terms that have 'bias' in name
@@ -449,21 +454,22 @@ def _get_data_source(rig):
449454
450455
451456 # --- Load data from docDB ---
452- _df = merge_in_df_docDB (_df )
453-
454- # add docDB_status column
455- _df ["docDB_status" ] = _df .apply (
456- lambda row : (
457- "0_not uploaded"
458- if pd .isnull (row ["session_loc" ])
459- else (
460- "1_uploaded but not processed"
461- if pd .isnull (row ["processed_session_loc" ])
462- else "2_uploaded and processed"
463- )
464- ),
465- axis = 1 ,
466- )
457+ if if_load_docDB :
458+ _df = merge_in_df_docDB (_df )
459+
460+ # add docDB_status column
461+ _df ["docDB_status" ] = _df .apply (
462+ lambda row : (
463+ "0_not uploaded"
464+ if pd .isnull (row ["session_loc" ])
465+ else (
466+ "1_uploaded but not processed"
467+ if pd .isnull (row ["processed_session_loc" ])
468+ else "2_uploaded and processed"
469+ )
470+ ),
471+ axis = 1 ,
472+ )
467473
468474 st .session_state .df ['sessions_bonsai' ] = _df # Somehow _df loses the reference to the original dataframe
469475 st .session_state .session_stats_names = [keys for keys in _df .keys ()]
@@ -753,9 +759,10 @@ def app():
753759
754760 # st.dataframe(st.session_state.df_session_filtered, use_container_width=True, height=1000)
755761
756- ok = True
757- if 'df' not in st .session_state or 'sessions_bonsai' not in st .session_state .df .keys ():
758- ok = init ()
762+ if __name__ == "__main__" :
763+ ok = True
764+ if 'df' not in st .session_state or 'sessions_bonsai' not in st .session_state .df .keys ():
765+ ok = init ()
759766
760- if ok :
761- app ()
767+ if ok :
768+ app ()
0 commit comments