Merge pull request 'more fixes for old datasets' (#5) from relacs into master
Reviewed-on: jgrewe/fishBook#5
This commit is contained in:
commit
8b93d92f4d
@ -453,7 +453,9 @@ def scan_nix_file_for_repros(dataset):
|
||||
def scan_folder_for_repros(dataset):
|
||||
print("\t\tNo nix-file, scanning directory!")
|
||||
repro_settings, stim_indices = read_stimuli_file(dataset["data_source"])
|
||||
repro_counts = {}
|
||||
repro_counts = {} # internal counter for repro runs, for cases in which the repro does not have a run counter
|
||||
repros_skipped = {} # internal counter to correct the run counter for repro runs in which no stimulus was put out, needed to align e.g. with stimspikes file
|
||||
repros_without_stims = ["baselineactivity"]
|
||||
cell_id = (Cells * CellDatasetMap * (Datasets & "dataset_id = '%s'" % dataset["dataset_id"])).fetch("cell_id", limit=1)[0]
|
||||
for rs, si in zip(repro_settings, stim_indices):
|
||||
rp = Repros.get_template_tuple()
|
||||
@ -463,20 +465,26 @@ def scan_folder_for_repros(dataset):
|
||||
find_key_recursive(rs, "RePro", path)
|
||||
rp["repro_name"] = deep_get(rs, path, "None")
|
||||
|
||||
if rp["repro_name"] not in repros_skipped.keys():
|
||||
repros_skipped[rp["repro_name"]] = 0
|
||||
|
||||
if rp["repro_name"].lower() not in repros_without_stims and len(si) == 0:
|
||||
repros_skipped[rp["repro_name"]] += 1
|
||||
continue
|
||||
|
||||
path = []
|
||||
if rp["repro_name"] in repro_counts.keys():
|
||||
repro_counts[rp["repro_name"]] += 1
|
||||
else:
|
||||
repro_counts[rp["repro_name"]] = 0
|
||||
|
||||
path = []
|
||||
if not find_key_recursive(rs, "run", path):
|
||||
find_key_recursive(rs, "Run", path)
|
||||
if len(path) > 0:
|
||||
rp["run"] = deep_get(rs, path, 0)
|
||||
rp["run"] = int(deep_get(rs, path, 0)) - repros_skipped[rp["repro_name"]]
|
||||
else: # the run information is not there and needs to be fixed!
|
||||
rp["run"] = repro_counts[rp["repro_name"]]
|
||||
|
||||
rp["run"] = repro_counts[rp["repro_name"]] - repros_skipped[rp["repro_name"]]
|
||||
|
||||
rp["cell_id"] = cell_id
|
||||
rp["repro_id"] = rp["repro_name"] + str(repro_counts[rp["repro_name"]])
|
||||
rp["start"] = 0.
|
||||
@ -501,8 +509,10 @@ def scan_folder_for_repros(dataset):
|
||||
find_key_recursive(rs, "Duration", path)
|
||||
if len(path) > 0 :
|
||||
stim_duration = deep_get(rs, path, None)
|
||||
if "ms" in stim_duration:
|
||||
stim_duration = float(stim_duration[:stim_duration.index("ms")])
|
||||
if "sec" in stim_duration:
|
||||
stim_duration = float(stim_duration[:stim_duration.index("sec")])
|
||||
elif "ms" in stim_duration:
|
||||
stim_duration = float(stim_duration[:stim_duration.index("ms")]) / 1000
|
||||
else:
|
||||
stim_duration = float(stim_duration[:stim_duration.index("s")])
|
||||
else:
|
||||
|
@ -207,7 +207,16 @@ class StimSpikesFile:
|
||||
for l in lines:
|
||||
l = l.strip()
|
||||
if "duration:" in l:
|
||||
trial_duration = float(l[1:].strip().split(":")[-1][:-3])
|
||||
trial_duration = l[1:].strip().split(":")[-1].strip()
|
||||
if "sec" in trial_duration:
|
||||
trial_duration = float(trial_duration[:-3])
|
||||
elif "ms" in trial_duration:
|
||||
trial_duration = float(trial_duration[:-2]) / 1000
|
||||
elif trial_duration[-1] == 's':
|
||||
trial_duration = float(trial_duration[:1])
|
||||
else:
|
||||
trial_duration = 0.0
|
||||
print(l, trial_duration)
|
||||
if "index:" in l:
|
||||
if len(trial_data) > 0:
|
||||
index_map[(index, trial)] = (trial_duration, trial_data)
|
||||
|
Loading…
Reference in New Issue
Block a user