forked from jgrewe/fishbook
change repro add skeleton for stimulus class
This commit is contained in:
parent
c6fc8a857a
commit
8fb7d476e8
25
database.py
25
database.py
@ -165,7 +165,7 @@ class CellDatasetMap(dj.Manual):
|
||||
|
||||
|
||||
@schema
|
||||
class RePro(dj.Manual):
|
||||
class Repro(dj.Manual):
|
||||
definition = """
|
||||
repro_id : varchar(512)
|
||||
run : smallint
|
||||
@ -173,17 +173,30 @@ class RePro(dj.Manual):
|
||||
----
|
||||
repro_name : varchar(512)
|
||||
settings : varchar(3000)
|
||||
start : float
|
||||
duration : float
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_template_tuple(repro_id=None):
|
||||
tup = dict(repro_id=None, dataset_id=None, run=0, repro_name="", settings=None)
|
||||
tup = dict(repro_id=None, dataset_id=None, run=0, repro_name="", settings=None, start=None, duration=None)
|
||||
if repro_id is not None:
|
||||
d = dict((RePro() & {"repro_id": repro_id}).fetch1())
|
||||
return d
|
||||
return tup
|
||||
|
||||
|
||||
@schema
|
||||
class Stimulus(dj.Manual):
|
||||
definition = """
|
||||
stimulus_id : int
|
||||
-> Repro
|
||||
---
|
||||
settings : varchar(3000)
|
||||
start : float
|
||||
duration : float
|
||||
"""
|
||||
|
||||
def populate_datasets(data_path):
|
||||
print("Importing dataset %s" % data_path)
|
||||
if not os.path.exists(data_path):
|
||||
@ -315,7 +328,7 @@ def populate_repros(data_path):
|
||||
if len(rs) == 0:
|
||||
continue
|
||||
rs = rs[0]
|
||||
rp = RePro.get_template_tuple()
|
||||
rp = Repro.get_template_tuple()
|
||||
rp["run"] = rs["Run"]
|
||||
rp["repro_name"] = rs["RePro"]
|
||||
rp["dataset_id"] = dataset["dataset_id"]
|
||||
@ -325,7 +338,9 @@ def populate_repros(data_path):
|
||||
rp["settings"] = ut.nix_metadata_to_yaml(settings[0])
|
||||
else:
|
||||
rp["settings"] = ut.nix_metadata_to_yaml(t.metadata)
|
||||
RePro.insert1(rp, skip_duplicates=True)
|
||||
rp["start"] = t.position[0]
|
||||
rp["duration"] = t.extent[0]
|
||||
Repro.insert1(rp, skip_duplicates=True)
|
||||
f.close()
|
||||
f = None
|
||||
else:
|
||||
@ -353,6 +368,6 @@ def populate(datasets):
|
||||
if __name__ == "__main__":
|
||||
# data_dir = "../../science/high_frequency_chirps/data"
|
||||
data_dir = "../high_freq_chirps/data"
|
||||
datasets = glob.glob(os.path.join(data_dir, '2018*'))
|
||||
datasets = glob.glob(os.path.join(data_dir, '2018-11-20*'))
|
||||
# drop_tables()
|
||||
populate(datasets)
|
||||
|
3
util.py
3
util.py
@ -103,12 +103,13 @@ def nix_metadata_to_yaml(section, cur_depth=0, val_count=1):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
nix_file = "../../science/high_frequency_chirps/data/2018-11-09-aa-invivo-1/2018-11-09-aa-invivo-1.nix"
|
||||
nix_file = "../../science/high_freq_chirps/data/2018-11-09-aa-invivo-1/2018-11-09-aa-invivo-1.nix"
|
||||
f = nix.File.open(nix_file, nix.FileMode.ReadOnly)
|
||||
b = f.blocks[0]
|
||||
yml = nix_metadata_to_yaml(b.tags[0].metadata)
|
||||
print(yml)
|
||||
print("-"* 80)
|
||||
print(nix_metadata_to_yaml(b.metadata))
|
||||
embed()
|
||||
f.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user