more fixes for old datasets #5

Merged
csachgau merged 2 commits from relacs into master 2020-08-14 15:26:51 +00:00
Showing only changes of commit 6e2bfde2dc - Show all commits

View File

@ -453,7 +453,9 @@ def scan_nix_file_for_repros(dataset):
def scan_folder_for_repros(dataset): def scan_folder_for_repros(dataset):
print("\t\tNo nix-file, scanning directory!") print("\t\tNo nix-file, scanning directory!")
repro_settings, stim_indices = read_stimuli_file(dataset["data_source"]) 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] 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): for rs, si in zip(repro_settings, stim_indices):
rp = Repros.get_template_tuple() rp = Repros.get_template_tuple()
@ -463,20 +465,26 @@ def scan_folder_for_repros(dataset):
find_key_recursive(rs, "RePro", path) find_key_recursive(rs, "RePro", path)
rp["repro_name"] = deep_get(rs, path, "None") 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 = [] path = []
if rp["repro_name"] in repro_counts.keys(): if rp["repro_name"] in repro_counts.keys():
repro_counts[rp["repro_name"]] += 1 repro_counts[rp["repro_name"]] += 1
else: else:
repro_counts[rp["repro_name"]] = 0 repro_counts[rp["repro_name"]] = 0
path = [] path = []
if not find_key_recursive(rs, "run", path): if not find_key_recursive(rs, "run", path):
find_key_recursive(rs, "Run", path) find_key_recursive(rs, "Run", path)
if len(path) > 0: 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! 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["cell_id"] = cell_id
rp["repro_id"] = rp["repro_name"] + str(repro_counts[rp["repro_name"]]) rp["repro_id"] = rp["repro_name"] + str(repro_counts[rp["repro_name"]])
rp["start"] = 0. rp["start"] = 0.
@ -501,8 +509,10 @@ def scan_folder_for_repros(dataset):
find_key_recursive(rs, "Duration", path) find_key_recursive(rs, "Duration", path)
if len(path) > 0 : if len(path) > 0 :
stim_duration = deep_get(rs, path, None) stim_duration = deep_get(rs, path, None)
if "ms" in stim_duration: if "sec" in stim_duration:
stim_duration = float(stim_duration[:stim_duration.index("ms")]) 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: else:
stim_duration = float(stim_duration[:stim_duration.index("s")]) stim_duration = float(stim_duration[:stim_duration.index("s")])
else: else: