reading of spike times
This commit is contained in:
parent
44147bdc1c
commit
c6b4869b01
38
code/read_chirp_data.py
Normal file
38
code/read_chirp_data.py
Normal file
@ -0,0 +1,38 @@
|
||||
import numpy as np
|
||||
import os
|
||||
from IPython import embed
|
||||
|
||||
|
||||
def load_chirp_spikes(dataset):
|
||||
spikes_file = os.path.join(dataset, "chirpspikess1.dat")
|
||||
if not os.path.exists(spikes_file):
|
||||
print("found no chirps!")
|
||||
return {}
|
||||
with open(spikes_file, 'r') as f:
|
||||
lines = f.readlines()
|
||||
spikes = {}
|
||||
for l in lines:
|
||||
l = l.strip()
|
||||
if "index" in l and "chirp" not in l:
|
||||
index = int(l.split(":")[-1])
|
||||
if "deltaf" in l and "true" not in l:
|
||||
df = l.split(":")[-1]
|
||||
if "contrast" in l and "true" not in l:
|
||||
contrast = l.split(":")[-1]
|
||||
if "#Key" in l:
|
||||
spikes[(index, df, contrast)] = {}
|
||||
if "chirp index" in l:
|
||||
ci = int(l.split(":")[-1])
|
||||
if "beat phase" in l:
|
||||
phase = float(l.split(":")[-1])
|
||||
spikes[(index, df, contrast)][(ci, phase)] = []
|
||||
if len(l.strip()) != 0 and "#" not in l:
|
||||
spikes[(index, df, contrast)][(ci, phase)].append(float(l))
|
||||
return spikes
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
data_dir = "../data"
|
||||
dataset = "2018-11-09-ad-invivo-1"
|
||||
spikes = load_chirp_spikes(os.path.join(data_dir, dataset))
|
||||
|
Loading…
Reference in New Issue
Block a user