Esempio n. 1
0
 def __init__(self, baseDir=None, probes=None, probeGen='3b'):
     if baseDir is None:
         self.dataDir = dataDir
     else:
         self.dataDir = baseDir
     sync_file = glob.glob(
         os.path.join(self.dataDir, '*' + ('[0-9]' * 18) + '.h5'))
     self.sync_file = sync_file[0] if len(sync_file) > 0 else None
     self.syncDataset = sync.Dataset(
         self.sync_file) if self.sync_file is not None else None
     if probes is None:
         self.probes_to_analyze = probeIDs
     else:
         self.probes_to_analyze = probes
     self.experimentDate = os.path.basename(self.dataDir)[:8]
     self.probeGen = probeGen
     if probeGen == '3b':
         if datetime.datetime.strptime(self.experimentDate,
                                       '%m%d%Y') < datetime.datetime(
                                           2019, 3, 15):
             fprobe = '4'
         else:
             fprobe = '3'
         self.PXIDict = {
             'A': 'slot2-probe1',
             'B': 'slot2-probe2',
             'C': 'slot2-probe3',
             'D': 'slot3-probe1',
             'E': 'slot3-probe2',
             'F': 'slot3-probe' + fprobe
         }
     else:
         self.PXIDict = None
Esempio n. 2
0
    def __init__(self, baseDir=None, probes=None, probeGen='3b'):
        if baseDir is None:
            self.dataDir = dataDir
        else:
            self.dataDir = baseDir

        if probeGen == 'pipeline':
            sync_file = glob.glob(os.path.join(self.dataDir, '*.sync'))
        else:
            sync_file = glob.glob(
                os.path.join(self.dataDir, '*' + ('[0-9]' * 18) + '.h5'))

        if len(sync_file) > 0:
            if len(sync_file) > 1:
                # get the last generated syncfile (assuming earlier were false starts)
                ftime = []
                for f in sync_file:
                    i = f.find('.')
                    ftime.append(
                        datetime.datetime.strptime(f[i - 6:i], '%H%M%S'))
                self.sync_file = sync_file[ftime.index(max(ftime))]
            else:
                self.sync_file = sync_file[0]
        else:
            self.sync_file = None

        self.syncDataset = sync.Dataset(
            self.sync_file) if self.sync_file is not None else None
        if probes is None:
            self.probes_to_analyze = probeIDs
        else:
            self.probes_to_analyze = probes
        self.experimentDate = os.path.basename(self.dataDir)[:8]
        self.probeGen = probeGen
        if probeGen == '3b':
            if datetime.datetime.strptime(self.experimentDate,
                                          '%m%d%Y') < datetime.datetime(
                                              2019, 3, 15):
                fprobe = '4'
            else:
                fprobe = '3'
            self.PXIDict = {
                'A': 'slot2-probe1',
                'B': 'slot2-probe2',
                'C': 'slot2-probe3',
                'D': 'slot3-probe1',
                'E': 'slot3-probe2',
                'F': 'slot3-probe' + fprobe
            }
        else:
            self.PXIDict = None
Esempio n. 3
0
 def loadFromHDF5(self, filePath=None):
     fileIO.hdf5ToObj(self,filePath)
     self.syncDataset = sync.Dataset(self.sync_file)
     self.getBehaviorData()
     self.getRFandFlashStimInfo()
ymin = rawData[channelsToPlot, samplesToPlot].min()
ymax = rawData[channelsToPlot, samplesToPlot].max()
for i, ch in enumerate(channelsToPlot):
    ax = fig.add_subplot(len(channelsToPlot), 1, i + 1)
    ax.plot(rawData[ch, samplesToPlot], 'k')
    for side in ('right', 'top'):
        ax.spines[side].set_visible(False)
    ax.set_ylim([ymin, ymax])
    ax.set_ylabel('uV')
    if i == len(channelsToPlot) - 1:
        ax.set_xlabel('Sample')
    ax.set_title('ch ' + str(ch))
plt.tight_layout()

# sync data
syncDataset = sync.Dataset(syncFile)

probeEventsDir = os.path.join(
    os.path.join(probeDataDir, 'events',
                 'Neuropix-PXI-' + pxiDict[probeLabel]), 'TTL_1')

# get barcodes from sync file
bRising, bFalling = get_sync_line_data(syncDataset, 'barcode')
bs_t, bs = ecephys.extract_barcodes_from_times(bRising, bFalling)

# get barcodes from ephys data
channel_states = np.load(os.path.join(probeEventsDir, 'channel_states.npy'))
event_times = np.load(os.path.join(probeEventsDir, 'event_timestamps.npy'))

beRising = event_times[channel_states > 0] / 30000.
beFalling = event_times[channel_states < 0] / 30000.
Esempio n. 5
0
#    plotPerformance(exps,label=reg,sessions=sessions,led=led)



#
syncFiles = []
while True:
    f = fileIO.getFile('choose sync file',fileType='*.h5')
    if f!='':
        syncFiles.append(f)
    else:
        break

ledOnset = []
for i,(f,obj) in enumerate(zip(syncFiles,exps)):
    syncDataset = sync.Dataset(f)
    
    frameRising, frameFalling = probeSync.get_sync_line_data(syncDataset, 'vsync_stim')
    vsyncTimes = frameFalling[1:] if frameFalling[0] < frameRising[0] else frameFalling
    frameAppearTimes = vsyncTimes + obj.monitorLag/obj.frameRate
    
    binWidth = 0.001
    for laserInd,ch in enumerate((11,1)):
        laserRising,laserFalling = probeSync.get_sync_line_data(syncDataset,channel=ch)
        if len(laserRising)>0:
            laserTrials = obj.laser==laserInd
            ct = frameAppearTimes[obj.changeFrames[laserTrials & (obj.changeTrials | obj.catchTrials)].astype(int)]
            fig = plt.figure(figsize=(6,6))
            for j,(t,xlbl) in enumerate(zip((laserRising,laserFalling),('onset','offset'))):
                timeFromChange = t[~obj.laserOnBeforeAbort[laserTrials]]-ct
                if xlbl=='onset':