PyNutil.interpolate_volume#
- PyNutil.interpolate_volume(*, segmentation_folder, alignment_json, colour, atlas, scale=1.0, missing_fill=nan, do_interpolation=True, k=5, batch_size=200000, use_atlas_mask=True, value_mode='pixel_count', segmentation_format='binary', segmentation_mode=True, intensity_channel='grayscale', min_intensity=None, max_intensity=None, return_orientation='asr')[source]#
Project section data into atlas-space volumes.
- Parameters:
segmentation_folder (
str) – Path to the folder containing segmentation images or source images.alignment_json (
str) – Path to the registration JSON passed toPyNutil.read_alignment().colour – Segmentation color or class identifier to extract. Use
Noneor"auto"to defer selection to the segmentation adapter.atlas (
object) – Atlas definition used to determine the target volume shape. This may be a BrainGlobe atlas object orAtlasData.scale (
float) – Isotropic scaling factor applied to the atlas output shape.missing_fill (
float) – Fill value assigned to voxels with no sampled data when interpolation is disabled or when uncovered voxels remain after processing.do_interpolation (
bool) – IfTrue, fill uncovered voxels using k-nearest-neighbor interpolation.k (
int) – Number of neighbors to use during interpolation.batch_size (
int) – Number of query voxels processed per interpolation batch.use_atlas_mask (
bool) – IfTrue, restrict interpolation to voxels inside the atlas mask.value_mode (
str) – Output volume mode. Supported values are"pixel_count","mean", and"object_count".segmentation_format (
str) – Name of the segmentation adapter to use whensegmentation_modeis enabled.segmentation_mode (
bool) – IfTrue, treat input files as segmentation outputs. IfFalse, treat them as source images and derive intensities fromintensity_channel.intensity_channel (
str) – Image channel to convert to intensity values whensegmentation_mode=False.min_intensity (
Optional[int]) – Optional lower threshold for intensity-mode inputs.max_intensity (
Optional[int]) – Optional upper threshold for intensity-mode inputs.
- Returns:
A tuple
(interpolated_volume, frequency_volume, damage_volume). The first element stores the requested value volume, the second stores per-voxel sampling frequency, and the third is a binary damage mask.- Return type:
tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]
Examples
Build atlas-space volumes from segmentation images:
>>> gv, fv, dv = interpolate_volume( ... segmentation_folder="path/to/segmentations/", ... alignment_json="path/to/alignment.json", ... colour=[0, 0, 0], ... atlas=atlas, ... )