diff --git a/code/read_chirp_data.py b/code/read_chirp_data.py index 5067922..3f53381 100644 --- a/code/read_chirp_data.py +++ b/code/read_chirp_data.py @@ -33,12 +33,40 @@ def load_chirp_spikes(dataset): return spikes +def load_chirp_eod(dataset): + eod_file = os.path.join(dataset, "chirpeodampls.dat") + if not os.path.exists(eod_file): + print("found no chirpeodampls.dat!") + return {} + with open(eod_file, 'r') as f: + lines = f.readlines() + chirp_eod = {} + 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 "chirpsize" in l: + cs = l.split(":")[-1] + if "#Key" in l: + chirp_eod[(index, df, contrast, cs)] = ([], []) + if len(l.strip()) != 0 and "#" not in l: + time = float(l.split()[0]) + ampl = float(l.split()[1]) + chirp_eod[(index, df, contrast, cs)][0].append(time) + chirp_eod[(index, df, contrast, cs)][1].append(ampl) + return chirp_eod + + def load_chirp_times(dataset): - spikes_file = os.path.join(dataset, "chirpss.dat") - if not os.path.exists(spikes_file): + chirp_times_file = os.path.join(dataset, "chirpss.dat") + if not os.path.exists(chirp_times_file): print("found no chirpss.dat!") return {} - with open(spikes_file, 'r') as f: + with open(chirp_times_file, 'r') as f: lines = f.readlines() chirp_times = {} for l in lines: @@ -63,4 +91,6 @@ if __name__ == "__main__": dataset = "2018-11-09-ad-invivo-1" spikes = load_chirp_spikes(os.path.join(data_dir, dataset)) chirp_times = load_chirp_times(os.path.join(data_dir, dataset)) + chirp_eod = load_chirp_eod(os.path.join(data_dir, dataset)) embed() +