Using PK to Measure the Performance of Anesthetic Depth Indicators.
Project description
pk4adi
Project Information
The package's name pk4adi is short for "PK for anesthetic depth indicators". The PK (Prediction probability) was firstly proposed by Docor Warren D. Smith in the paper Measuring the Performance of Anesthetic Depth Indicators in 1996. Docor Warren D. Smith and his team provide a tool to calculate PK writen using the xls macro language.
Our team provide a reimplementation of the PK tools developed using the Python language with easy using apis in this package. The project is fully open source in the github. The lastest version 0.1.0 released on June 17, 2023.
Please feel free to contact us(silencejiang@zju.edu.cn). Any kind of feedbacks is welcomed. You could report any bugs or issues when using pk4adi in the github project.
Specially, a gui version of pk4adi is under development. We will also open source the gui version project.
Changelogs
Please refer the changelog.md for details.
Requirements
Python
Python 3.8 or greater.
Packages
pandas>=0.18.0
numpy>=1.21.6
scipy>=1.9.0
tabulate
Install
To install pk4adi, run the following in the command prompt.
pip install pk4adi
APIs
- calculate_pk of module pk.py.
calculate_pk(x_in , y_in):
Compute the pk value to Measure the Performance of Anesthetic Depth Indicators.
print_pk() will be called before return the ans.
Parameters
----------
x_in : a list or a pandas series (pandas.Series()).
Indicator.
y_in : a list or a pandas series (pandas.Series()).
State.
Returns
-------
ans : a dict.
A dict containing all the matrix and variables involved in.
Use to script 'print(ans.keys())' to get the details.
The most important variables all already been printed.
- print_pk of module pk.py.
print_pk(result, floatfmt=".3f", tablefmt='simple'):
Pretty display of a pk calculation result.
Parameters
----------
result : a dict.
Must be the return value of function calculate_pk().
floatfmt : string.
Decimal number formatting.
tablefmt : string.
Table format (e.g. 'simple', 'plain', 'html', 'latex', 'grid', 'rst').
For a full list of available formats, please refer to
https://pypi.org/project/tabulate/
Returns
-------
Nothing will be returned.
- compare_pks of module pkc.py.
compare_pks(pk1, pk2):
Compare two answers of the pk values, which is the output of the function calculate_pk().
print_pks() will be called before return the ans.
Parameters
----------
pk1 : a dict.
The output of the function calculate_pk().
pk2 : a dict.
The output of the function calculate_pk().
Returns
-------
ans : a dict.
A dict containing all the matrix and variables involved in.
Use to script 'print(ans.keys())' to get the details.
The most important variables all already been printed.
- print_pks of module pkc.py.
print_pks(result, floatfmt=".3f", tablefmt='simple'):
Pretty display of two pk calculation result comparison.
Parameters
----------
result : a dict.
Must be the return value of function compare_pks().
floatfmt : string.
Decimal number formatting.
tablefmt : string.
Table format (e.g. 'simple', 'plain', 'html', 'latex', 'grid', 'rst').
For a full list of available formats, please refer to
https://pypi.org/project/tabulate/
Returns
-------
Nothing will be returned.
Examples
The best way to use this package is using the Python scripts.
1. calculate PK
from pk4adi.pk import calculate_pk
x = [ 0, 0, 0, 0, 0, 0]
y = [ 1, 1, 1, 1, 1, 2]
pk = PK()
pk.calculate_pk(x_in=x, y_in=y)
You will get the following output.
==============
PK calculation
==============
PK SE0 SE1 jack_ok PKj SEj
----- ----- ----- --------- ----- -----
0.500 0.000 0.000 False nan nan
==============
PK calculation
==============
PK SE0 SE1 jack_ok PKj SEj
----- ----- ----- --------- ----- -----
0.900 0.124 0.085 True 0.901 0.117
2. compare results of PK
from pk4adi.pk import calculate_pk
from pk4adi.pkc import compare_pks
x1 = [ 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6 ]
y1 = [ 1, 1, 1, 1, 1, 2, 1, 1, 3, 3, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3 ]
pk1 = calculate_pk(x_in = x1, y_in = y1)
x2 = [ 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6 ]
y2 = [ 1, 1, 2, 1, 1, 2, 1, 2, 3, 3, 2, 2, 1, 2, 2, 2, 3, 3, 3, 3, 2, 3, 3, 2 ]
pk2 = calculate_pk(x_in = x2, y_in = y2)
ans = compare_pks(pk1, pk2)
You will get the following output.
==============
PK calculation
==============
PK SE0 SE1 jack_ok PKj SEj
----- ----- ----- --------- ----- -----
0.867 0.065 0.066 True 0.866 0.070
==============
PK calculation
==============
PK SE0 SE1 jack_ok PKj SEj
----- ----- ----- --------- ----- -----
0.798 0.073 0.068 True 0.799 0.073
==============
PKs comparison
==============
=================
For Group (z-test)
=================
PKD SED ZD P value Comment
----- ----- ----- --------- ---------
0.068 0.101 0.669 0.504 P > 0.05
=================
For Pair (t-test)
=================
PKDJ SEDJ DF TD P value Comment
------ ------ ---- ----- --------- ---------
0.030 0.066 23 0.453 0.327 P > 0.05
Development
Contribute
Please feel free to contact us(silencejiang@zju.edu.cn). Any kind of feedbacks is welcomed and appreciated.
- Check out the wiki for development info (coming soon!).
- Fork us from @xfz329's main.
- Report an issue here.
- Report a bug with data.
References
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pk4adi-0.1.0.tar.gz
.
File metadata
- Download URL: pk4adi-0.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 789973b289b5da2ef8674ef359bc6c66a50b4f1f98464f1867c387432c05c7ed |
|
MD5 | 8d005d49d9992f046d040e39b84a4cb8 |
|
BLAKE2b-256 | 7afac5501ecb4b13d6264b4e6012b30e1ebd027fe29906dca4972b9937c2dbc4 |
File details
Details for the file pk4adi-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pk4adi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc6b1a87615b42c51c84ffe4c7c3ced2cfa95a45d72b84e111cd35cf9db62dfc |
|
MD5 | 506a1c214fee2da5a6fda9a286ab4016 |
|
BLAKE2b-256 | f97fdc0dc48644317333dbad1c3bc34a47b92c2fc4b2433e717af6aaf612e8da |