Пример #1
0
def plotMovement():
	'''
	'''
	temp = np.arange(1, 80)
	spat = np.arange(0.1, 100, 0.1)
	fig = plt.figure()
	ax = fig.add_subplot(111)
	pf.AxisFormat()
	pf.TufteAxis(ax, ['bottom', 'left'])
	ax.loglog(spat, brownian_motion(spat, temp), 'k')

	ax.set_ylim([10 ** -5, 1.05])
	ax.set_ylabel('transfer')
	ax.set_xlabel('spatial frequency (cycles / deg)')
	plt.tight_layout()
	plt.show()
Пример #2
0
def plotAmpSpec(imageData, figPath='Figures/', _brownian=True, save_plots=False):
    """Plot the amplitude spec of image.

    :param save_plots: decide whether to save plots (True) or not (False)
    :type save_plots: bool        
    
    **This function produces:**
    
    .. figure:: ../../Figures/ampSpec.png
       :height: 300px
       :width: 400px
       :align: center  

       **Fig 1:** An amplitude spectrum of a series of images.
       
    """

    fig = plt.figure(figsize=(8,6))
    ax = fig.add_subplot(111)
    pf.AxisFormat()
    pf.TufteAxis(ax, ['left', 'bottom'], [5, 3])
    
    plaw = imageData['powerlaw'](imageData['imagexval'][10:300])
    if _brownian:
        from emmetrop.eye.movement import brownian_motion
        
        temp = np.arange(1, 80, 1)
        spat = imageData['imagexval'][10:300]
        movement_filter = brownian_motion(spat, temp)
        #ax.semilogx(imageData['imagexval'][10:300], movement_filter, 
        #          'g', linewidth = 2.5)           
        whiteStim = plaw * movement_filter
        whiteStim = sig.decibels(whiteStim)
        ax.semilogx(imageData['imagexval'][10:300], whiteStim, 
                  'k', linewidth = 2.5)     

    plaw = sig.decibels(plaw)
    


    ax.semilogx(imageData['imagexval'][10:300], 
                imageData['decibels'][10:300],
                'r.', markersize = 10, markeredgewidth = 0)
 
    ax.semilogx(imageData['imagexval'][10:300],
                plaw, 
              'k', linewidth = 2.5)
              
    ax.set_xlim([0.45, 15])
                  
    #ax.text(1, 10**-2.4, r'$\frac{1}{\mathit{f}}$', size = 35)

    plt.xlabel('spatial frequency (cycles / deg)')
    plt.ylabel('spectral density (dB)')
    
    plt.tight_layout()
    
    if save_plots:
        fig.show()
        fig.savefig(self.figPath + 'ampSpec.png')
        plt.close()
    else:
        plt.show()
Пример #3
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