| 1 |
import nixio |
| 2 |
|
| 3 |
def main(): |
| 4 |
|
| 5 |
nixfile = nixio.File.open("annotations.nix", mode=nixio.FileMode.Overwrite) |
| 6 |
block = nixfile.create_block("recording 1", "nix.session") |
| 7 |
|
| 8 |
session = nixfile.create_section('recording session', 'odml.recording') |
| 9 |
session['experimenter'] = 'John Doe' |
| 10 |
session['recording date'] = '2014-01-01' |
| 11 |
|
| 12 |
subject = session.create_section('subject', 'odml.subject') |
| 13 |
subject['id'] = 'mouse xyz' |
| 14 |
|
| 15 |
cell = subject.create_section('cell', 'odml.cell') |
| 16 |
p = cell.create_property('resting potential', -64.5) |
| 17 |
p.uncertainty = 2.25 |
| 18 |
p.unit = 'mV' |
| 19 |
|
| 20 |
|
| 21 |
block.metadata = session |
| 22 |
|
| 23 |
|
| 24 |
block.metadata.pprint(max_depth=-1) |
| 25 |
|
| 26 |
print(block.metadata["subject"]["cell"]["resting potential"]) |
| 27 |
|
| 28 |
print(session.find_sections(lambda s: s.name.lower() == "cell")) |
| 29 |
|
| 30 |
print(session.find_sections(lambda s: "resting potential" in s.props)) |
| 31 |
print(session.find_sections(lambda s: "resting potential" in s.props)[0]["resting potential"]) |
| 32 |
|
| 33 |
observations = subject.create_property("observations", ["p10", "p12", "p14"]) |
| 34 |
observations.definition = "Some behavioral observations I did on several days" |
| 35 |
print(observations.values) |
| 36 |
|
| 37 |
observations.extend_values("p16") |
| 38 |
observations.extend_values(["p18", "p20"]) |
| 39 |
|
| 40 |
try: |
| 41 |
observations.extend_values(22) |
| 42 |
except TypeError as e: |
| 43 |
print(e) |
| 44 |
|
| 45 |
nixfile.close() |
| 46 |
|
| 47 |
if __name__ == "__main__": |
| 48 |
main() |