import os import scipy.io as sio import cv2 import rateMapUtils #function to find the nearest value to a list def nearestDate(dates, pivot): minimum = min(dates, key=lambda x: abs(x - pivot)) minimum_index = dates.index(minimum) return minimum_index, minimum #read the cheetah clock start time CHEETAH_LOG_FILE_NAME = 'CheetahLogFile.txt' MAIN_NLX_CLOCK_START = rateMapUtils.getNeuralynxStartTime( CHEETAH_LOG_FILE_NAME) #is in the form of HH:MM:SS.Microseconds #Events File Name Events_File_Name = 'Events.nev' #dictionary to hold events info from events.nev file events = {} #list which hold picamera Date time from the raw text file piCameraTime = [] # start maze time and end maze time (will be noted from events file) StartMazeTime = -1 EndMazeTime = -1 #blank black image to draw trajcectory blank_image = np.zeros((720, 720, 3), np.uint8) #convert the main clock start time to timedelta object MAIN_NLX_CLOCK_START = datetime.strptime(MAIN_NLX_CLOCK_START, '%H:%M:%S.%f').time()
# -*- coding: utf-8 -*- """ Created on Tue Sep 13 12:55:58 2016 @author: rajat """ import glob import pickle from datetime import timedelta, datetime import rateMapUtils #read the cheetah clock start time CHEETAH_LOG_FILE_NAME = 'CheetahLogFile.txt' MAIN_NLX_CLOCK_START = rateMapUtils.getNeuralynxStartTime(CHEETAH_LOG_FILE_NAME) MAIN_NLX_CLOCK_START = datetime.strptime(MAIN_NLX_CLOCK_START,'%H:%M:%S.%f').time() #convert the main clock start time to timedelta object MAIN_NLX_CLOCK_START = timedelta(hours=MAIN_NLX_CLOCK_START .hour, minutes=MAIN_NLX_CLOCK_START .minute, seconds=MAIN_NLX_CLOCK_START .second, microseconds=MAIN_NLX_CLOCK_START .microsecond) #input for directory DIRECTORY = str(raw_input('Please enter the path to directory\n')) print "Directory:- " + DIRECTORY + "\n" print "Neuralynx Clock Start Time: " + str(MAIN_NLX_CLOCK_START) # iterates over files starting with "cl-maze" for name in glob.glob(DIRECTORY + "/TT[0-9]*-cl-maze[0-9].[0-9].p"): #dictionary to hold the updated data spikeInfoUpdated = {}
import os import scipy.io as sio import cv2 import rateMapUtils # function to find the nearest value to a list def nearestDate(dates, pivot): minimum = min(dates, key=lambda x: abs(x - pivot)) minimum_index = dates.index(minimum) return minimum_index, minimum # read the cheetah clock start time CHEETAH_LOG_FILE_NAME = "CheetahLogFile.txt" MAIN_NLX_CLOCK_START = rateMapUtils.getNeuralynxStartTime( CHEETAH_LOG_FILE_NAME ) # is in the form of HH:MM:SS.Microseconds # Events File Name Events_File_Name = "Events.nev" # dictionary to hold events info from events.nev file events = {} # list which hold picamera Date time from the raw text file piCameraTime = [] # start maze time and end maze time (will be noted from events file) StartMazeTime = -1 EndMazeTime = -1 # blank black image to draw trajcectory blank_image = np.zeros((720, 720, 3), np.uint8) # convert the main clock start time to timedelta object MAIN_NLX_CLOCK_START = datetime.strptime(MAIN_NLX_CLOCK_START, "%H:%M:%S.%f").time()
#minvalue for occupancy map thresholding (seconds) occMapThreshold = 0.4 #used to set the root root = os.getcwd() for dirname in os.listdir(root): if dirname.startswith('Day'): #set the directory to root same as cd.. in linux os.chdir(root) #set the directory to dirname same as cd dirname in linux os.chdir(dirname) print str(dirname) + '\n' #get neuralynx main clock start time MAIN_NLX_CLOCK_START = rateMapUtils.getNeuralynxStartTime(CHEETAH_LOG_FILE_NAME) MAIN_NLX_CLOCK_START = datetime.strptime(MAIN_NLX_CLOCK_START,'%H:%M:%S.%f').time() #convert the main clock start time to timedelta object MAIN_NLX_CLOCK_START = timedelta(hours=MAIN_NLX_CLOCK_START .hour, minutes=MAIN_NLX_CLOCK_START .minute, seconds=MAIN_NLX_CLOCK_START .second, microseconds=MAIN_NLX_CLOCK_START .microsecond) print 'Neuralynx Start Time: ' + str(MAIN_NLX_CLOCK_START) + '\n' #get start acquisition time for cheetah log file START_ACQ_NTP_TIME, START_ACQ_SXBOX_TIME = rateMapUtils.getNeuralynxStartAcqTime(CHEETAH_LOG_FILE_NAME) print 'Neuralynx Start Acquisition Time acc to NTP Server: ' + str(START_ACQ_NTP_TIME) print 'Neuralynx Start Acquisition Time acc to SX Box: ' + str(START_ACQ_SXBOX_TIME) + '\n' #check if already processed data exists in directory processedDataExists = rateMapUtils.checkIfProcessedDataExists(os.getcwd(), NlxFlag=True) #if processed data exists, use that for rate map generation if processedDataExists: