Beispiel #1
0
def processInformation(expName='GNS', spikeFile='GaussianNatScene.spk', dnew={}):
    '''
    Load spikes from spikeFile
    Extract last parameters used from expName in parameters.txt
    Update any parameters according to dnew (in case I want to change something)

    do whatever processing I feel is necessary
    '''
    # load basic dictionary with experimental data, cells and the seq of Home and Targets
    print('Loading cells and variables')
    d, cells, blockSeq, blockStartT, blockEndT = preProcess(expName, spikeFile)
    d.update(dnew)

    # Define a TW for computing basic response properties
    TW_startT = .05
    TW_endT = .20
    binsN = 4
    eventStartT = _np.array(blockStartT) + TW_startT
    eventEndT = _np.array(blockStartT) + TW_endT
    binLength = (TW_endT - TW_startT)/binsN

    # compute Latency and spike count
    print('Processing Latency for all cells')
    latency = ba.processNested(rt.getLatency, 0, cells, eventStartT, eventEndT, noSpikeSymbol = - binLength/2)
    print('Processing Spike Count for all cells')
    spkCnt = ba.processNested(rt.getSpkCnt, 0, cells, eventStartT, eventEndT)

    # convert latency into discrete symbols (for each cell)
    latency = ba.processNested(lambda x: _np.floor(x/binLength), 0, latency)
    
    # combine latency and spkCnt into a unique symbol
    spkCntLat = ba.processNested(lambda x, y: list(zip(x, y)), 0, latency, spkCnt)


    # process information
    print('Processing Information')
    latencyInfo = ba.processNested(info.mi, 0, latency, blockSeq)
    spkCntInfo = ba.processNested(info.mi, 0, spkCnt, blockSeq)
    spkCntLatInfo = [info.mi(spkCntLat[i], blockSeq) for i in range(len(cells))]

    # as a control, process information with a shuffled version of blockSeq
    shuffled = blockSeq.copy()
    _np.random.shuffle(shuffled)
    latencyInfoSh = ba.processNested(info.mi, 0, latency, shuffled)
    spkCntInfoSh = ba.processNested(info.mi, 0, spkCnt, shuffled)
    spkCntLatInfoSh = [info.mi(spkCntLat[i], shuffled) for i in range(len(cells))]
    
    
    # make a nice plot
    print('Plotting information')
    _plt.close('Information')
    _plt.figure('Information')
    _plt.plot(latencyInfo, 'ro', label = 'Latency')
    _plt.plot(spkCntInfo, 'bo', label = 'Spike Count')
    _plt.plot(spkCntLatInfo, 'ko', label = 'Lat and SpkCnt')
    _plt.plot(latencyInfoSh, 'r.')
    _plt.plot(spkCntInfoSh, 'b.')
    _plt.plot(spkCntLatInfoSh, 'k.')
    _plt.ylabel('Information (Bits)')
    _plt.xlabel('Image ID')
    _plt.title('Mutual Information')
    _plt.legend()
    _plt.xlim(-.5, len(cells)+.5)
    _plt.show()

    return d, cells, latency, spkCnt, blockSeq, latencyInfo, spkCntInfo, spkCntLatInfo