예제 #1
0
def MTFplot(meta, intensity, density=False):
    '''
    '''
    intensity = ea.getMTF(meta, intensity)
    variable = ea.findDependentVar(meta)

    fig = plt.figure()
    fig.set_tight_layout(True)
    ax = fig.add_subplot(111)
    pf.AxisFormat(20)
    pf.TufteAxis(ax, ['left', 'bottom'], [5, 5], integer='on')

    cycles = (np.arange(0, intensity['MTF'].shape[1] )) / 2
    cpd = cycles / meta['retImg'] * meta['mm/deg'] 

    for i in range(0, meta['iterations']):

        if variable is not None:
            ax.plot(cpd,
                intensity['MTF'][i, :].T,
                label = '{0}'.format(meta[variable][i]))
        else:
            ax.plot(cpd, intensity['MTF'][i, :].T)

    # plot diffraction limited case:
    diffract, _x = o.diffraction(intensity['MTF'].shape[1], 
                    meta['pupil_size_%'][0], 16.6)
    if not density: 
        ax.plot(_x, diffract, 'k')
    if density:
        ax.semilogx(cpd, decibels(diffract), 'k')

    if variable is not None:
        ax.legend().set_title(variable.replace('_',' ')
            .replace('%','(mm)')
            .replace('&','(y)')
            .replace('D', '(D)')
            .replace('*', '$\\degree$'))

    plt.ylim([0, 1.0])
    plt.xlim([0, 60.0])
    plt.ylabel('modulation transfer')
    plt.xlabel('cycles / deg')
    plt.show()
예제 #2
0
def computeConeActivity(Analysis, ImageData, rec_field, cpd, _meta,
                _brownian=True, glasses=False):
    """Compute the estimated activity of a cone photoreceptor.
    
    :param Receptive_Field: a handle to the spline fitted receptive field.
    :type Receptive_Field: function handle.
    """
    Rec_Field = (rec_field[540]['fft'] / rec_field['max']) 
        
    ImageData['fitLaw'] = ImageData['powerlaw'](cpd[1:])
    powerlaw = ImageData['fitLaw']

    if _brownian:    
        temp = np.arange(1, 80)
        movement_filter = brownian_motion(cpd[1:], temp)
        powerlaw *= movement_filter

    # compute the diffraction limited case seperately
    diffract = {}
    diff, _x = o.diffraction(_meta['samples'], 
                                    _meta['pupil_size'],
                                    16.6, 
                                    ref_index=1.4, 
                                    wavelength=550.0)
    # now interpolate mtf into cpd's of analysis:
    mtf = np.interp(cpd, _x, diff)

    # remove zeros to avoid errors in future computations:
    ind = np.where(mtf != 0)[0]
    diffract['cpd'] = cpd[ind]
    diffract['mtf'] = mtf[ind]

    diffract['preCone'] =  (powerlaw[ind] * 
            diffract['mtf'][ind])
    diffract['retina'] = (diffract['preCone'] *
                                    Rec_Field[ind])

    if glasses:
        # if glasses on, compute effect after diffraction case
        powerlaw *= gauss(cpd[1:], 10)

    for key in Analysis:
        # find cone fft:
        wv = Analysis[key]['wavelength']
        Rec_Field = (rec_field[wv]['fft'] / rec_field['max'])

        # generate MTFs for each condition:
        intensity = traceEye(
                            Analysis[key]['dist'], 
                            Analysis[key]['off_axis'], 
                            Analysis[key]['pupil_size'], 
                            Analysis[key]['focus'],
                            Analysis[key]['wavelength'])
        psf = o.genPSF(intensity, _meta['samples'])[1]
        Analysis[key]['mtf'] = o.genMTF(psf)[ind]

        Analysis[key]['preCone'] = (powerlaw[ind] * 
            Analysis[key]['mtf'])

        Analysis[key]['retina'] = (Analysis[key]['preCone'] *
                                    Rec_Field[ind])

    return Analysis, diffract