Repository: rsagroup/rsatoolbox

Issue:
Model visualization doesn't support `rho-a` similarity
**Describe the bug**
Visualization of `rho-a` for comparing RDMs will complain `UnboundLocalError: local variable 'y_label' referenced before assignment`.

**To Reproduce**
Use a random dataset and a random model we can reproduce the bug like this:
```python
import numpy as np
import rsatoolbox

# Create a random dataset
d = rsatoolbox.data.Dataset(measurements=np.random.rand(10, 10))
r = rsatoolbox.rdm.calc_rdm(d, method="correlation")
model = rsatoolbox.model.ModelFixed('random', r)
results = rsatoolbox.inference.eval_bootstrap(models, rdms, N=5, method='rho-a')
rsatoolbox.vis.plot_model_comparison(results)
```

**Expected behavior**
Expected visualization to show up.

**Versions**
```
rsatoolbox==0.1.2
python==3.10.6
```

**Additional context**
Taking a look at the code it's evident that the `get_y_label` function doesn't have an if branch for `rho-a`. I believe this is what caused the issue.

```python
def _get_y_label(method):
    """ generates y-label string

    Args:
        method : String
            Method for model evaluation used

    Returns:
        y_label : String

    """
    if method.lower() == 'cosine':
        y_label = '[across-subject mean of cosine similarity]'
    if method.lower() in ['cosine_cov', 'whitened cosine']:
        y_label = '[across-subject mean of whitened-RDM cosine]'
    elif method.lower() == 'spearman':
        y_label = '[across-subject mean of Spearman r rank correlation]'
    elif method.lower() in ['corr', 'pearson']:
        y_label = '[across-subject mean of Pearson r correlation]'
    elif method.lower() in ['whitened pearson', 'corr_cov']:
        y_label = '[across-subject mean of whitened-RDM Pearson r correlation]'
    elif method.lower() in ['kendall', 'tau-b']:
        y_label = '[across-subject mean of Kendall tau-b rank correlation]'
    elif method.lower() == 'tau-a':
        y_label = '[across-subject mean of ' \
            + 'Kendall tau-a rank correlation]'
    elif method.lower() == 'neg_riem_dist':
        y_label = '[across-subject mean of ' \
            + 'negative riemannian distance]'
    return y_label

```

**stack trace**
```
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
[/Users/xujinliu/projects/MinimalMooneyNet/notebooks/rsa_toolbox.ipynb](https://file+.vscode-resource.vscode-cdn.net/Users/xujinliu/projects/MinimalMooneyNet/notebooks/rsa_toolbox.ipynb) Cell 23 in 8
      [5](vscode-notebook-cell:/Users/xujinliu/projects/MinimalMooneyNet/notebooks/rsa_toolbox.ipynb#X40sZmlsZQ%3D%3D?line=4) rdms = rsr.calc_rdm([x.subset_channel(roi[0], roi[1]) for x in datasets], method=metric_to_use, descriptor='image')
      [7](vscode-notebook-cell:/Users/xujinliu/projects/MinimalMooneyNet/notebooks/rsa_toolbox.ipynb#X40sZmlsZQ%3D%3D?line=6) results = rsatoolbox.inference.eval_bootstrap(models, rdms, method='rho-a')
----> [8](vscode-notebook-cell:/Users/xujinliu/projects/MinimalMooneyNet/notebooks/rsa_toolbox.ipynb#X40sZmlsZQ%3D%3D?line=7) rsatoolbox.vis.plot_model_comparison(results)

File [~/miniconda3/envs/mooney/lib/python3.10/site-packages/rsatoolbox/vis/model_plot.py:481](https://file+.vscode-resource.vscode-cdn.net/Users/xujinliu/projects/MinimalMooneyNet/notebooks/~/miniconda3/envs/mooney/lib/python3.10/site-packages/rsatoolbox/vis/model_plot.py:481), in plot_model_comparison(result, sort, colors, alpha, test_pair_comparisons, multiple_pair_testing, test_above_0, test_below_noise_ceil, error_bars, test_type)
    478 plt.rc('ytick', labelsize=fs2)
    480 # Axis labels
--> 481 y_label_string = _get_y_label(method)
    482 ylabel_fig_x, ysublabel_fig_x = 0.07, 0.095
    483 trans = transforms.blended_transform_factory(fig.transFigure,
    484                                              ax.get_yaxis_transform())

File [~/miniconda3/envs/mooney/lib/python3.10/site-packages/rsatoolbox/vis/model_plot.py:990](https://file+.vscode-resource.vscode-cdn.net/Users/xujinliu/projects/MinimalMooneyNet/notebooks/~/miniconda3/envs/mooney/lib/python3.10/site-packages/rsatoolbox/vis/model_plot.py:990), in _get_y_label(method)
    987 elif method.lower() == 'neg_riem_dist':
    988     y_label = '[across-subject mean of ' \
    989         + 'negative riemannian distance]'
--> 990 return y_label

UnboundLocalError: local variable 'y_label' referenced before assignment
```


Discussion:

Patch:
diff --git a/src/rsatoolbox/vis/model_plot.py b/src/rsatoolbox/vis/model_plot.py
index cd686b53..ce315f8b 100644
--- a/src/rsatoolbox/vis/model_plot.py
+++ b/src/rsatoolbox/vis/model_plot.py
@@ -987,4 +987,7 @@ def _get_y_label(method):
     elif method.lower() == 'neg_riem_dist':
         y_label = '[across-subject mean of ' \
             + 'negative riemannian distance]'
+    elif method.lower() == 'rho-a':
+        y_label = '[across-subject mean of ' \
+            + 'Spearman r rank correlation with random tie-breaking]'
     return y_label


Test patch:
diff --git a/tests/test_vis.py b/tests/test_vis.py
index cb2eeaef..f349faf1 100644
--- a/tests/test_vis.py
+++ b/tests/test_vis.py
@@ -163,11 +163,17 @@ class Test_rdm_plot(TestCase):
 
 
 class Test_model_plot(TestCase):
+    methods_supported = [
+        "corr", "cosine", "cosine_cov", "spearman", "corr_cov",
+        "tau-b", "tau-a", "neg_riem_dist", "rho-a"
+    ]
     def test_y_label(self):
         from rsatoolbox.vis.model_plot import _get_y_label
 
-        y_label = _get_y_label("corr")
-        self.assertIsInstance(y_label, str)
+        for this_method in self.methods_supported:
+            with self.subTest(msg=f"Testing {this_method}..."):
+                y_label = _get_y_label(this_method)
+                self.assertIsInstance(y_label, str)
 
     def test_descr(self):
         from rsatoolbox.vis.model_plot import _get_model_comp_descr