PyNutil.interpolate_volume#

PyNutil.interpolate_volume(*, image_series, registration, atlas, scale=1.0, missing_fill=nan, do_interpolation=True, k=5, batch_size=200000, use_atlas_mask=True, value_mode='pixel_count', segmentation_mode=True, intensity_channel='grayscale', min_intensity=None, max_intensity=None, return_orientation='asr')[source]#

Project section data into atlas-space volumes.

Parameters:
  • image_series (ImageSeries) – ImageSeries containing the sections to project. Build one with read_segmentation_dir() or read_image_dir().

  • registration (RegistrationData) – RegistrationData loaded with read_alignment().

  • atlas (object) – Atlas definition used to determine the target volume shape. This may be a BrainGlobe atlas object or AtlasData.

  • 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) – If True, 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) – If True, restrict interpolation to voxels inside the atlas mask.

  • value_mode (str) – Output volume mode. Supported values are "pixel_count", "mean", and "object_count".

  • segmentation_mode (bool) – If True, treat input files as segmentation outputs. If False, treat them as source images and derive intensities from intensity_channel.

  • intensity_channel (str) – Image channel to convert to intensity values when segmentation_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 VolumeResult with value (the requested metric volume), frequency (per-voxel sample count), and damage (binary damage mask).

Return type:

VolumeResult

Examples

Build atlas-space volumes from segmentation images:

>>> image_series = pnt.read_segmentation_dir(
...     "path/to/segmentations/",
...     pixel_id=[0, 0, 0],
... )
>>> registration = pnt.read_alignment("path/to/alignment.json")
>>> result = pnt.interpolate_volume(
...     image_series=image_series,
...     registration=registration,
...     atlas=atlas,
... )
>>> gv = result.value
>>> fv = result.frequency
>>> dv = result.damage