123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- '''
- Session-specific NWB parameters
- Parameters that are different for different animals are:
- sessionID
- sessionDescription
- sessionNotes
- areas
- endCh
- probeInserted
- electrodeName
- nChannelsPerShank
- electrodeCoordinates
- electrodeImplantationType
- '''
- import numpy as np
- import datetime
- import os
- import h5py
- import re
- from localFunctions import electrodeLocations
- # General info
- sessionID = ['20190122191103']
- sessionDescription = ['awake restrained']
- sessionNotes = ['Probes advanced to 700 um (z-axis) into the left S1bf and 3250 um (z-axis) into the left VB. Recording was done in an awake head-restraint animal.']
- endCh = [[None] * 2 for i in range(len(sessionID))]
- endCh[0][0] = np.array([16]) # Corresponding probe end channels starting from the tip of the probe. Corresponding and previous end channels are used to work out probe channels that reside in the corresponding brain area.
- endCh[0][1] = np.array([6, 10, 18, 24, 32])
- # Initialise variables
- sessionStartTime = [[None] for i in range(len(sessionID))]
- probeInserted = [[None] * 2 for i in range(len(sessionID))]
- electrodeName = [[None] * 2 for i in range(len(sessionID))]
- electrodeDescription = [[None] * 2 for i in range(len(sessionID))]
- electrodeManufacturer = [[None] * 2 for i in range(len(sessionID))]
- electrodeFolder = [[None] * 2 for i in range(len(sessionID))]
- nShanks = [[None] * 2 for i in range(len(sessionID))]
- nChannelsPerShank = [[None] * 2 for i in range(len(sessionID))]
- nCh = [[None] * 2 for i in range(len(sessionID))]
- electrodeLocation = [[None] * 2 for i in range(len(sessionID))]
- electrodeCoordinates = [[None] * 2 for i in range(len(sessionID))]
- electrodeLabel = [[None] * 2 for i in range(len(sessionID))]
- electrodeImplantationType = [[None] * 2 for i in range(len(sessionID))]
- # Probes info
- for iSess in range(len(sessionID)):
- sessionStartTime[iSess] = datetime.datetime(int(sessionID[iSess][0:4]), int(sessionID[iSess][4:6]), int(sessionID[iSess][6:8]), \
- int(sessionID[iSess][8:10]), int(sessionID[iSess][10:12]), int(sessionID[iSess][12:14]))
-
- # Probe #1 info
- ref = 0 # probe reference
- probeInserted[iSess][ref] = True # If the probe used at all
- if probeInserted[iSess][ref] and endCh[iSess][ref].any():
- electrodeName[iSess][ref] = 'CM16LP-A1x16-Poly2-5mm-50s-177'
- electrodeDescription[iSess][ref] = 'Single shank low density probe in position ' + str(ref+1)
- electrodeManufacturer[iSess][ref] = 'Neuronexus'
- electrodeFolder[iSess][ref] = os.path.join(animalRawDataFolder, sessionID[iSess] + '1')
- if not os.path.isdir(electrodeFolder[iSess][ref]): # in case a probe is missing
- electrodeFolder[iSess][ref] = os.path.normpath(electrodeFolder[iSess][ref][0:-1])
- if re.search('neuropixels', electrodeName[iSess][ref], re.IGNORECASE):
- electrodeMap = os.path.join(electrodeFolder[iSess][ref], 'forPRB_Neuropixels.mat')
- else:
- electrodeMap = os.path.join(electrodeFolder[iSess][ref], 'forPRB_' + electrodeName[iSess][ref] + '.mat')
- electrodeMap = os.path.join(electrodeFolder[iSess][ref], 'forPRB_' + electrodeName[iSess][ref] + '.mat')
- nShanks[iSess][ref] = 1
- nChannelsPerShank[iSess][ref] = 16
- nCh[iSess][ref] = nChannelsPerShank[iSess][ref]*nShanks[iSess][ref] # total number of probe channels
- areas = ['S1'] # brain areas that this probe spans
- electrodeLocation[iSess][ref] = electrodeLocations(areas, endCh[iSess][ref], nCh[iSess][ref]) # Brain area assigned to each recording channel.
- electrodeCoordinates[iSess][ref] = [-1.8, -2.5, 0] # Electrode insertion location on the cortical surface in Paxinos coords: AP (posterior negative), ML (left negative), DV (recording site position starting with the tip of the probe.
- electrodeCoordinates[iSess][ref] = [electrodeCoordinates[iSess][ref]] * nCh[iSess][ref] # Coordinates of each probe recording channel (the probe rotation angle is not taken into account). Y coordinates are relative to the tip of the probe.
- f = h5py.File(electrodeMap,'r')
- ycoords = np.array(f.get('ycoords'))/1000
- electrodeLabel[iSess][ref] = 'probe' + str(ref+1)
- electrodeImplantationType[iSess][ref] = 'chronic'
- else: # The case when the probe #1 is missing
- probeInserted[iSess][ref] = False
- electrodeName[iSess][ref] = []
- electrodeDescription[iSess][ref] = []
- electrodeManufacturer[iSess][ref] = []
- electrodeFolder[iSess][ref] = []
- nShanks[iSess][ref] = []
- nChannelsPerShank[iSess][ref] = []
- nCh[iSess][ref] = []
- electrodeLocation[iSess][ref] = []
- electrodeCoordinates[iSess][ref] = []
- electrodeLabel[iSess][ref] = []
- electrodeImplantationType[iSess][ref] = []
- # Probe #2 info
- ref = 1 # probe reference
- probeInserted[iSess][ref] = True # If the probe used at all
- if probeInserted[iSess][ref] and endCh[iSess][ref].any():
- electrodeName[iSess][ref] = 'CM32-A1x32-Edge-5mm-100-177'
- electrodeDescription[iSess][ref] = 'Single shank low density probe in position ' + str(ref+1)
- electrodeManufacturer[iSess][ref] = 'Neuronexus'
- electrodeFolder[iSess][ref] = os.path.join(animalRawDataFolder, sessionID[iSess] + '26')
- if not os.path.isdir(electrodeFolder[iSess][ref]) or len(os.listdir(electrodeFolder[iSess][ref])) <= 0: # in case the raw data folder name is shorter
- electrodeFolder[iSess][ref] = os.path.normpath(electrodeFolder[iSess][ref][0:-1])
- if not os.path.isdir(electrodeFolder[iSess][ref]): # in case a probe is missing
- electrodeFolder[iSess][ref] = os.path.normpath(electrodeFolder[iSess][ref][0:-1])
- if re.search('neuropixels', electrodeName[iSess][ref], re.IGNORECASE):
- electrodeMap = os.path.join(electrodeFolder[iSess][ref], 'forPRB_Neuropixels.mat')
- else:
- electrodeMap = os.path.join(electrodeFolder[iSess][ref], 'forPRB_' + electrodeName[iSess][ref] + '.mat')
- electrodeMap = os.path.join(electrodeFolder[iSess][ref], 'forPRB_' + electrodeName[iSess][ref] + '.mat')
- nShanks[iSess][ref] = 1
- nChannelsPerShank[iSess][ref] = 32
- nCh[iSess][ref] = nChannelsPerShank[iSess][ref]*nShanks[iSess][ref]
- areas = ['Po','LP','DG','CA1','RSC']
- electrodeLocation[iSess][ref] = electrodeLocations(areas, endCh[iSess][ref], nCh[iSess][ref])
- electrodeCoordinates[iSess][ref] = [-1.8, -0.5, 0]
- electrodeCoordinates[iSess][ref] = [electrodeCoordinates[iSess][ref]] * nCh[iSess][ref]
- f = h5py.File(electrodeMap,'r')
- ycoords = np.array(f.get('ycoords'))/1000
- electrodeLabel[iSess][ref] = 'probe' + str(ref+1)
- electrodeImplantationType[iSess][ref] = 'chronic'
- else: # The case when the probe #2 is missing
- probeInserted[iSess][ref] = False
- electrodeName[iSess][ref] = []
- electrodeDescription[iSess][ref] = []
- electrodeManufacturer[iSess][ref] = []
- electrodeFolder[iSess][ref] = []
- nShanks[iSess][ref] = []
- nChannelsPerShank[iSess][ref] = []
- nCh[iSess][ref] = []
- electrodeLocation[iSess][ref] = []
- electrodeCoordinates[iSess][ref] = []
- electrodeLabel[iSess][ref] = []
- electrodeImplantationType[iSess][ref] = []
|