laverdes commited on
Commit
5f55710
1 Parent(s): 3ecf26a

chore: refactor relative calculation

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -70,22 +70,26 @@ with col2:
70
  df_right.pupil_dilation = df_right.pupil_dilation.map(lambda ser: [f for f in ser if f != 0.0])
71
  df_right.baseline = df_right.baseline.map(lambda ser: [f for f in ser if f != 0.0])
72
  st.success("Blinking values have been removed!")
73
- if "baseline" in list(df_right.keys()):
74
- st.markdown(f"A **baseline** feature has been found on your data, do you want to merge it with any of the other features in a new calculated field?")
75
- option = st.multiselect('Select a feature to merge', [k for k in list(df_right.keys()) if k != 'baseline'], [[k for k in list(df_right.keys()) if k != 'baseline'][-2]])
76
- relative_key = f"relative_{option[0]}"
77
- add_relative = st.button(f"Add {relative_key}")
78
- if add_relative:
79
- baseline_mean = [sum(s)/len(s) for s in df['baseline']]
80
- df_right['relative_pupil_dilation'] = [df[option[0]][i] - baseline_mean[i] for i in range(len(df))]
81
- st.markdown("After adding calculated fields")
82
- st.dataframe(df_right)
83
- with open('myfile.csv') as f:
84
- st.download_button('Download CSV', f)
85
- st.info("Your data has been downloaded, you can visualize and detect outliers in the 'Plotting' and 'Detect Outliers' pages on the sidebar.")
86
  elif detect_blinking and not number_of_blinks:
87
  st.caption("No blinking values were found in your data!")
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  if not df_base.empty:
90
  st.warning("Consider running outlier detection to clean your data!", icon="⚠️")
91
 
 
70
  df_right.pupil_dilation = df_right.pupil_dilation.map(lambda ser: [f for f in ser if f != 0.0])
71
  df_right.baseline = df_right.baseline.map(lambda ser: [f for f in ser if f != 0.0])
72
  st.success("Blinking values have been removed!")
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  elif detect_blinking and not number_of_blinks:
74
  st.caption("No blinking values were found in your data!")
75
 
76
+ with col2:
77
+ if 'df' in list(st.session_state.keys()):
78
+ df_right = st.session_state.df.copy(deep=True)
79
+ if "baseline" in list(df_right.keys()):
80
+ st.markdown(f"A **baseline** feature has been found on your data, do you want to merge it with any of the other features in a new calculated field?")
81
+ option = st.multiselect('Select a feature to merge', [k for k in list(df_right.keys()) if k != 'baseline'], [[k for k in list(df_right.keys()) if k != 'baseline'][-3]])
82
+ relative_key = f"relative_{option[0]}"
83
+ add_relative = st.button(f"Add {relative_key}")
84
+ if add_relative:
85
+ baseline_mean = [sum(s)/len(s) for s in df['baseline']]
86
+ df_right['relative_pupil_dilation'] = [df[option[0]][i] - baseline_mean[i] for i in range(len(df))]
87
+ st.markdown("After adding calculated fields")
88
+ st.dataframe(df_right)
89
+ with open('myfile.csv') as f:
90
+ st.download_button('Download CSV', f)
91
+ st.info("Your data has been downloaded, you can visualize and detect outliers in the 'Plotting' and 'Detect Outliers' pages on the sidebar.")
92
+
93
  if not df_base.empty:
94
  st.warning("Consider running outlier detection to clean your data!", icon="⚠️")
95