Skip to main content

BioExp

Build Status Documentation Status PyPI version License: MIT

Explaining Deep Learning Models which perform various image processing tasks in the medical images and natural images.

Features

  • Dissection Analysis
  • Ablation Analysis
  • Uncertainity Analysis
    • Epistemic Uncertainty using Bayesian Dropout
    • Aleatoric Uncertainty using Test Time Augmentation
  • Activation Maximization
  • CAM Analysis
  • RCT on input and concept space
  • Concept generation clustering analysis
    • wts based clustering
    • feature based clustering
  • Concept Identification
    • Dissection based
    • Flow based
  • Causal Graph
  • Inference Methods
  • Counterfactuals on Visual Trails
  • Counterfactual Generation
  • Ante-hoc methods (Meta-Causation)

Citations

If you use BioExp, please cite our work:

@article{natekar2019demystifying,
  title={Demystifying Brain Tumour Segmentation Networks: Interpretability and Uncertainty Analysis},
  author={Natekar, Parth and Kori, Avinash and Krishnamurthi, Ganapathy},
  journal={arXiv preprint arXiv:1909.01498},
  year={2019}
}

Defined Pipeline

pipeline

Installation

Running of the explainability pipeline requires a GPU and several deep learning modules.

Requirements

  • 'pandas'
  • 'numpy'
  • 'scipy==1.6.0'
  • 'matplotlib'
  • 'pillow'
  • 'simpleITK'
  • 'opencv-python'
  • 'tensorflow-gpu==1.14'
  • 'keras'
  • 'keras-vis'
  • 'lucid'

The following command will install only the dependencies listed above.

pip install BioExp

Ablation

Usage

from BioExp.spatial import Ablation

A = spatial.Ablation(model = model, 
				weights_pth = weights_path, 
				metric      = dice_label_coef, 
				layer_name  = layer_name, 
				test_image  = test_image, 
				gt 	    = gt, 
				classes     = infoclasses, 
				nclasses    = 4)

df = A.ablate_filter(step = 1)

Dissection

Usage

from BioExp.spatial import Dissector

layer_name = 'conv2d_3'
infoclasses = {}
for i in range(1): infoclasses['class_'+str(i)] = (i,)
infoclasses['whole'] = (1,2,3)

dissector = Dissector(model=model,
                        layer_name = layer_name)

threshold_maps = dissector.get_threshold_maps(dataset_path = data_root_path,
                                                save_path  = savepath,
                                                percentile = 85)
dissector.apply_threshold(image, threshold_maps, 
                        nfeatures =9, 
                        save_path = savepath, 
                        ROI       = ROI)

dissector.quantify_gt_features(image, gt, 
                        threshold_maps, 
                        nclasses   = infoclass, 
                        nfeatures  = 9, 
                        save_path  = savepath,
                        save_fmaps = False, 
                        ROI        = ROI)

Results

dissection

GradCAM

Usage

from BioExp.spatial import cam

dice = flow.cam(model, img, gt, 
				nclasses = nclasses, 
				save_path = save_path, 
				layer_idx = -1, 
				threshol = 0.5,
				modifier = 'guided')

Results

gradcam

Activation Maximization

Usage

from BioExp.concept.feature import Feature_Visualizer

class Load_Model(Model):

  model_path = '../../saved_models/model_flair_scaled/model.pb'
  image_shape = [None, 1, 240, 240]
  image_value_range = (0, 10)
  input_name = 'input_1'

E = Feature_Visualizer(Load_Model, savepath = '../results/', regularizer_params={'L1':1e-3, 'rotate':8})
a = E.run(layer = 'conv2d_17', class_ = 'None', channel = 95, transforms=True)

##Activation Results lucid

Uncertainty

Usage

from BioExp.uncertainty import uncertainty

D = uncertainty(test_image)
            
# for aleatoric
mean, var = D.aleatoric(model, iterations = 50)

# for epistemic
mean, var = D.epistemic(model, iterations = 50)
 
# for combined
mean, var = D.combined(model, iterations = 50)

Results

un

Radiomics

Usage

from BioExp.helpers import radfeatures
feat_extractor = radfeatures.ExtractRadiomicFeatures(image, mask, save_path = pth)
df = feat_extractor.all_features()

Causal Inference Pipeline

un

Contact

Metadata

Release files for BioExp 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for BioExp 0.0.4
File Size Uploaded
BioExp-0.0.4.tar.gz 30.5 kB Details

Release files / BioExp-0.0.4.tar.gz

Download URL BioExp-0.0.4.tar.gz
Size 30.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3067c338093664b5cf24539c701f7a03cdc03742da232e189b761cb9d9f6c8bf
BLAKE2b-256 checksum
How to use checksums
7cbef63f6b3b9db1190769ed5deacb73f7fa939c07dcbd464756840724ca6887
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 release file

0.0.3

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page