Skip to content

Commit

Permalink
starts working on adding Freeman data
Browse files Browse the repository at this point in the history
  • Loading branch information
billbrod committed Oct 21, 2024
1 parent 316bfb3 commit 2b40016
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
21 changes: 13 additions & 8 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4530,23 +4530,28 @@ 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
assert wildcards.logscale == 'log', "if normalized, scale must be log!"
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'
Expand Down
24 changes: 23 additions & 1 deletion foveated_metamers/figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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})


Expand Down
4 changes: 2 additions & 2 deletions foveated_metamers/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down Expand Up @@ -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'}
Expand Down

0 comments on commit 2b40016

Please sign in to comment.