Severian commited on
Commit
ab4848f
·
verified ·
1 Parent(s): ad689b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -28
app.py CHANGED
@@ -670,8 +670,8 @@ def calculate_statistics(df_filtered, lens_selected):
670
  return stats
671
 
672
  def update_manifold_visualization(species_selection, emotion_selection, lens_selection,
673
- alpha_range, srl_range, feature_range, point_size,
674
- show_boundary, show_trajectories, color_scheme):
675
  """Main update function for the manifold visualization."""
676
 
677
  # Filter data based on selections
@@ -691,14 +691,14 @@ def update_manifold_visualization(species_selection, emotion_selection, lens_sel
691
 
692
  if alpha_col in df_filtered.columns:
693
  df_filtered = df_filtered[
694
- (df_filtered[alpha_col] >= alpha_range[0]) &
695
- (df_filtered[alpha_col] <= alpha_range[1])
696
  ]
697
 
698
  if srl_col in df_filtered.columns:
699
  df_filtered = df_filtered[
700
- (df_filtered[srl_col] >= srl_range[0]) &
701
- (df_filtered[srl_col] <= srl_range[1])
702
  ]
703
 
704
  # Feature magnitude filter (using first few feature columns if they exist)
@@ -706,8 +706,8 @@ def update_manifold_visualization(species_selection, emotion_selection, lens_sel
706
  if feature_cols:
707
  feature_magnitudes = np.sqrt(df_filtered[feature_cols[:3]].pow(2).sum(axis=1))
708
  df_filtered = df_filtered[
709
- (feature_magnitudes >= feature_range[0]) &
710
- (feature_magnitudes <= feature_range[1])
711
  ]
712
 
713
  # Create visualizations
@@ -1194,23 +1194,32 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="cyan")) a
1194
 
1195
  # Advanced filtering sliders
1196
  with gr.Accordion("🎛️ Advanced CMT Filters", open=False):
1197
- alpha_range = gr.RangeSlider(
1198
- label="CMT Alpha Range (Geometric Consistency)",
1199
- minimum=0, maximum=1, value=[0, 1], step=0.01,
1200
- info="Filter by geometric consistency measure"
1201
- )
 
 
 
1202
 
1203
- srl_range = gr.RangeSlider(
1204
- label="SRL Range (Complexity Level)",
1205
- minimum=0, maximum=100, value=[0, 100], step=1,
1206
- info="Filter by spike response level (complexity)"
1207
- )
 
 
 
1208
 
1209
- feature_magnitude = gr.RangeSlider(
1210
- label="Feature Magnitude Range",
1211
- minimum=-3, maximum=3, value=[-3, 3], step=0.1,
1212
- info="Filter by overall feature strength"
1213
- )
 
 
 
1214
 
1215
  # Visualization options
1216
  with gr.Accordion("🎨 Visualization Options", open=True):
@@ -1309,8 +1318,8 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="cyan")) a
1309
  # Wire up all the interactive components
1310
  manifold_inputs = [
1311
  species_filter, emotion_filter, lens_selector,
1312
- alpha_range, srl_range, feature_magnitude, point_size,
1313
- show_species_boundary, show_trajectories, color_scheme
1314
  ]
1315
 
1316
  manifold_outputs = [
@@ -1333,9 +1342,12 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="cyan")) a
1333
  ["Human", "Dog"], # species_selection
1334
  list(df_combined['label'].unique()), # emotion_selection
1335
  "gamma", # lens_selection
1336
- [0, 1], # alpha_range
1337
- [0, 100], # srl_range
1338
- [-3, 3], # feature_range
 
 
 
1339
  6, # point_size
1340
  True, # show_boundary
1341
  False, # show_trajectories
 
670
  return stats
671
 
672
  def update_manifold_visualization(species_selection, emotion_selection, lens_selection,
673
+ alpha_min, alpha_max, srl_min, srl_max, feature_min, feature_max,
674
+ point_size, show_boundary, show_trajectories, color_scheme):
675
  """Main update function for the manifold visualization."""
676
 
677
  # Filter data based on selections
 
691
 
692
  if alpha_col in df_filtered.columns:
693
  df_filtered = df_filtered[
694
+ (df_filtered[alpha_col] >= alpha_min) &
695
+ (df_filtered[alpha_col] <= alpha_max)
696
  ]
697
 
698
  if srl_col in df_filtered.columns:
699
  df_filtered = df_filtered[
700
+ (df_filtered[srl_col] >= srl_min) &
701
+ (df_filtered[srl_col] <= srl_max)
702
  ]
703
 
704
  # Feature magnitude filter (using first few feature columns if they exist)
 
706
  if feature_cols:
707
  feature_magnitudes = np.sqrt(df_filtered[feature_cols[:3]].pow(2).sum(axis=1))
708
  df_filtered = df_filtered[
709
+ (feature_magnitudes >= feature_min) &
710
+ (feature_magnitudes <= feature_max)
711
  ]
712
 
713
  # Create visualizations
 
1194
 
1195
  # Advanced filtering sliders
1196
  with gr.Accordion("🎛️ Advanced CMT Filters", open=False):
1197
+ gr.Markdown("**CMT Alpha Range (Geometric Consistency)**")
1198
+ with gr.Row():
1199
+ alpha_min = gr.Slider(
1200
+ label="Alpha Min", minimum=0, maximum=1, value=0, step=0.01
1201
+ )
1202
+ alpha_max = gr.Slider(
1203
+ label="Alpha Max", minimum=0, maximum=1, value=1, step=0.01
1204
+ )
1205
 
1206
+ gr.Markdown("**SRL Range (Complexity Level)**")
1207
+ with gr.Row():
1208
+ srl_min = gr.Slider(
1209
+ label="SRL Min", minimum=0, maximum=100, value=0, step=1
1210
+ )
1211
+ srl_max = gr.Slider(
1212
+ label="SRL Max", minimum=0, maximum=100, value=100, step=1
1213
+ )
1214
 
1215
+ gr.Markdown("**Feature Magnitude Range**")
1216
+ with gr.Row():
1217
+ feature_min = gr.Slider(
1218
+ label="Feature Min", minimum=-3, maximum=3, value=-3, step=0.1
1219
+ )
1220
+ feature_max = gr.Slider(
1221
+ label="Feature Max", minimum=-3, maximum=3, value=3, step=0.1
1222
+ )
1223
 
1224
  # Visualization options
1225
  with gr.Accordion("🎨 Visualization Options", open=True):
 
1318
  # Wire up all the interactive components
1319
  manifold_inputs = [
1320
  species_filter, emotion_filter, lens_selector,
1321
+ alpha_min, alpha_max, srl_min, srl_max, feature_min, feature_max,
1322
+ point_size, show_species_boundary, show_trajectories, color_scheme
1323
  ]
1324
 
1325
  manifold_outputs = [
 
1342
  ["Human", "Dog"], # species_selection
1343
  list(df_combined['label'].unique()), # emotion_selection
1344
  "gamma", # lens_selection
1345
+ 0, # alpha_min
1346
+ 1, # alpha_max
1347
+ 0, # srl_min
1348
+ 100, # srl_max
1349
+ -3, # feature_min
1350
+ 3, # feature_max
1351
  6, # point_size
1352
  True, # show_boundary
1353
  False, # show_trajectories