Skip to content

Add weights parameter to density_from_points()#167

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-weights-parameter-to-density-function
Draft

Add weights parameter to density_from_points()#167
Copilot wants to merge 3 commits intomainfrom
copilot/add-weights-parameter-to-density-function

Conversation

Copy link
Contributor

Copilot AI commented Nov 30, 2025

Adds optional weights parameter to density_from_points() to support weighted density maps (e.g., weighting points by their volume in voxels or mm³).

Changes

  • Add weights: Union[np.ndarray, None] = None parameter, passed through to da.histogramdd()
  • Validate weights shape matches number of points
  • Convert weights to dask array with compatible chunking for histogramdd

Usage

points = np.array([[5.0, 5.0, 5.0], [6.0, 6.0, 6.0]])
volumes = np.array([100.0, 250.0])  # e.g., nvoxels or mm³
weighted_density = density_from_points(points, ref_img, weights=volumes)

Tests

Added 7 tests covering weighted density computation, accumulation, voxel space mode, and error handling.

Original prompt

in the density_from_points() func, add an option to provide an optional weights array, passed along to histogramdd.. e.g. could use this to weight points by their size in nvoxels, (or mm^3)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 30, 2025 18:40
Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Copilot AI changed the title [WIP] Add optional weights array to density_from_points function Add weights parameter to density_from_points() Nov 30, 2025
Copilot AI requested a review from akhanf November 30, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants