def fit_pRF_radius(ctx, retinotopy=Ellipsis, mask=None, weight=Ellipsis, slope_only=False):
rdat = retinotopy_data(ctx, retinotopy)<EOL>if '<STR_LIT>' not in rdat: raise ValueError('<STR_LIT>' % retinotopy)<EOL>rad = rdat['<STR_LIT>']<EOL>(ang,ecc) = as_retinotopy(rdat, '<STR_LIT>')<EOL>if isinstance(mask, (set, frozenset)):<EOL><INDENT>mask = reduce(np.intersect1d, [ctx.mask(m, indices=True) for m in mask])<EOL><DEDENT>else: mask = ctx.mask(mask, indices=True)<EOL>if weight in [False, None]: wgt = np.ones(rad.shape)<EOL>elif weight in [True, Ellipsis]:<EOL><INDENT>if '<STR_LIT>' in rdat: wgt = rdat['<STR_LIT>']<EOL>else: wgt = np.ones(rad.shape)<EOL><DEDENT>else: wgt = ctx.property(weight)<EOL>(ecc,rad,wgt) = [x[mask] for x in (ecc,rad,wgt)]<EOL>if slope_only:<EOL><INDENT>ecc = np.reshape(ecc * wgt, (len(ecc), <NUM_LIT:1>))<EOL>rad = np.reshape(rad * wgt, (len(rad), <NUM_LIT:1>))<EOL>return np.linalg.lstsq(ecc, rad)[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return tuple(np.polyfit(ecc, rad, <NUM_LIT:1>, w=wgt))<EOL><DEDENT>
fit_pRF_radius(ctx) fits a line, m*eccen + b, to the pRF radius and yields the tuple (m, b).

The following options may be given:
  * retinotopy (default: Ellipsis) specifies the prefix for the retinotopy (passed to
    retinotopy_data() to find the retinotopic dataset).
  * mask (default: None) specifies the mask over which to perform the calculation. This is
    passed to the to_mask() function. In the case that mask is a set or frozenset, then it is
    treated as a conjunction (intersection) of masks.
  * weight (default: None) specifies that a weight should be used; if this is True or Ellipsis,
    will use the variance_explained if it is part of the retinotopy dataset; if this is False or
    None, uses no weight; otherwise, this must be a weight property or property name.
  * slope_only (default: False) may be set to True to instead fit radius = m*eccen and return
    only m.