SreekarB commited on
Commit
0d33b30
·
verified ·
1 Parent(s): 3a90fb6

Upload 3 files

Browse files
Files changed (2) hide show
  1. app.py +3 -3
  2. osf_demovae_adapter.py +6 -6
app.py CHANGED
@@ -307,7 +307,7 @@ def generate_fc_visualization(age, mpo, education, gender, handedness,
307
  except (NameError, AttributeError):
308
  # Fall back to old style visualization
309
  plt.figure(figsize=(10, 8))
310
- plt.imshow(custom_fc_mat, cmap='coolwarm', vmin=-1, vmax=1)
311
  plt.colorbar(label='Correlation')
312
  plt.title(f'FC Matrix: Age {age}, Gender {"M" if gender_val else "F"}, Aphasia Score: {predicted_aphasia_score:.1f}')
313
  plt.savefig(temp_img_path)
@@ -439,8 +439,8 @@ with gr.Blocks(title="Aphasia Prediction with FC Visualization") as demo:
439
  3. Optionally, override the model's prediction with your own custom score
440
  4. If the model is not trained, go to the "Train Model" tab to train it first
441
 
442
- The heatmap shows correlations between brain regions. Yellow indicates positive correlations (regions that activate together),
443
- green indicates neutral correlations, and blue indicates negative correlations (regions with opposing activation patterns).
444
  """)
445
 
446
  if __name__ == "__main__":
 
307
  except (NameError, AttributeError):
308
  # Fall back to old style visualization
309
  plt.figure(figsize=(10, 8))
310
+ plt.imshow(custom_fc_mat, cmap='RdBu_r', vmin=-1, vmax=1)
311
  plt.colorbar(label='Correlation')
312
  plt.title(f'FC Matrix: Age {age}, Gender {"M" if gender_val else "F"}, Aphasia Score: {predicted_aphasia_score:.1f}')
313
  plt.savefig(temp_img_path)
 
439
  3. Optionally, override the model's prediction with your own custom score
440
  4. If the model is not trained, go to the "Train Model" tab to train it first
441
 
442
+ The heatmap shows correlations between brain regions. Red indicates positive correlations (regions that activate together),
443
+ white indicates neutral correlations, and blue indicates negative correlations (regions with opposing activation patterns).
444
  """)
445
 
446
  if __name__ == "__main__":
osf_demovae_adapter.py CHANGED
@@ -743,13 +743,13 @@ def plot_connectivity_matrix(fc_matrix, subject_id=None, save_path=None, show_la
743
  print("Matplotlib is required for plotting connectivity matrices")
744
  return None
745
 
746
- # Create a custom colormap (yellow-green-blue)
747
- colors = [(1, 1, 0), # Yellow for positive correlations
748
- (0, 1, 0), # Green for moderate correlations
749
  (0, 0, 1)] # Blue for negative correlations
750
 
751
  n_bins = 256 # Number of discrete colors
752
- custom_cmap = LinearSegmentedColormap.from_list("YellowGreenBlue", colors, N=n_bins)
753
 
754
  # Create figure
755
  fig_size = 12 if show_labels else 8
@@ -789,14 +789,14 @@ def plot_connectivity_matrix(fc_matrix, subject_id=None, save_path=None, show_la
789
  cbar.set_label("Correlation Strength", rotation=270, labelpad=15)
790
 
791
  # Add annotations explaining the color scheme
792
- fig.text(0.01, 0.01, "Color scheme: Yellow (positive correlation), Green (neutral), Blue (negative correlation)",
793
  fontsize=8, ha='left')
794
 
795
  # Add explanation of matrix content
796
  explanation = (
797
  "This matrix shows the functional connectivity between brain regions.\n"
798
  "Each cell represents the correlation of activity between two regions.\n"
799
- "Positive values (yellow) indicate regions that activate together.\n"
800
  "Negative values (blue) indicate regions with opposite activation patterns."
801
  )
802
 
 
743
  print("Matplotlib is required for plotting connectivity matrices")
744
  return None
745
 
746
+ # Create a custom colormap (red-white-blue)
747
+ colors = [(1, 0, 0), # Red for positive correlations
748
+ (1, 1, 1), # White for neutral correlations
749
  (0, 0, 1)] # Blue for negative correlations
750
 
751
  n_bins = 256 # Number of discrete colors
752
+ custom_cmap = LinearSegmentedColormap.from_list("RedWhiteBlue", colors, N=n_bins)
753
 
754
  # Create figure
755
  fig_size = 12 if show_labels else 8
 
789
  cbar.set_label("Correlation Strength", rotation=270, labelpad=15)
790
 
791
  # Add annotations explaining the color scheme
792
+ fig.text(0.01, 0.01, "Color scheme: Red (positive correlation), White (neutral), Blue (negative correlation)",
793
  fontsize=8, ha='left')
794
 
795
  # Add explanation of matrix content
796
  explanation = (
797
  "This matrix shows the functional connectivity between brain regions.\n"
798
  "Each cell represents the correlation of activity between two regions.\n"
799
+ "Positive values (red) indicate regions that activate together.\n"
800
  "Negative values (blue) indicate regions with opposite activation patterns."
801
  )
802