Metadata-Version: 2.1
Name: pyinclusion
Version: 0.0.4
Summary: A simple library to generate subject inclusion flow chart for epidemiology analysis
Home-page: https://github.com/activityMonitoring/py_inclusion
Author: Hang Yuan
Author-email: angerhangy@gmail.com
License: UNKNOWN
Project-URL: Bug Reports, https://github.com/activityMonitoring/py_inclusion/issues
Project-URL: Source, https://github.com/activityMonitoring/py_inclusion
Keywords: sample,setuptools,development
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.6, <4
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: pandas
Requires-Dist: numpy
Requires-Dist: pyflowchart
Provides-Extra: dev
Requires-Dist: check-manifest ; extra == 'dev'
Provides-Extra: test
Requires-Dist: coverage ; extra == 'test'

# py_inclusion
[![Github all releases](https://img.shields.io/github/release/activityMonitoring/py_inclusion.svg)](https://github.com/activityMonitoring/py_inclusion/releases/)
![CI](https://github.com/activityMonitoring/py_inclusion/workflows/CI/badge.svg)

This package provides an easy way to generate the inclusion flowchart generation for participant inclusion for medical and epidemiology analyses. It will reduce the possibility of erroneous reporting in epi research as often the inclusion conditions may vary as the research progresses. Manual flowchart generation is neither efficient or reliable. 

## How to install
```shell
pip install py_inclusion
```
## How to use 
`sample_flowchart.ipynb` has a nice example and the specific format required. We expect the input to be a `Pandas` dataframe of with at least a subject id column called `PID`. All the other columns should contain bolean variables, whehter a particular subject has met the condition based on that criteria
```
sample_df.head()
pid	calibration     summary	    duration
248	True	        True	    True
884	True	        True	    False
793	True	        True	    True
699	False	        True	    True
319	True	        True	    True
```

To generate the flowchart 
```python
from pyinclusion.core import gen_graph
my_order = ['calibration', 'duration', 'summary'] # optional. The default ordering will be used if not specified
gen_flowchart(sample_df, condition_order=my_order)
```
It will generate a script like this:
```
st79=>start: This is not working Ok
cond81=>condition: Fulfilled condtions 
 n=72
cond83=>condition: Fulfilled condtions 
 n=72
cond85=>condition: Fulfilled condtions 
 n=72
e80=>end: Included subjects
op86=>operation: Excluded due to duration
 n= 0
op84=>operation: Excluded due to summary
 n= 0
op82=>operation: Excluded due to calibration
 n= 0

st79->cond81
cond81->
cond81->
cond81(yes)->cond83
cond83->
cond83->
cond83(yes)->cond85
cond85->
cond85->
cond85(yes)->e80
cond85(no)->op86
cond83(no)->op84
cond81(no)->op82
```
The generated graph is based on `flowchart.js`, which can be used to render images in the web.
You can then copy and paste the generated script into [flowchart.js](http://flowchart.js.org]) to generate SVG for your
work. To download svg, you can use [SVG Export](https://chrome.google.com/webstore/detail/svg-export/naeaaedieihlkmdajjefioajbbdbdjgp?hl=en-GB)
on from to easily to that.

A sample figure will look like:


![Sample_graph](https://github.com/activityMonitoring/py_inclusion/blob/main/sample_graph.png?raw=true)


