Skip to main content

Secondary Features

Secondary features are higher-order digital phenotyping insights computed from primary features and raw data. They produce a single value per time window (e.g., one value per day). They are organized into the following categories.

Output Structureโ€‹

Secondary features return a time-series of values:

{"timestamp": 1638248400000, "value": 14.5}

Periods with no raw data return None for the value.


Device Usage (7 features)โ€‹

FeatureDependencyOutputDescription
screen_durationscreen_active (primary)duration (ms)Total screen-on time. Sums all screen_active bouts.
screen_unlocksdevice_usage (SensorKit)countNumber of screen unlock events.
screen_unlock_durationdevice_usage (SensorKit)duration (ms)Total time screen was unlocked.
screen_wakesdevice_usage (SensorKit)countNumber of screen wake events.
inactive_durationacc_jerk + screen_activeduration (ms)Longest continuous inactive period โ€” intersection of zero accelerometer jerk AND screen off. Uses a 10-second gap threshold for merging inactive bouts.
battery_leveldevice_state (raw)float (%)Mean battery level across the time window.
app_timedevice_usage (SensorKit)duration (ms)Total app usage time. Accepts a category parameter (e.g., "social", "health", "all"). Supports 27 app categories.
note

screen_unlocks, screen_unlock_duration, screen_wakes, and app_time depend on iOS SensorKit data (device_usage). These features require enrollment in an Apple-approved research study. For non-SensorKit deployments, use screen_duration (which uses standard device_state data) for screen usage analysis.


Mobility (5 features)โ€‹

FeatureDependencyOutputDescription
hometimesignificant_locations (primary)duration (ms)Time spent at the most-visited location (rank 0, typically home).
entropysignificant_locations (primary)floatLocation entropy โ€” calculated as โˆ’ฮฃ(p ร— log(p)) for each location's visit proportion. Higher entropy = more diverse movement.
trip_distancetrips (primary)distance (km)Total distance traveled across all trips. Uses Haversine formula.
trip_durationtrips (primary)duration (ms)Total time spent traveling (sum of trip durations).
visit_timevisits (SensorKit)duration (ms)Time spent at a specified location category. Required parameter: category โ€” one of "gym", "home", "school", "work", "other".

Sensor requirements: hometime, entropy, trip_distance, and trip_duration require lamp.gps to be enabled. visit_time requires iOS SensorKit.


Communication (5 features)โ€‹

FeatureDependencyOutputDescription
call_numbertelephony or phone_usage (SensorKit)countTotal number of calls.
call_durationtelephony or phone_usage (SensorKit)duration (ms)Total call duration.
call_degreetelephony or phone_usage (SensorKit)countNumber of unique contacts called.
text_numbermessages_usage (SensorKit)countTotal number of text messages.
text_degreemessages_usage (SensorKit)countNumber of unique contacts texted.

Common parameters for call features:

ParameterTypeDefaultDescription
sensorstring"Telephony"Data source: "Telephony" (standard) or "SensorKit"
call_directionstring"all"Filter: "all", "incoming", or "outgoing"

Parameters for text features:

ParameterTypeDefaultDescription
text_directionstring"all"Filter: "all", "incoming", or "outgoing" (text_number only)

Sensor requirements: call_number, call_duration, and call_degree work with standard lamp.telephony data. text_number and text_degree require iOS SensorKit (messages_usage).


Activity (2 features)โ€‹

FeatureDependencyOutputDescription
step_countsteps + analytics (raw)countTotal step count from the specified source.
nearby_device_countnearby_device (raw)countNumber of unique Bluetooth devices detected (filters by type="bluetooth", counts unique addresses).

step_count parameters:

ParameterTypeDefaultDescription
data_typestring"health"Source: "health" (HealthKit/Health Connect), "pedometer" (device pedometer), or "watch" (wearable)

Sensor requirements: step_count requires lamp.steps. nearby_device_count requires lamp.nearby_device.


Health (1 feature)โ€‹

FeatureDependencyOutputDescription
healthkit_sleep_durationsleep (raw)duration (ms)Sleep duration from HealthKit/Health Connect data. Deduplicates by timestamp.

Parameters:

ParameterTypeDefaultDescription
duration_typestring"in_bed"Sleep state: "in_bed", "in_sleep", or "in_awake"

Sensor requirements: Requires lamp.sleep data, typically from a connected wearable.


Assessment Results (2 features)โ€‹

FeatureDependencyOutputDescription
survey_resultssurvey_scores (primary)floatMean score for a specified question or category across all surveys in the window.
game_resultsgame_level_scores (primary)floatAverage game-specific score across sessions in the window.

survey_results parameters:

ParameterTypeDescription
question_or_categorystringRequired. The survey question text or category label to aggregate.

game_results parameters:

ParameterTypeDescription
name_of_gamestringRequired. Game name. Score computation varies by game:
GameScore Metric
cats_and_dogs, spatial_span, jewels_a, jewels_bAverage tap time (ms)
balloon_riskAverage number of pumps
pop_the_bubblesAverage percent correct on no-go trials

Data Quality (1 feature)โ€‹

FeatureDependencyOutputDescription
data_qualityaccelerometer or gps (raw)float (0โ€“1)Percentage of time bins containing at least one data point.

Parameters:

ParameterTypeDefaultDescription
featurestringโ€”Required. Sensor to assess: "accelerometer" or "gps"
bin_sizeintvariesBin size in ms. Default: 1000 ms for accelerometer, 600000 ms (10 min) for GPS. Set to -1 for defaults.
result = cortex.run(
"U1234567890",
features=["data_quality"],
feature_params={
"data_quality": {
"feature": "gps",
"bin_size": 3600000 # 1-hour bins
}
}
)

Returns a value from 0.0 (no data) to 1.0 (complete coverage). Compare against expected coverage to identify data collection gaps.

Why the GPS default bin is 10 minutes, not 1 second

Although the app requests GPS at 1 Hz, mobile operating systems throttle background location delivery โ€” actual data arrives at roughly 0.1 Hz or less. The 10-minute bin (600,000 ms) measures whether any GPS data was received in each 10-minute window, which aligns with what background collection realistically delivers. A 1.0 score means every 10-minute window in the day had at least one GPS reading; below 0.50, GPS-derived features like home time and entropy become unreliable (Calvert et al., 2026).

See also: Data Quality monitoring guide.


Usageโ€‹

import cortex

# Compute multiple secondary features
result = cortex.run(
"U1234567890",
features=["hometime", "screen_duration", "step_count", "entropy"],
start=start_time,
end=end_time,
resolution=86400000 # Daily
)

# Access individual feature results
hometime_df = result["hometime"]

Common Analysis Patternsโ€‹

Features that are typically used together for specific analyses:

  • Mobility profile: hometime + entropy + trip_distance + trip_duration โ€” characterizes overall movement patterns and home/away behavior.
  • Device engagement: screen_duration + inactive_duration + step_count โ€” combines screen usage with physical activity indicators.
  • Communication: call_number + call_degree + text_number + text_degree โ€” measures social interaction volume and network diversity.

Deprecated Featuresโ€‹

The following features have been replaced:

  • sms_number โ€” Replaced by text_number (SensorKit).
  • bluetooth_device_count โ€” Replaced by nearby_device_count.
  • sleep_duration (accelerometer-based) โ€” Replaced by healthkit_sleep_duration.