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):
|
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,19 +465,25 @@ 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"]])
|
||||||
@ -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:
|
||||||
|
@ -207,7 +207,16 @@ class StimSpikesFile:
|
|||||||
for l in lines:
|
for l in lines:
|
||||||
l = l.strip()
|
l = l.strip()
|
||||||
if "duration:" in l:
|
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 "index:" in l:
|
||||||
if len(trial_data) > 0:
|
if len(trial_data) > 0:
|
||||||
index_map[(index, trial)] = (trial_duration, trial_data)
|
index_map[(index, trial)] = (trial_duration, trial_data)
|
||||||
|
Loading…
Reference in New Issue
Block a user