Skip to content

Commit

Permalink
update(schemas): update social schemas to use the refactored Stream, …
Browse files Browse the repository at this point in the history
…StreamGroup and Device
  • Loading branch information
ttngu207 committed Apr 4, 2024
1 parent b1fbea7 commit 28e5397
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 186 deletions.
150 changes: 77 additions & 73 deletions aeon/schema/schemas.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
from dotmap import DotMap
from aeon.io.device import Device
from aeon.schema import core, foraging, octagon, social

import aeon.schema.core as stream
from aeon.schema.streams import Device
from aeon.schema import foraging, octagon, social_01, social_02


exp02 = DotMap(
[
Device("Metadata", core.metadata),
Device("ExperimentalMetadata", core.environment, core.message_log),
Device("CameraTop", core.video, core.position, foraging.region),
Device("CameraEast", core.video),
Device("CameraNest", core.video),
Device("CameraNorth", core.video),
Device("CameraPatch1", core.video),
Device("CameraPatch2", core.video),
Device("CameraSouth", core.video),
Device("CameraWest", core.video),
Device("Nest", foraging.weight),
Device("Patch1", foraging.patch),
Device("Patch2", foraging.patch),
Device("Metadata", stream.Metadata),
Device("ExperimentalMetadata", stream.Environment, stream.MessageLog),
Device("CameraTop", stream.Video, stream.Position, foraging.Region),
Device("CameraEast", stream.Video),
Device("CameraNest", stream.Video),
Device("CameraNorth", stream.Video),
Device("CameraPatch1", stream.Video),
Device("CameraPatch2", stream.Video),
Device("CameraSouth", stream.Video),
Device("CameraWest", stream.Video),
Device("Nest", foraging.Weight),
Device("Patch1", foraging.Patch),
Device("Patch2", foraging.Patch),
]
)

exp01 = DotMap(
[
Device("SessionData", foraging.session),
Device("FrameTop", core.video, core.position),
Device("FrameEast", core.video),
Device("FrameGate", core.video),
Device("FrameNorth", core.video),
Device("FramePatch1", core.video),
Device("FramePatch2", core.video),
Device("FrameSouth", core.video),
Device("FrameWest", core.video),
Device("Patch1", foraging.depletion_function, core.encoder, foraging.feeder),
Device("Patch2", foraging.depletion_function, core.encoder, foraging.feeder),
Device("SessionData", foraging.SessionData),
Device("FrameTop", stream.Video, stream.Position),
Device("FrameEast", stream.Video),
Device("FrameGate", stream.Video),
Device("FrameNorth", stream.Video),
Device("FramePatch1", stream.Video),
Device("FramePatch2", stream.Video),
Device("FrameSouth", stream.Video),
Device("FrameWest", stream.Video),
Device("Patch1", foraging.DepletionFunction, stream.Encoder, foraging.Feeder),
Device("Patch2", foraging.DepletionFunction, stream.Encoder, foraging.Feeder),
]
)

octagon01 = DotMap(
[
Device("Metadata", core.metadata),
Device("CameraTop", core.video, core.position),
Device("CameraColorTop", core.video),
Device("ExperimentalMetadata", core.subject_state),
Device("Photodiode", octagon.photodiode),
Device("Metadata", stream.Metadata),
Device("CameraTop", stream.Video, stream.Position),
Device("CameraColorTop", stream.Video),
Device("ExperimentalMetadata", stream.SubjectState),
Device("Photodiode", octagon.Photodiode),
Device("OSC", octagon.OSC),
Device("TaskLogic", octagon.TaskLogic),
Device("Wall1", octagon.Wall),
Expand All @@ -58,55 +61,56 @@

social01 = DotMap(
[
Device("Metadata", core.metadata),
Device("Environment", social.environment_b, social.subject_b),
Device("CameraTop", core.video, social.camera_top_pos_b),
Device("CameraNorth", core.video),
Device("CameraSouth", core.video),
Device("CameraEast", core.video),
Device("CameraWest", core.video),
Device("CameraPatch1", core.video),
Device("CameraPatch2", core.video),
Device("CameraPatch3", core.video),
Device("CameraNest", core.video),
Device("Nest", social.weight_raw_b, social.weight_filtered_b),
Device("Patch1", social.patch_streams_b),
Device("Patch2", social.patch_streams_b),
Device("Patch3", social.patch_streams_b),
Device("RfidGate", social.rfid_events_social01_b),
Device("RfidNest1", social.rfid_events_social01_b),
Device("RfidNest2", social.rfid_events_social01_b),
Device("RfidPatch1", social.rfid_events_social01_b),
Device("RfidPatch2", social.rfid_events_social01_b),
Device("RfidPatch3", social.rfid_events_social01_b),
Device("Metadata", stream.Metadata),
Device("Environment", social_02.Environment, social_02.SubjectData),
Device("CameraTop", stream.Video, social_02.Pose),
Device("CameraNorth", stream.Video),
Device("CameraSouth", stream.Video),
Device("CameraEast", stream.Video),
Device("CameraWest", stream.Video),
Device("CameraPatch1", stream.Video),
Device("CameraPatch2", stream.Video),
Device("CameraPatch3", stream.Video),
Device("CameraNest", stream.Video),
Device("Nest", social_02.WeightRaw, social_02.WeightFiltered),
Device("Patch1", social_02.Patch),
Device("Patch2", social_02.Patch),
Device("Patch3", social_02.Patch),
Device("RfidGate", social_01.RfidEvents),
Device("RfidNest1", social_01.RfidEvents),
Device("RfidNest2", social_01.RfidEvents),
Device("RfidPatch1", social_01.RfidEvents),
Device("RfidPatch2", social_01.RfidEvents),
Device("RfidPatch3", social_01.RfidEvents),
]
)


social02 = DotMap(
[
Device("Metadata", core.metadata),
Device("Environment", social.environment_b, social.subject_b),
Device("CameraTop", core.video, social.camera_top_pos_b),
Device("CameraNorth", core.video),
Device("CameraSouth", core.video),
Device("CameraEast", core.video),
Device("CameraWest", core.video),
Device("CameraPatch1", core.video),
Device("CameraPatch2", core.video),
Device("CameraPatch3", core.video),
Device("CameraNest", core.video),
Device("Nest", social.weight_raw_b, social.weight_filtered_b),
Device("Patch1", social.patch_streams_b),
Device("Patch2", social.patch_streams_b),
Device("Patch3", social.patch_streams_b),
Device("Patch1Rfid", social.rfid_events_b),
Device("Patch2Rfid", social.rfid_events_b),
Device("Patch3Rfid", social.rfid_events_b),
Device("NestRfid1", social.rfid_events_b),
Device("NestRfid2", social.rfid_events_b),
Device("GateRfid", social.rfid_events_b),
Device("Metadata", stream.Metadata),
Device("Environment", social_02.Environment, social_02.SubjectData),
Device("CameraTop", stream.Video, social_02.Pose),
Device("CameraNorth", stream.Video),
Device("CameraSouth", stream.Video),
Device("CameraEast", stream.Video),
Device("CameraWest", stream.Video),
Device("CameraPatch1", stream.Video),
Device("CameraPatch2", stream.Video),
Device("CameraPatch3", stream.Video),
Device("CameraNest", stream.Video),
Device("Nest", social_02.WeightRaw, social_02.WeightFiltered),
Device("Patch1", social_02.Patch),
Device("Patch2", social_02.Patch),
Device("Patch3", social_02.Patch),
Device("RfidGate", social_02.RfidEvents),
Device("RfidNest1", social_02.RfidEvents),
Device("RfidNest2", social_02.RfidEvents),
Device("RfidPatch1", social_02.RfidEvents),
Device("RfidPatch2", social_02.RfidEvents),
Device("RfidPatch3", social_02.RfidEvents),
]
)


__all__ = ["exp01", "exp02", "octagon01", "social01", "social02"]
113 changes: 0 additions & 113 deletions aeon/schema/social.py

This file was deleted.

12 changes: 12 additions & 0 deletions aeon/schema/social_01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import aeon.io.reader as _reader
from aeon.schema.streams import Stream


class RfidEvents(Stream):

def __init__(self, path):
path = path.replace("Rfid", "")
if path.startswith("Events"):
path = path.replace("Events", "")

super().__init__(_reader.Harp(f"RfidEvents{path}_32*", ["rfid"]))
88 changes: 88 additions & 0 deletions aeon/schema/social_02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import aeon.io.reader as _reader
from aeon.schema.streams import Stream, StreamGroup
from aeon.schema import core, foraging


class Environment(StreamGroup):

def __init__(self, path):
super().__init__(path)

EnvironmentState = core.EnvironmentState

class BlockState(Stream):
def __init__(self, path):
super().__init__(_reader.Csv(f"{path}_BlockState_*", columns=["pellet_ct", "pellet_ct_thresh", "due_time"]))

class LightEvents(Stream):
def __init__(self, path):
super().__init__(_reader.Csv(f"{path}_LightEvents_*", columns=["channel", "value"]))

MessageLog = core.MessageLog


class SubjectData(StreamGroup):
def __init__(self, path):
super().__init__(path)

class SubjectState(Stream):
def __init__(self, path):
super().__init__(_reader.Csv(f"{path}_SubjectState_*", columns=["id", "weight", "type"]))

class SubjectVisits(Stream):
def __init__(self, path):
super().__init__(_reader.Csv(f"{path}_SubjectVisits_*", columns=["id", "type", "region"]))

class SubjectWeight(Stream):
def __init__(self, path):
super().__init__(_reader.Csv(f"{path}_SubjectWeight_*", columns=["weight", "confidence", "subject_id", "int_id"]))


class Pose(Stream):

def __init__(self, path):
super().__init__(_reader.Pose(f"{path}_test-node1*"))


class WeightRaw(Stream):

def __init__(self, path):
super().__init__(_reader.Harp(f"{path}_200_*", ["weight(g)", "stability"]))


class WeightFiltered(Stream):

def __init__(self, path):
super().__init__(_reader.Harp(f"{path}_202_*", ["weight(g)", "stability"]))


class Patch(StreamGroup):

def __init__(self, path):
super().__init__(path)

class DepletionState(Stream):
def __init__(self, path):
super().__init__(_reader.Csv(f"{path}_State_*", columns=["threshold", "offset", "rate"]))

Encoder = core.Encoder

Feeder = foraging.Feeder

class ManualDelivery(Stream):
def __init__(self, path):
super().__init__(_reader.Harp(f"{path}_201_*", ["manual_delivery"]))

class MissedPellet(Stream):
def __init__(self, path):
super().__init__(_reader.Harp(f"{path}_202_*", ["missed_pellet"]))

class RetriedDelivery(Stream):
def __init__(self, path):
super().__init__(_reader.Harp(f"{path}_203_*", ["retried_delivery"]))


class RfidEvents(Stream):

def __init__(self, path):
super().__init__(_reader.Harp(f"{path}_32*", ["rfid"]))

0 comments on commit 28e5397

Please sign in to comment.