RadVis
RadVis (Radiology Visualization) is a visualization tool for medical images.
Installation
pip install radvis
RadSlice Viewer
Loading an image and displaying it with a slider
import radvis as rv
# Creates a 'RadImage' object containing the image data
image = rv.load_image('path/to/image.nii.gz') # Can also load from DICOM or Numpy files
slicer = rv.RadSlicer(image, axis=0)
slicer.display()
Create a RadImage from a numpy array
import radvis as rv
import numpy as np
# Creating a numpy array
image_data = np.random.rand(100, 100, 100)
# Creating a 'RadImage' object from the numpy array
image = rv.from_numpy(image_data)
slicer = rv.RadSlicer(image, axis=0)
slicer.display()
Adding masks to the image
import radvis as rv
import numpy as np
image = rv.load_image('path/to/image.nii.gz')
slicer = rv.RadSlicer(image, axis=0)
# 0 values wont be displayed
red_mask = np.zeros_like(image.image_data)
red_mask[5:100, 5:100, 5:100] = 1
blue_mask = np.zeros_like(image.image_data)
blue_mask[70:150, 70:150, 70:150] = 1
slicer.add_mask(red_mask, color="red")
slicer.add_mask(blue_mask, color="blue")
slicer.display()
Mask can be another RadImage object so you can load up your masks from a DICOM or NIFTI
import radvis as rv
import numpy as np
AXIS = 1
IMAGE_PATH = "path/to/image.nii.gz"
IMAGE_MASK_PATH = "path/to/mask.nii.gz"
image = rv.load_image(IMAGE_PATH)
mask = rv.load_image(IMAGE_MASK_PATH)
slicer = rv.RadSlicer(image, AXIS, width=3)
slicer.add_mask(mask, color="red", alpha=0.3)
slicer.display()
slicer.save_animation(f"images/axis_{AXIS}_brain_seg.gif", fps=30)
slicer.save_frame(f"images/axis_{AXIS}_brain_seg.png", index=180, dpi=300)
You can also display multiple slicers at once
import radvis as rv
import numpy as np
img1 = rv.from_numpy(np.random.rand(50, 10, 10))
img2 = rv.from_numpy(np.random.rand(10, 50, 10))
img3 = rv.from_numpy(np.random.rand(10, 10, 50))
img4 = rv.from_numpy(np.random.rand(50, 10, 10))
img5 = rv.from_numpy(np.random.rand(10, 50, 10))
img6 = rv.from_numpy(np.random.rand(10, 10, 50))
rs1 = rv.RadSlicer(img1, title="Image 1")
rs2 = rv.RadSlicer(img2, title="Image 2")
rs3 = rv.RadSlicer(img3, title="Image 3")
rs4 = rv.RadSlicer(img4, title="Image 4")
rs5 = rv.RadSlicer(img5, title="Image 5")
rs6 = rv.RadSlicer(img6, title="Image 6")
rsg = rv.RadSlicerGroup([rs1, rs2, rs3, rs4, rs5, rs6], rows=2, cols=3)
rsg.update_slider_heights(0.05)
rsg.display()
Processing Module
The processing module of RadVis offers a set of functions to perform preprocessing tasks
Clipping
The percentile_clipping function clips pixel intensities above and below percentile ranges
Noise Reduction
The noise_reduction function reduces the amount of noise in the image
Normalization
The normalization function normalizes the pixel intensities of the image to a specified range.
Padding
The add_padding function adds padding evenly to match a target shape
Example usage of processing functions:
import radvis as rv
import numpy as np
# Loading image
image = rv.load_image(filepath='path/to/image.nii.gz')
# Applying processing functions
clipped_image = rv.processing.percentile_clipping(image, lower_percentile=0.25, upper_percentile=0.75)
filtered_image = rv.processing.noise_reduction(clipped_image, filter_size=1)
normalized_image = rv.processing.normalization(filtered_image, min_val=0, max_val=255)
padded_image = rv.processing.add_padding(normalized_image, target_shape=(128, 128, 128))
# Displaying processed image
slicer = rv.RadSlicer(padded_image, axis=0)
slicer.display()
Metadata
Release files for radvis 0.3.0
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 |
|---|---|---|---|---|
| radvis-0.3.0.tar.gz | 15.4 kB | Without provenance | Details for radvis-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| radvis-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for radvis-0.3.0-py3-none-any.whl |
Total release size: 35.3 kB
Release files / radvis-0.3.0.tar.gz
| Download URL | radvis-0.3.0.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7332b8052bd9240c6fd640063c2fae3b21ae017c360211d5f14147d256a3ba4
|
|
BLAKE2b-256 checksum How to use checksums |
5ffc67326f184da9b3aad1b93c5e485bb063a8a94094c2012ecde75389fa275a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / radvis-0.3.0-py3-none-any.whl
| Download URL | radvis-0.3.0-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4856c7c47cc721782bcc8f5c9b79160878d4025e040bfa32c2d898560a05b64
|
|
BLAKE2b-256 checksum How to use checksums |
c09a1600220d5d8c76f743247595bd283b5e1ce7908c0ffed8f99d5c4a36c11d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Security for radvis 0.3.0
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.