Skip to main content

Radiomics-related modules for extraction and experimenting

Project description


AutoRadiomics

License CI Build codecov

Simple pipeline for experimenting with radiomics features

Streamlit Share

Docker

Python

Demo

docker run -p 8501:8501 -v <your_data_dir>:/data -it piotrekwoznicki/autorad:0.2 pip install --upgrade autorad

 

Installation from source

git clone https://github.com/pwoznicki/AutoRadiomics.git
cd AutoRadiomics
pip install -e .

Example - Hydronephrosis detection from CT images:

Extract radiomics features

df = pd.read_csv(table_dir / "paths.csv")
image_dataset = ImageDataset(
    df=df,
    image_colname="image path",
    mask_colname="mask path",
    ID_colname="patient ID"
)
extractor = FeatureExtractor(
    dataset=image_dataset,
    out_path=(table_dir / "features.csv"),
)
extractor.extract_features()

Load, split and preprocess extracted features

# Create a dataset from the radiomics features
feature_df = pd.read_csv(table_dir / "features.csv")
feature_dataset = FeatureDataset(
    dataframe=feature_df,
    target="Hydronephrosis",
    task_name="Hydronephrosis detection"
)

# Split data and load splits
splits_path = result_dir / "splits.json"
feature_dataset.full_split(save_path=splits_path)
feature_dataset.load_splits_from_json(splits_path)

# Preprocessing
preprocessor = Preprocessor(
    normalize=True,
    feature_selection_method="boruta",
    oversampling_method="SMOTE",
)
feature_dataset._data = preprocessor.fit_transform(dataset.data)

Train the model for hydronephrosis classification

# Select classifiers to compare
classifier_names = [
    "Gaussian Process Classifier",
    "Logistic Regression",
    "SVM",
    "Random Forest",
    "XGBoost",
]
classifiers = [MLClassifier.from_sklearn(name) for name in classifier_names]

model = MLClassifier.from_sklearn(name="Random Forest")
model.set_optimizer("optuna", n_trials=5)

trainer = Trainer(
    dataset=dataset,
    models=[model],
    result_dir=result_dir,
    experiment_name="Hydronephrosis detection"
)
trainer.run()

Create an evaluator to train and evaluate selected classifiers

evaluator = Evaluator(dataset=data, models=classifiers)
evaluator.evaluate_cross_validation()
evaluator.boxplot_by_class()
evaluator.plot_all_cross_validation()
evaluator.plot_test()

Commands

MLFlow

mlflow server -h 0.0.0.0 -p 5000 --backend-store-uri <result_dir>

Dependencies:

  • MONAI
  • pyRadiomics
  • MLFlow
  • Optuna
  • scikit-learn
  • imbalanced-learn
  • XGBoost
  • Boruta
  • Medpy
  • NiBabel
  • nilearn
  • plotly
  • seaborn

App dependencies:

  • Streamlit
  • Docker

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

autorad-0.1.2.tar.gz (46.1 kB view hashes)

Uploaded Source

Built Distribution

autorad-0.1.2-py3-none-any.whl (54.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page