Jiaaaaaaax commited on
Commit
0c62c39
·
verified ·
1 Parent(s): 7d996ca

Update session_analysis.py

Browse files
Files changed (1) hide show
  1. session_analysis.py +73 -49
session_analysis.py CHANGED
@@ -447,55 +447,6 @@ def process_analysis_results(raw_analysis):
447
  "timestamp": datetime.now().isoformat()
448
  }
449
 
450
- def show_analysis_results():
451
- """Display the analysis results in the dashboard"""
452
- if not st.session_state.analysis_results:
453
- return
454
-
455
- # Use the analysis results directly (they're already parsed)
456
- analysis = st.session_state.analysis_results
457
-
458
- # Display MI Adherence Score
459
- st.subheader("MI Adherence Score")
460
- score = analysis.get('mi_adherence_score', 0)
461
- create_gauge_chart(score)
462
-
463
- # Display Key Themes
464
- st.subheader("Key Themes")
465
- themes = analysis.get('key_themes', [])
466
- if themes:
467
- for theme in themes:
468
- st.markdown(f"• {theme}")
469
-
470
- # Display Technique Usage
471
- st.subheader("MI Technique Usage")
472
- technique_usage = analysis.get('technique_usage', {})
473
- if technique_usage:
474
- fig = go.Figure(data=[
475
- go.Bar(x=list(technique_usage.keys()), y=list(technique_usage.values()))
476
- ])
477
- fig.update_layout(title="Technique Usage Frequency")
478
- st.plotly_chart(fig)
479
-
480
- # Display Strengths and Areas for Improvement
481
- col1, col2 = st.columns(2)
482
-
483
- with col1:
484
- st.subheader("Strengths")
485
- strengths = analysis.get('strengths', [])
486
- for strength in strengths:
487
- st.markdown(f"✓ {strength}")
488
-
489
- with col2:
490
- st.subheader("Areas for Improvement")
491
- improvements = analysis.get('areas_for_improvement', [])
492
- for improvement in improvements:
493
- st.markdown(f"△ {improvement}")
494
-
495
- # Display Session Summary
496
- st.subheader("Session Summary")
497
- st.write(analysis.get('session_summary', ''))
498
-
499
 
500
  def show_mi_metrics_dashboard(metrics):
501
  st.subheader("MI Performance Dashboard")
@@ -866,7 +817,80 @@ def show_analysis_results():
866
  for area in growth[0].strip().split('\n'):
867
  if area.startswith('- '):
868
  st.markdown(f"🔄 {area[2:]}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
869
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
870
  # Client Language Tab
871
  with tabs[2]:
872
  st.subheader("Client Language Analysis")
 
447
  "timestamp": datetime.now().isoformat()
448
  }
449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
 
451
  def show_mi_metrics_dashboard(metrics):
452
  st.subheader("MI Performance Dashboard")
 
817
  for area in growth[0].strip().split('\n'):
818
  if area.startswith('- '):
819
  st.markdown(f"🔄 {area[2:]}")
820
+ # Technical Skills Tab
821
+ with tabs[1]:
822
+ st.subheader("OARS Technique Analysis")
823
+
824
+ # Extract OARS counts
825
+ oars_pattern = r'OARS Usage Count:\n- Open Questions: (\d+)\n- Affirmations: (\d+)\n- Reflections: (\d+)\n- Summaries: (\d+)'
826
+ oars_match = re.search(oars_pattern, results)
827
+
828
+ if oars_match:
829
+ open_q = int(oars_match.group(1))
830
+ affirm = int(oars_match.group(2))
831
+ reflect = int(oars_match.group(3))
832
+ summ = int(oars_match.group(4))
833
+
834
+ # Create bar chart
835
+ fig = go.Figure(data=[
836
+ go.Bar(
837
+ x=['Open Questions', 'Affirmations', 'Reflections', 'Summaries'],
838
+ y=[open_q, affirm, reflect, summ],
839
+ marker_color=['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728']
840
+ )
841
+ ])
842
+
843
+ fig.update_layout(
844
+ title="OARS Techniques Usage",
845
+ xaxis_title="Technique Type",
846
+ yaxis_title="Frequency",
847
+ showlegend=False,
848
+ height=400
849
+ )
850
+
851
+ st.plotly_chart(fig)
852
 
853
+ # Display detailed breakdown
854
+ col1, col2 = st.columns(2)
855
+
856
+ with col1:
857
+ st.markdown("### Technique Counts")
858
+ st.markdown(f"🔹 **Open Questions:** {open_q}")
859
+ st.markdown(f"🔹 **Affirmations:** {affirm}")
860
+ st.markdown(f"🔹 **Reflections:** {reflect}")
861
+ st.markdown(f"🔹 **Summaries:** {summ}")
862
+
863
+ with col2:
864
+ # Calculate total and percentages
865
+ total = open_q + affirm + reflect + summ
866
+ st.markdown("### Technique Distribution")
867
+ st.markdown(f"🔸 **Open Questions:** {(open_q/total*100):.1f}%")
868
+ st.markdown(f"🔸 **Affirmations:** {(affirm/total*100):.1f}%")
869
+ st.markdown(f"🔸 **Reflections:** {(reflect/total*100):.1f}%")
870
+ st.markdown(f"🔸 **Summaries:** {(summ/total*100):.1f}%")
871
+
872
+ # Add reflection-to-question ratio
873
+ st.markdown("### Key Metrics")
874
+ if open_q > 0:
875
+ r_to_q = reflect / open_q
876
+ st.metric(
877
+ label="Reflection-to-Question Ratio",
878
+ value=f"{r_to_q:.2f}",
879
+ help="Target ratio is 2:1 or higher"
880
+ )
881
+
882
+ # Add MI best practice guidelines
883
+ st.markdown("### MI Best Practices")
884
+ st.info("""
885
+ 📌 **Ideal OARS Distribution:**
886
+ - Reflections should exceed questions (2:1 ratio)
887
+ - Regular use of affirmations (at least 1-2 per session)
888
+ - Strategic use of summaries at transition points
889
+ - Open questions > 70% of all questions
890
+ """)
891
+
892
+ else:
893
+ st.warning("Technical skills analysis data not found in the results.")
894
  # Client Language Tab
895
  with tabs[2]:
896
  st.subheader("Client Language Analysis")