Coder Social home page Coder Social logo

reproschema-py's Introduction

Python package

Reproschema Python library and Command Line Interface (CLI)

Installation

reproschema requires Python 3.7+.

pip install reproschema

Developer installation

Install repo in developer mode:

git clone https://github.com/ReproNim/reproschema-py.git
cd reproschema-py
pip install -e .[dev]

It is also useful to install pre-commit, which takes care of styling when committing code. When pre-commit is used you may have to run git commit twice, since pre-commit may make additional changes to your code for styling and will not commit these changes by default:

pre-commit install

CLI usage

This package installs reproschema a CLI.

$ reproschema
Usage: reproschema [OPTIONS] COMMAND [ARGS]...

  A client to support interactions with ReproSchema

  To see help for a specific command, run

  reproschema COMMAND --help     e.g. reproschema validate --help

Options:
  --version
  -l, --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
                                  Log level name  [default: INFO]
  --help                          Show this message and exit.

Commands:
  convert
  create
  redcap2reproschema  Convert REDCap CSV files to Reproschema format.
  reproschema2redcap  Convert reproschema protocol to REDCap CSV format.
  serve
  validate

reproschema2redcap Usage

Command-Line Usage

You can use this feature directly from the command line. To convert ReproSchema protocol to REDCap CSV format, use the following command

reproschema reproschema2redcap <input_dir_path> <output_csv_filename>
  • <input_dir_path>: The path to the root folder of a protocol. For example, to convert the reproschema-demo-protocol provided by ReproNim, you can use the following commands:
    git clone https://github.com/ReproNim/reproschema-demo-protocol.git
    cd reproschema-demo-protocol
    pwd
    In this case, the output from pwd (which shows your current directory path)should be your <input_dir_path>.
  • <output_csv_filename>: The name of the output CSV file where the converted data will be saved.

Python Function Usage

You can also use the reproschema2redcap function from the reproschema-py package in your Python code.

from reproschema import reproschema2redcap

input_dir_path = "path-to/reproschema-demo-protocol"
output_csv_filename = "output.csv"

reproschema2redcap(input_dir_path, output_csv_filename)

redcap2reproschema Usage

The redcap2reproschema function is designed to process a given REDCap CSV file and YAML configuration to generate the output in the reproschema format.

Prerequisites

Before the conversion, ensure you have the following:

YAML Configuration File:

YAML File Configuration

In the templates/redcap2rs.yaml file, provide the following information:

  • protocol_name: This is a unique identifier for your protocol. Use underscores for spaces and avoid special characters.
  • protocol_display_name: The name that will appear in the application.
  • protocol_description: A brief description of your protocol.

Example:

protocol_name: "My_Protocol"
protocol_display_name: "Assessment Protocol"
protocol_description: "This protocol is for assessing cognitive skills."

Command-Line Usage

The `redcap2reproschema`` function has been integrated into a CLI tool, use the following command:

reproschema redcap2reproschema path/to/your_redcap_data_dic.csv path/to/your_redcap2rs.yaml

Python Function Usage

You can also use the redcap2reproschema function from the reproschema-py package in your Python code.

from reproschema import redcap2reproschema

csv_path = "path-to/your_redcap_data_dic.csv"
yaml_path = "path-to/your_redcap2rs.yaml"

reproschema2redcap(input_dir_path, output_csv_filename)

After configuring the YAML file:

  1. Run the Python script with the paths to your CSV file and the YAML file as arguments.
  2. Command Format: python script_name.py path/to/your_redcap_data_dic.csv path/to/your_redcap2rs.yaml

Notes

  1. The script requires an active internet connection to access the GitHub repository.
  2. Make sure you use git add, git commit, git push properly afterwards to maintain a good version control for your converted data.

reproschema-py's People

Contributors

yibeichan avatar satra avatar pre-commit-ci[bot] avatar sanuann avatar remi-gau avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.