Skip to content

position_merge.py

PositionOutput

Bases: _Merge, SpyglassMixin

Table to identify source of Position Information from upstream options (e.g. DLC, Trodes, etc...) To add another upstream option, a new Part table should be added in the same syntax as DLCPos and TrodesPos.

Source code in src/spyglass/position/position_merge.py
@schema
class PositionOutput(_Merge, SpyglassMixin):
    """
    Table to identify source of Position Information from upstream options
    (e.g. DLC, Trodes, etc...) To add another upstream option, a new Part table
    should be added in the same syntax as DLCPos and TrodesPos.
    """

    definition = """
    merge_id: uuid
    ---
    source: varchar(32)
    """

    class DLCPosV1(SpyglassMixin, dj.Part):
        """
        Table to pass-through upstream DLC Pose Estimation information
        """

        definition = """
        -> PositionOutput
        ---
        -> DLCPosV1
        """

    class TrodesPosV1(SpyglassMixin, dj.Part):
        """
        Table to pass-through upstream Trodes Position Tracking information
        """

        definition = """
        -> PositionOutput
        ---
        -> TrodesPosV1
        """

    class CommonPos(SpyglassMixin, dj.Part):
        """
        Table to pass-through upstream Trodes Position Tracking information
        """

        definition = """
        -> PositionOutput
        ---
        -> CommonPos
        """

    def fetch1_dataframe(self) -> DataFrame:
        """Fetch a single dataframe from the merged table."""
        # proj replaces operator restriction to enable
        # (TableName & restriction).fetch1_dataframe()
        key = self.merge_restrict(self.proj()).proj()
        query = (
            source_class_dict[
                to_camel_case(self.merge_get_parent(self.proj()).table_name)
            ]
            & key
        )
        return query.fetch1_dataframe()

DLCPosV1

Bases: SpyglassMixin, Part

Table to pass-through upstream DLC Pose Estimation information

Source code in src/spyglass/position/position_merge.py
class DLCPosV1(SpyglassMixin, dj.Part):
    """
    Table to pass-through upstream DLC Pose Estimation information
    """

    definition = """
    -> PositionOutput
    ---
    -> DLCPosV1
    """

TrodesPosV1

Bases: SpyglassMixin, Part

Table to pass-through upstream Trodes Position Tracking information

Source code in src/spyglass/position/position_merge.py
class TrodesPosV1(SpyglassMixin, dj.Part):
    """
    Table to pass-through upstream Trodes Position Tracking information
    """

    definition = """
    -> PositionOutput
    ---
    -> TrodesPosV1
    """

CommonPos

Bases: SpyglassMixin, Part

Table to pass-through upstream Trodes Position Tracking information

Source code in src/spyglass/position/position_merge.py
class CommonPos(SpyglassMixin, dj.Part):
    """
    Table to pass-through upstream Trodes Position Tracking information
    """

    definition = """
    -> PositionOutput
    ---
    -> CommonPos
    """

fetch1_dataframe()

Fetch a single dataframe from the merged table.

Source code in src/spyglass/position/position_merge.py
def fetch1_dataframe(self) -> DataFrame:
    """Fetch a single dataframe from the merged table."""
    # proj replaces operator restriction to enable
    # (TableName & restriction).fetch1_dataframe()
    key = self.merge_restrict(self.proj()).proj()
    query = (
        source_class_dict[
            to_camel_case(self.merge_get_parent(self.proj()).table_name)
        ]
        & key
    )
    return query.fetch1_dataframe()