Skip to content

ActiGraph

labda.parsers.Actigraph

from_csv

from_csv(
    path: Path | str,
    header: bool = True,
    lines: int = 10,
    columns: dict[int, str] | None = None,
    *,
    datetime_format: str | None = None,
    timezone: str | ZoneInfo | None = None
) -> Subject

Parses a Actigraph file in CSV format into a LABDA's data object.

Warning

Due to the potentially inconsistent structure of legacy CSV files, achieving fully automated and accurate parsing with this parser is challenging. Consequently, errors might occur during the parsing process. Therefore, it is currently considered experimental.

Parameters:

Name Type Description Default
path Path | str

The path to the Actigraph file.

required
header bool

Parsing Actigraph metadata (~10 lines).

True
lines int

The number of lines before the data starts. Usually length of the Actigraph's metadata is 10 lines, therefore those lines are skipped.

10
columns dict[int, str] | None

When the file does not have a column header, the columns can be provided as a dictionary.For example: {0: "y_counts", 1: "x_counts", 2: "z_counts"}, where the keys are the column indices and the values are the column names. If columns header exists and set to None, the columns will be parsed automatically. See mode documentation for more info about exported columns

None
datetime_format str | None

The strftime to parse time, e.g. "%d/%m/%Y". See strftime documentation for more info.

None
timezone str | ZoneInfo | None

The timezone which the data comes from. If not provided, time will be timezone-naive.

None

Returns:

Name Type Description
Subject Subject

The LABDA's data object.

Example
from labda.parsers import Actigraph

sbj = Actigraph.from_csv(
    "ellie_williams.csv",
    header=False,
    lines=0,
    columns={0: "datetime", 1: "counts_y", 2: "counts_x", 3: "counts_z"},
    datetime_format="%d/%m/%Y %H:%M:%S",
    timezone="America/New_York",
)