From c6b4869b012d4e2338d923f165912f5547e94c53 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Mon, 12 Nov 2018 10:49:31 +0100 Subject: [PATCH] reading of spike times --- code/read_chirp_data.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 code/read_chirp_data.py diff --git a/code/read_chirp_data.py b/code/read_chirp_data.py new file mode 100644 index 0000000..2cd1055 --- /dev/null +++ b/code/read_chirp_data.py @@ -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)) +