semvec/pypi-packages huggingface dataset:
RadText 1.0.0
Radiology Report Text Analysis (RadText)
License: Apache License 2.0
Requires Python: >=3.6
Keywords: natural-language-processing nlp radiology-report-analysis

<!-- ![RadText](https://github.com/yfpeng/radtext/blob/master/radtext.png?raw=true) -->

<img src="https://github.com/yfpeng/radtext/blob/master/radtext.png?raw=true" alt="RadText" width="700"/>

RadText is a high-performance Python Radiology Text Analysis System. Users can access all the functionalities of RadText through Python APIs.

## Install RadText
```bash
pip install radtext
```

## Running RadText's pipeline

```bash
import radtext

% initialize RadText\'s pipeline.
nlp = radtext.Pipeline()

% run RadText\'s pipeline on a report.
collection = nlp('FINDINGS: The lungs are clear without consolidation, effusion or edema...')

print(collection)
```

After running all modules, RadText returns a `Collection` instance that stores the final annotation results. Within a `Collection` instance, the annotations are stored in either `Passage` or `Sentence` classes. The following code snippet shows how we can access the detected disease findings and the corresponding negation status after obtaining the `Collection` instance.

```bash
for doc in collection.documents:
    for passage in doc.passages:
        for annotation in passage.annotations:
            print(annotation.infon['source_concept'], \
                    annotation.infon['negation'])
```

## Partial pipeline execution

Through Python API, RadText enables partial pipeline execution. Therefore, users can pause after any module of RadText to access the intermediate NLP results.  Since each module requires the output of the previous module, RadText's API will automatically run every module until it finishes running the specified module. 

The modules include `csv2bioc`, `deid`, `split_section`, `preprocess`, `ner`, `parse`, `neg`, `collect_label`.

```bash
import radtext

% initialize RadText\'s modules with split_section.
nlp = radtext.Pipeline(annotator=['split_section'])
collection = nlp('FINDINGS: The lungs are clear without consolidation, effusion or edema...')

print(collection)
```

## BioC-CDM conversion

Python API supports the mutual conversion between BioC format and OMOP CDM. The following code snippet shows an example of converting BioC format to CDM and then converting CDM back to BioC format.

```bash
import bioc
from radtext import BioC2CDM, CDM2BioC

% initialize RadText\'s BioC2CDM converter.
bioc2cdm = BioC2CDM()
with open('/path/to/XML_file') as fp:
    collection = bioc.load(fp)

cdm_df = bioc2cdm(collection)

# initialize RadText's CDM2BioC converter.
cdm2bioc = CDM2BioC()

bioc_collection = cdm2bioc(cdm_df)
```
## LICENSE
RadText is released under the Apache License, Version 2.0. See the LICENSE file for more details.