Пример #1
0
    def saveCCFPositionsAsArray(self, appendEntry=True):
        for pid in self.probes_to_analyze:
            f = os.path.join(self.dataDir,
                             'UnitAndTipCCFPositions_probe' + pid + '.npy')
            d = np.array([
                self.units[pid][u]['ccf']
                for u in probeSync.getOrderedUnits(self.units[pid])
            ]).astype(float)
            if appendEntry:
                d = np.concatenate(
                    (d, self.probeCCF[pid]['entry'][None, :3])).astype(
                        float)  # add probe entry point
            d /= 25  # 25 um per ccf voxel
            d += 1  # for ImageGui

            rf = os.path.join(self.dataDir,
                              'VisualResponsiveness_probe' + pid + '.npy')
            r = np.array([
                self.units[pid][u]['peakMeanVisualResponse']
                for u in probeSync.getOrderedUnits(self.units[pid])
            ]).astype(float)
            if appendEntry:
                r = np.append(r, np.median(r)).astype(
                    float)  # add probe entry point

            np.save(f, d)
            np.save(rf, r)
Пример #2
0
def plotLFPNoise(obj, agarChRange=None, timeRange=[0, 10]):
    for pid in obj.probes_to_analyze:
        t = obj.lfp[pid]['time']
        d = obj.lfp[pid]['data']
        i = (t >= t[0] + timeRange[0]) & (t <= t[0] + timeRange[1])
        if agarChRange is None:
            d = d[i]
        else:
            agar = np.median(d[i, agarChRange[0]:agarChRange[1]], axis=1)
            d = d[i] - agar[:, None]

        peakChan = [
            obj.units[pid][u]['position'][1] / 10
            for u in probeSync.getOrderedUnits(obj.units[pid])
        ]
        unitCount, bins = np.histogram(peakChan, range(d.shape[1] + 1))

        fig = plt.figure()
        ax = plt.subplot(1, 1, 1)
        ax2 = ax.twinx()
        ax2.plot(unitCount, 'b')
        ax2.set_ylabel('Unit Count', color='b')
        ax.plot(d.std(axis=0), 'k')
        ax.set_xlabel('Channel')
        ax.set_ylabel('Noise')
Пример #3
0
def all_unit_summary(obj, probesToAnalyze=None, name_tag = ''):
    plt.close('all')
    if probesToAnalyze is None:
        probesToAnalyze = obj.probes_to_analyze
    for pid in probesToAnalyze:
        multipageObj = PdfPages(os.path.join(obj.dataDir, 'SummaryPlots_' + pid + name_tag + '.pdf'))
        try:
            orderedUnits = probeSync.getOrderedUnits(obj.units[pid])
            for u in orderedUnits:
                plot_unit_summary(obj, pid, u, multipageObj)
                plot_unit_behavior_summary(obj, pid, u, multipageObj)
        finally:
            multipageObj.close()
Пример #4
0
    def getUnitsByArea(self, area, cortex=True):
        pids = []
        us = []
        for pid in self.probes_to_analyze:
            for u in probeSync.getOrderedUnits(self.units[pid]):

                if cortex:
                   if self.units[pid][u]['inCortex'] and area==self.probeCCF[pid]['ISIRegion']:
                       pids.append(pid)
                       us.append(u)
                else:
                    if area==self.units[pid][u]['ccfRegion']:
                        pids.append(pid)
                        us.append(u)
        return np.array(pids), np.array(us)
Пример #5
0
    
    selectedTrials = (b.hit | b.miss)&(~b.ignore)
    changeTimes = b.frameAppearTimes[np.array(b.trials['change_frame'][selectedTrials]).astype(int)+1] #add one to correct for change frame indexing problem
    image_flash_times = b.frameAppearTimes[np.array(b.core_data['visual_stimuli']['frame'])]
    image_id = np.array(b.core_data['visual_stimuli']['image_name'])
    preChangeIndices = np.searchsorted(image_flash_times, changeTimes)-1
    preChangeTimes = image_flash_times[preChangeIndices]
    preChangeIDs = image_id[preChangeIndices]
    changeIDs = image_id[preChangeIndices+1] #double check to make sure this worked
    
    regionsOfInterest = ['VISam', 'VISpm', 'VISp', 'VISl', 'VISal', 'VISrl']
    preTime = 0.25
    postTime = 0.5

    for pid in b.probes_to_analyze:
        for u in probeSync.getOrderedUnits(b.units[pid]):
            spikes = b.units[pid][u]['times']
            
            #exclude cells that fire below 1Hz during task
            if np.sum(spikes<3600)<3600: 
                continue
            
            #check if RF
            if rfFilter:
                rfmat = summaryPlots.plot_rf(b, spikes, plot=False, returnMat=True)
                if rfmat[1].max() < 99.9:
                    continue
                
            changesdfs = []
            presdfs = []            
            for im in np.unique(preChangeIDs):