Skip to main content

Utilities for 3D Slicer

Project description

Python package Upload Python Package PyPI version

slicerutils

Python utilities for 3D Slicer interoperability.

The package contains utility functions for reading and writing segmentation files. More functions will be added in the future.

Installation

Using pip:

pip install slicerutils

Example

  1. Read segmentation and show some information about segments
import slicerutils
segmentation_info = slicerutils.read_segmentation_info("Segmentation.seg.nrrd")

number_of_segments = len(segmentation_info["segments"])
print(f"Number of segments: {number_of_segments}")

segment_names = slicerutils.segment_names(segmentation_info)
print(f"Segment names: {', '.join(segment_names)}")

segment0 = segment_from_name(segmentation_info, names[0])
print(f"First segment info: {segment0})

Extract selected segments with chosen label values

extracted_filename = "c:/Users/andra/OneDrive/Projects/SegmentationPynrrd/SegmentationExtracted.seg.nrrd"
voxels, header = nrrd.read(filename)
segment_list = [("Segment_1", 10), ("Segment_3", 12), ("Segment_4", 6)]
extracted_voxels, extracted_header = extract_segments(voxels, header, segmentation_info, segment_list)
nrrd.write(extracted_filename, extracted_voxels, extracted_header)

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

slicerio-0.1.0.tar.gz (761.7 kB view hashes)

Uploaded Source

Built Distribution

slicerio-0.1.0-py3-none-any.whl (7.2 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