Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent behavior of aeon.preprocess.api.pelletdata #12

Closed
joacorapela opened this issue Jun 25, 2021 · 0 comments · Fixed by #7
Closed

inconsistent behavior of aeon.preprocess.api.pelletdata #12

joacorapela opened this issue Jun 25, 2021 · 0 comments · Fixed by #7
Assignees

Comments

@joacorapela
Copy link

joacorapela commented Jun 25, 2021

In the script below if I call

pellet_vals = aeon.preprocess.api.pelletdata(root, patch_name, start=t0_absolute, end=tf_absolute)

with t0_absolute=0 the return value is an empty DatetimeIndex but if I use t0_absolute=12000 the return value is an empty Index.

Ideally it should always return an empty DatetimeIndex. Can this be fixed?

Thanks.

import sys
import pdb
import datetime
import argparse

import aeon.preprocess.api
import aeon.preprocess.utils


def main(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument("--root", help="Root path for data access", default="/ceph/aeon/test2/experiment0.1")
    parser.add_argument("--session", help="Session index", default=3, type=int)
    parser.add_argument("--start_time", help="Start time (sec)", default=12000.0, type=float)
    parser.add_argument("--duration", help="Duration (sec)", default=600.0, type=float)
    parser.add_argument("--patch_name", help="Patch name", default="Patch2")
    parser.add_argument("--pellet_event_name", help="Pellet event name to display", default="TriggerPellet")

    args = parser.parse_args()

    root = args.root
    session = args.session
    t0_relative = args.start_time
    requested_duration = args.duration
    tf_relative = args.start_time+args.duration
    patch_name = args.patch_name
    pellet_event_name = args.pellet_event_name

    metadata = aeon.preprocess.api.sessiondata(root)
    metadata = metadata[metadata.id.str.startswith('BAA')]
    metadata = aeon.preprocess.utils.getPairedEvents(metadata=metadata)
    metadata = aeon.preprocess.api.sessionduration(metadata)

    session_duration_sec = metadata.iloc[session].duration.total_seconds()
    if requested_duration>session_duration_sec:
        raise ValueError("Requested duration {:f} exceeds the session duration {:f}".format(requested_duration, session_duration_sec))
                                                                                                                                                                                                                                                                                  
    session_start = metadata.index[session]
    t0_absolute = session_start + datetime.timedelta(seconds=t0_relative)
    tf_absolute = session_start + datetime.timedelta(seconds=tf_relative)
    pellet_vals = aeon.preprocess.api.pelletdata(root, patch_name, start=t0_absolute, end=tf_absolute)
    pellets_times = pellet_vals[pellet_vals.event == "{:s}".format(pellet_event_name)].index
    print("pellets_times ==", pellets_times)
    pdb.set_trace()

if __name__=="__main__":
    main(sys.argv)
@glopesdev glopesdev linked a pull request Jun 25, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants