Skip to main content

rcol

CI Python 3.8+ PyPI version

rcol (RedCap Uni Oldenburg) is a Python package that provides Pandas DataFrame templates for REDCap instruments with stacking and upload functionality.

Tested on: Windows, Linux, macOS | Python: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13

Installation

pip install rcol

Quick Start

from rcol.instruments import fal, ehi, bdi_ii
import pandas as pd

# Use individual instruments
print(f"FAL has {len(fal)} fields")
print(f"EHI has {len(ehi)} fields") 
print(f"BDI-II has {len(bdi_ii)} fields")

# Stack multiple instruments for REDCap upload
all_instruments = pd.concat([fal, ehi, bdi_ii], ignore_index=True)
print(f"Combined: {len(all_instruments)} total fields")

# Upload to REDCap (requires PyCap and API credentials)
from redcap import Project
project = Project(api_url, api_token)
project.import_metadata(all_instruments, import_format='df')

Available Instruments

  • fal: Fragebogen zur Allgemeinen Leistungsfähigkeit (General Performance Questionnaire)
  • ehi: Edinburgh Handedness Inventory
  • bdi_ii: Beck Depression Inventory II
  • moca: Montreal Cognitive Assessment
  • tmt: Trail Making Test
  • wnss: Weinstein's Noise Sensitivity Scale (WNSS-21)

Creating Custom Instruments

You can create custom instruments or extend existing ones without contributing to the package:

import pandas as pd
from rcol.instruments import fal, ehi
from redcap import Project

# Create a custom instrument from scratch
custom_instrument = pd.DataFrame({
    'field_name': ['record_id', 'custom_field_1', 'custom_field_2'],
    'field_label': ['Record ID', 'Custom Field 1', 'Custom Field 2'],
    'field_type': ['text', 'text', 'radio'],
    'form_name': ['custom_form', 'custom_form', 'custom_form'],
    'choices': ['', '', '1, Yes | 0, No']
})

# Add a new question to an existing instrument
fal_new_question = pd.DataFrame({
    'field_name': ['fal_like_redcap'],
    'field_label': ['Do you like REDCap?'],
    'field_type': ['radio'],
    'form_name': ['fal'],
    'choices': ['1, Yes | 0, No']
})

fal_extended = pd.concat([fal, fal_new_question], ignore_index=True)

# Combine everything and upload to REDCap
all_instruments = pd.concat([fal_extended, ehi, custom_instrument], ignore_index=True)

project = Project(api_url, api_token)
project.import_metadata(all_instruments, import_format='df')

See tutorial_custom_instruments.py for a complete guide with all REDCap metadata fields.

Running Tutorial Scripts

Two tutorial scripts are provided in the repository to help you get started:

  1. tutorial_custom_instruments.py - Create custom instruments and extend existing ones
  2. tutorial_existing_instruments.py - Use existing instruments from rcol and the RTG (Research Template Gallery)

To run these tutorials after installing rcol:

# Install rcol and dependencies
pip install rcol python-dotenv PyCap

# Set up your REDCap API credentials
# Create a .env file with: RC_API_KEY=your_api_key_here

# Download the tutorial scripts from the repository
# Then run them:
python tutorial_custom_instruments.py
python tutorial_existing_instruments.py

Note: The tutorials require valid REDCap API credentials. Make sure to set the RC_API_KEY environment variable or create a .env file with your credentials before running them.

Contributing a New Instrument

  1. Fork this repository

  2. Add your instrument data in src/rcol/instruments.py:

    # Define your instrument fields
    my_instrument_data = [
        {
            "field_name": "record_id",
            "form_name": "my_instrument", 
            "field_type": "text",
            "field_label": "Record ID",
            # ... other REDCap metadata fields
        },
        # ... more fields
    ]
    
    # Create DataFrame
    my_instrument = pd.DataFrame(my_instrument_data)
    
  3. Run the instrument test suite to validate your template. The shared tests automatically pick up every pandas.DataFrame exported from rcol.instruments and check for required REDCap metadata, non-empty field names, and duplicate protection:

    uv run --with pytest pytest -k instrument
    

    If you add custom validation that needs extra assertions, extend tests/test_templates.py accordingly.

  4. Preview the documentation (optional). The MkDocs site renders the instrument tables directly from rcol.instruments. To check the output locally:

    uv run --group docs mkdocs serve
    
  5. Submit a pull request. Every PR triggers the GitHub Actions CI workflow, which runs the instrument tests across Windows, Linux, and macOS with Python 3.8-3.13. Make sure the workflow badge stays green before requesting review.

Development

# Clone and install for development
git clone https://github.com/JuliusWelzel/rcol.git
cd rcol
uv sync

# Run tests
uv run pytest

# Build package
uv build

Documentation

The documentation site is powered by MkDocs and mkdocstrings, so instrumentation tables are rendered directly from rcol.instruments at build time.

# Serve docs locally
uv run --group docs mkdocs serve

# Build static site
uv run --group docs mkdocs build

License

MIT

Metadata

Release files for rcol 0.0.8

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

Source distribution (sdist)

Source distribution for rcol 0.0.8
File Size Uploaded Provenance Actions
rcol-0.0.8.tar.gz 74.6 kB Without provenance Details for rcol-0.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rcol 0.0.8
File Interpreter ABI Platform Actions
rcol-0.0.8-py3-none-any.whl Python 3 none any Details for rcol-0.0.8-py3-none-any.whl

Total release size: 109.0 kB

Release files / rcol-0.0.8.tar.gz

Download URL rcol-0.0.8.tar.gz
Size 74.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f6427f759378ac8edc417ae761f4350123bc059294c8e075601a1ea32dc08071
BLAKE2b-256 checksum
How to use checksums
867254eb0ed910b68751467cfb4f5e9e376ea723ebec98af73aea976d32cc728
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / rcol-0.0.8-py3-none-any.whl

Download URL rcol-0.0.8-py3-none-any.whl
Size 34.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bde10a765bdeedd5fec21af6f97fc5e313645d5f93a4500375c4d42ed8268b6b
BLAKE2b-256 checksum
How to use checksums
2255e004c35d413057a54b9abd386ca7bccf47264f18489cbabcfac381676357
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for rcol 0.0.8

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.

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