Skip to main content

ema-scheduler-redcap

Creates randomized EMA (ecological momentary assessment) schedules for a longitudinal REDCap study. It reads CSV files and writes CSV files. It never talks to REDCap.

For each EMA event, it finds participants who are due a schedule, generates random sample times, and writes one REDCap import CSV for that event. To upload the CSV, use update_redcap from redcap-toolbox.

Install

pip install ema-scheduler-redcap

Use

ema-populate [options] <scr_csv> <config_yaml> <output_dir>
Argument / option Meaning
<scr_csv> Screening data exported from REDCap.
<config_yaml> Settings (events, filters, time zones, schedule shape).
<output_dir> Folder for the import files. It must already exist.
--dry-run Select and generate, but write nothing.
--today=YYYY-MM-DD Pretend today is this date. Useful for testing.
--seed=N Fix the random seed, for repeatable schedules.
-v, --verbose More logging.

Print one participant's schedule, to check the settings by eye:

ema-gen --help

Inputs and outputs

  • The screening CSV (scr_csv) is the only source of who is eligible. It needs one row per participant. It must contain the ID column, every column named in the config's filters, and each event's start date, start time, time zone and state columns. A missing column stops the run with an error naming it. The state column helps with timezone-aware scheduling.
  • Each event's existing EMA export is read from the same folder as the screening CSV. The file name comes from ema_csv in the config.
  • A participant is scheduled for an event if they pass the filters, have a start date, are not already in that event's EMA file, and their start date falls in the scheduling window (max_days_before_start before the start through max_days_after_start after).
  • A missing or empty EMA file logs a warning (EMA file missing or empty) and is treated as "nobody is scheduled yet" for that event. Watch your logs for that message: if an export is lost by accident, everyone who is due will be scheduled again.
  • One output file per event is written to <output_dir>. Its name is the event's output_csv value in the config, for example redcap__int_ema_cache.csv. It must be a plain file name, not a path. If you use the {ema_csv_name} placeholder, it is replaced by the EMA file's name without extension, and the pattern must be quoted in YAML: output_csv: "{ema_csv_name}_cache.csv".
  • Output files are overwritten on every run, using a temporary file and a rename, so a failed run never leaves a half-written file. If nobody is due, no file is written.
  • Times are generated in each participant's local time zone and written in REDCap's time zone (default: central_tz).

Configuration

A YAML file with top-level settings, shared defaults, and an events section whose entries override the defaults.

  • Top level:

    • id_field,
    • sample_time_field,
    • central_tz,
    • timezone_field,
    • state_field,
    • timezones,
    • no_dst_overrides.
  • defaults (any of these can also be set per event):

    • day_field,
    • start_time_field,
    • start_offset_days,
    • max_days_before_start,
    • max_days_after_start,
    • samples_per_day,
    • sampling_min,
    • gap_min,
    • max_iters,
    • filters.
  • Per event:

    • start_date_field,
    • days,
    • ema_csv,
    • output_csv.

A full example is in the repository: config/test_config.yaml.

Development

uv sync
uv run pytest

Metadata

Release files for ema-scheduler-redcap 2026.11.23

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ema-scheduler-redcap 2026.11.23
File Size Uploaded Provenance Actions
ema_scheduler_redcap-2026.11.23.tar.gz 9.4 kB Without provenance Details for ema_scheduler_redcap-2026.11.23.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ema-scheduler-redcap 2026.11.23
File Interpreter ABI Platform Actions
ema_scheduler_redcap-2026.11.23-py3-none-any.whl Python 3 none any Details for ema_scheduler_redcap-2026.11.23-py3-none-any.whl

Total release size: 21.9 kB

Release files / ema_scheduler_redcap-2026.11.23.tar.gz

Download URL ema_scheduler_redcap-2026.11.23.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9d8fcb353635dff76aca9da2f84c6f248513c585261c4ec450309168233c77ca
BLAKE2b-256 checksum
How to use checksums
8cd9033d3fde2e30aa2cc7c0cab6ea64a42745a6a0e54792a63e51749c98eb6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / ema_scheduler_redcap-2026.11.23-py3-none-any.whl

Download URL ema_scheduler_redcap-2026.11.23-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4adba293280d8ecf6d6a67bfb849cfeed9ea7a8a42aab48aca5248e38157b837
BLAKE2b-256 checksum
How to use checksums
e33753feaf772671aaeb32ea5c8e4ec88e55b82439750131e6342d587d84b9ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for ema-scheduler-redcap 2026.11.23

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2026.11.23 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page