Skip to content

Analyzing Data#

A captured target is laid out by its schema, so loading it is one call: cg.load over the same schema you used to author the procedure returns a typed value, ready for NumPy, pandas, and notebook analysis.

Overview#

The procedure declares how to capture; the same schema describes what came back:

schema ──► procedure ──► iOS app ──► captured target ──► cg.load(path, Schema)

cg.load walks the directory the schema laid out, decodes each leaf to a typed Python value, and returns the loaded cg.Struct. Composite values broadcast attribute access — cg.Array and cg.Map project a field across every element at once — so vectorized extraction is just attribute access.

Getting captured data#

A captured target is a directory on disk. There are two ways to get one onto your analysis machine:

  1. Straight off the phone — captures live in the app's Documents/CaptureData/<Target>/ folder; copy it over with Finder. No server required. See Analyzing Your Data.
  2. From a server — for multi-user targets, download with CaptureGraph Sync.

Either way the loading code is identical: cg.load(path, Schema).

Quick Start#

Reuse the schema the procedure was authored with:

import capturegraph as cg


class Session(cg.Struct):
    photo: cg.Image
    notes: cg.String


class Survey(cg.Struct):
    sessions: cg.Map[cg.Date, Session]


survey = cg.load("/path/to/MySurvey", Survey)

# A Map of sessions, keyed by capture time
for when, session in survey.sessions.items():
    print(when, session.notes.value)

# Vectorized: project a field across every session
all_notes = survey.sessions.notes          # broadcasts over Map entries

Section Contents#

cg.load over a schema, file scalars, and missing data

cg.Array and cg.Map broadcasting and NumPy integration