CT Counterfactuals
The code and models here were used in the Paper 📄 Merlin: A Vision Language Foundation Model for 3D Computed Tomography .
Classifiers
A 1692 target classifier predicting phenotypes from CT scans
import ct_counterfactuals as ct_cf
model = ct_cf.classifiers.phecode.PheCodeClassifier()
x = torch.ones([1, 1, 224, 224, 174])
out = model(x)
out.shape # [1, 1692]
A lung segmentation model from CT slices
import ct_counterfactuals as ct_cf
model = ct_cf.classifiers.lungmask.LungMaskSegmenter()
x = torch.ones([1, 1, 224, 224, 174])
out = model(x)
out.shape # [1, 3, 224, 224, 1]
# Channels
# 0 = No lung
# 1 = Right lung
# 2 = Left lung
Autoencoders
A VQ-GAN autoencoder trained on CT slices
import ct_counterfactuals as ct_cf
ae = ct_cf.ae.VQGAN(weights='2023-12-25T10-26-40_ct2_vqgan256_sddd')
x = torch.ones([1, 1, 224, 224])
out = ae(x)
out.shape # [1, 1, 224, 224]
Utility code is provided to encode 3D volumes
import ct_counterfactuals as ct_cf
ae = ct_cf.ae.VQGAN(weights='2023-12-25T10-26-40_ct2_vqgan256_sddd')
slice_ae = SliceAEFull(ae, 45, 55) # range specified is where gradients can propigate
x = torch.ones([1, 1, 224, 224, 174])
out = ae(x)
out.shape # [1, 1, 224, 224, 174]
Example CF explainations of the classifier
| Effusion (fluid in lungs) | Splenomegaly (enlarged spleen) |
|---|---|
Metadata
Release files for ct-counterfactuals 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ct-counterfactuals-0.0.4.tar.gz | 1.2 MB | Without provenance | Details for ct-counterfactuals-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ct_counterfactuals-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for ct_counterfactuals-0.0.4-py3-none-any.whl |
Total release size: 2.5 MB
Release files / ct-counterfactuals-0.0.4.tar.gz
| Download URL | ct-counterfactuals-0.0.4.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e701a3223aca6ccbe89066cf130c15e55a9e0ab3d5c59ccc853349f287678308
|
|
BLAKE2b-256 checksum How to use checksums |
d757fbd3f63a5c2325797bd3de1dd950c85b3c74041c58515e6c561b4edb0e58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.0
|
Release files / ct_counterfactuals-0.0.4-py3-none-any.whl
| Download URL | ct_counterfactuals-0.0.4-py3-none-any.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf9b418fffaa20bebf51c2d8cc2fbc1b519113266afa73425b503a75ef57ac43
|
|
BLAKE2b-256 checksum How to use checksums |
e0ec28eff5ba8b057326593167d2d91c73de0af05f0feb29021afb93515c1a28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.0
|
Security for ct-counterfactuals 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.