Cellshape-voxel is an easy-to-use tool to analyse the shapes of cells using deep learning and, in particular, 3D convolutional neural networks. The tool provides the ability to train 3D convolutional autoencoders on 3D single cell masks as well as providing pre-trained networks for inference.
To install
pip install cellshape-voxel
Usage
Basic usage
import torch
from cellshape_voxel import VoxelAutoEncoder
from cellshape_voxel.encoders.resnet import Bottleneck
model = VoxelAutoEncoder(num_layers_encoder=3,
num_layers_decoder=3,
encoder_type="resnet",
input_shape=(64, 64, 64, 1),
filters=(32, 64, 128, 256, 512),
num_features=50,
bias=True,
activations=False,
batch_norm=True,
leaky=True,
neg_slope=0.01,
resnet_depth=10,
resnet_block_inplanes=(64, 128, 256, 512),
resnet_block=Bottleneck,
n_input_channels=1,
no_max_pool=True,
resnet_shortcut_type="B",
resnet_widen_factor=1.0)
volume = torch.randn(1, 64, 64, 64, 1)
recon, features = model(volume)
To train a 3D resnet autoencoder on masks of cells or nuclei:
import torch
from torch.utils.data import DataLoader
import cellshape_voxel as voxel
input_dir = "path/to/binary/mask/files/"
batch_size = 16
learning_rate = 0.0001
num_epochs = 1
output_dir = "path/to/save/output/"
model = voxel.AutoEncoder(
num_layers_encoder=4,
num_layers_decoder=4,
input_shape=(64, 64, 64, 1),
encoder_type="resnet",
)
dataset = voxel.VoxelDataset(
PATH_TO_DATASET, transform=None, img_size=(300, 300, 300)
)
dataloader = voxel.DataLoader(dataset, batch_size=batch_size, shuffle=True)
optimizer = torch.optim.Adam(
model.parameters(),
lr=learning_rate * 16 / batch_size,
betas=(0.9, 0.999),
weight_decay=1e-6,
)
voxel.train(model, dataloader, 1, optimizer, output_dir)
Parameters
num_features: int.
The size of the latent space of the autoencoder. If you have rectangular images, make sure your image size is the maximum of the width and heightk: int.
The number of neightbours to use in the k-nearest-neighbours graph construction.encoder_type: int.
The type of encoder: 'foldingnet' or 'dgcnn'decoder_type: int.
The type of decoder: 'foldingnet' or 'dgcnn'
For developers
- Fork the repository
- Clone your fork
git clone https://github.com/USERNAME/cellshape-voxel
- Install an editable version (
-e) with the development requirements (dev)
cd cellshape-voxel
pip install -e .[dev]
- To install pre-commit hooks to ensure formatting is correct:
pre-commit install
- To release a new version:
Firstly, update the version with bump2version (bump2version patch,
bump2version minor or bump2version major). This will increment the
package version (to a release candidate - e.g. 0.0.1rc0) and tag the
commit. Push this tag to GitHub to run the deployment workflow:
git push --follow-tags
Once the release candidate has been tested, the release version can be created with:
bump2version release
Metadata
Release files for cellshape-voxel 0.0.5
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 |
|---|---|---|---|---|
| cellshape-voxel-0.0.5.tar.gz | 8.0 kB | Without provenance | Details for cellshape-voxel-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cellshape_voxel-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for cellshape_voxel-0.0.5-py3-none-any.whl |
Total release size: 16.0 kB
Release files / cellshape-voxel-0.0.5.tar.gz
| Download URL | cellshape-voxel-0.0.5.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1aa57cbe2dac9363e0ec02eb8a95fd674e380775e9daa94705b037d2cd729b1b
|
|
BLAKE2b-256 checksum How to use checksums |
c242f3557e0e1016802824f46bdf62274ca3e61a575a8d37f64f3586dbb4f4c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / cellshape_voxel-0.0.5-py3-none-any.whl
| Download URL | cellshape_voxel-0.0.5-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e260a16c06f9fa99d4629df21c385b6e3baced1b6bf7300af4ddce81e75450d3
|
|
BLAKE2b-256 checksum How to use checksums |
a8e16252080b75acd5e3367e278f39083bc58513f0e62e7e6d4f5453e552cc8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Security for cellshape-voxel 0.0.5
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.