diff --git a/Snakefile b/Snakefile index ef34b09..6a0be36 100644 --- a/Snakefile +++ b/Snakefile @@ -4530,15 +4530,9 @@ rule critical_scaling_pointplot: crit_scaling.append(tmp) crit_scaling = pd.concat(crit_scaling) crit_scaling['model'] = crit_scaling['model'].map(fov.plotting.MODEL_PLOT) - crit_scaling = pd.concat([crit_scaling, fov.figures.wallis_critical_scaling()]) - pal = fov.plotting.get_palette('model', fov.plotting.MODEL_PLOT.values()) - crit_scaling.model = crit_scaling.model.apply(lambda x: x.replace(' model', '')) - pal = {k.replace(' model', ''): v for k, v in pal.items()} - # color copied from Freeman and Simoncelli, 2011's V2 purple - pal['Texture'] = (165/255, 109/255, 189/255) # put dummy data in for this Luminance met vs met, since we # can't actually fit - tmp = crit_scaling.query("model=='Luminance' & trial_type == 'metamer_vs_reference'") + tmp = crit_scaling.query("model=='Luminance model' & trial_type == 'metamer_vs_reference'") tmp['trial_type'] = 'metamer_vs_metamer' if wildcards.norm == 'True': tmp['critical_scaling'] = 8*tmp.critical_scaling @@ -4546,7 +4540,18 @@ rule critical_scaling_pointplot: else: tmp['critical_scaling'] = 24*tmp.critical_scaling crit_scaling = pd.concat([crit_scaling, tmp]) - g = sns.FacetGrid(crit_scaling, hue='model', palette=pal, height=fig_width) + crit_scaling.model = crit_scaling.model.apply(lambda x: f"{x}\n(this study)") + crit_scaling = pd.concat([crit_scaling, fov.figures.wallis_critical_scaling(), + fov.figures.freeman_critical_scaling()]) + pal = fov.plotting.get_palette('model', fov.plotting.MODEL_PLOT.values()) + crit_scaling.model = crit_scaling.model.apply(lambda x: x.replace(' model', '')) + pal = {k.replace(' model', ''): v for k, v in pal.items()} + # color copied from Freeman and Simoncelli, 2011's V2 purple + pal['Texture'] = (165/255, 109/255, 189/255) + pal = {k: pal[k.split()[0]] for k in crit_scaling.model.unique()} + print(crit_scaling) + g = sns.FacetGrid(crit_scaling, hue='model', palette=pal, + height=fig_width, aspect=1.5) g.map_dataframe(fov.plotting.vertical_pointplot, x='model', y='critical_scaling', norm_y=wildcards.norm=='True') ylabel = 'Critical scaling' diff --git a/foveated_metamers/figures.py b/foveated_metamers/figures.py index ec115e4..6302743 100644 --- a/foveated_metamers/figures.py +++ b/foveated_metamers/figures.py @@ -2906,6 +2906,28 @@ def facet_compare(data, **kwargs): return g +def freeman_critical_scaling(): + """Return df with critical scaling values from Freeman and Simoncelli, 2011. + + These are values for the texture and energy models, for the metamer_vs_metamer + comparison. + + Numbers come from Freeman and Simoncelli, 2011, figure 5, extracted with + WebPlotDigitizer. + + Returns + ------- + df : pd.DataFrame + df with critical scaling values. + + """ + crit_scaling = [0.255, 0.483] + model = ['Energy model\n(Freeman)', 'Texture model\n(Freeman)'] + return pd.DataFrame({'critical_scaling': crit_scaling, + 'model': model, + 'trial_type': 'metamer_vs_metamer'}) + + def wallis_critical_scaling(): """Return df with critical scaling values from Wallis et al., 2019. @@ -2929,7 +2951,7 @@ def wallis_critical_scaling(): 'metamer_vs_metamer', 'metamer_vs_metamer'] images = ['texture', 'scene', 'texture', 'scene'] return pd.DataFrame({'critical_scaling': crit_scaling, - 'model': 'Texture model', + 'model': 'Texture model\n(Wallis)', 'trial_type': comp, 'image_type': images}) diff --git a/foveated_metamers/plotting.py b/foveated_metamers/plotting.py index 1a496a4..5bf09d9 100644 --- a/foveated_metamers/plotting.py +++ b/foveated_metamers/plotting.py @@ -2127,7 +2127,7 @@ def vertical_pointplot(data, x, y, norm_y=False, **kwargs): - If there's more than two points contained in data, we groupby model and trial_type and take the mean. - - If the label == 'Luminance', we'll plot the point corresponding to + - If the label == 'Luminance\n(this study)', we'll plot the point corresponding to 'metamer_vs_reference' as 'o' and the one corresponding to 'metamer_vs_metamer' as '$\bigwedge$' (which looks like an up arrow) For all others, both points will be plotted as 'o'. @@ -2167,7 +2167,7 @@ def vertical_pointplot(data, x, y, norm_y=False, **kwargs): data[y] = data[y] / data[y].min() # want the line to be under the points, so set zorder=0 ax.plot(data[x].values, data[y].values, linewidth=lw, zorder=0, **kwargs) - if kwargs['label'] == 'Luminance': + if kwargs['label'] == 'Luminance\n(this study)': marker = {'metamer_vs_reference': 'o', 'metamer_vs_metamer': r'$\bigwedge$'} else: marker = {'metamer_vs_reference': 'o', 'metamer_vs_metamer': 'o'}