Created
October 1, 2018 22:37
-
-
Save nicain/498e8199c887257578de9cfdb2a6da67 to your computer and use it in GitHub Desktop.
EpochTable Hello World
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pynwb import NWBFile, NWBHDF5IO, TimeSeries | |
from pynwb.epoch import Epochs | |
import os | |
import pandas as pd | |
import datetime | |
nwbfile = NWBFile( | |
source='Data source', | |
session_description='test', | |
identifier='test', | |
session_start_time=datetime.datetime.now(), | |
file_create_date=datetime.datetime.now() | |
) | |
stimulus_table = pd.DataFrame({'start_time':[0.,1.,2.], 'end_time':[1.,2.,3.], 'example_metadata':['a', 'b', 'c']}) | |
nwbfile.add_epoch_metadata_column(name='example_metadata', description='what do this column\'s values mean?') | |
for _, row_series in stimulus_table.iterrows(): | |
row = row_series.to_dict() | |
start_time = row.pop('start_time') | |
stop_time = row.pop('end_time') | |
nwbfile.create_epoch(start_time=start_time, | |
stop_time=stop_time, | |
timeseries=[], | |
tags='stimulus', | |
description='Stimulus Presentation Epoch', | |
metadata=row) | |
print nwbfile.epochs.metadata.columns[0].data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment