Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assignment of compartment grid points #192

Merged
merged 12 commits into from
Sep 25, 2023
Merged

Conversation

mogres
Copy link
Collaborator

@mogres mogres commented Sep 18, 2023

Problem

This PR includes various updates to grid creation and visualization and fixes errors in main while trying to pack nested compartments.

When assigning whether grid points are inside or outside a compartment, only grid points with a compartment id of 0 were checked and updated. This caused an issue if the compartments were nested, and the outer compartment was processed before the inner (as it should).

Solution

points_in_mesh now updates the identity of grid points where compartment id <= the id of the current compartment being assigned. This assumes that larger compartments are created before smaller ones.

The buildgrid_trimesh function and distance calculations in gradient.py was updated to streamline and speed up grid creation. Visualization of grid points was cleaned up to remove unused values, improve readability and visibility.

Change summary:

Gradient calculations:

  • removed normalization of surface distances while setting gradient attributes, this is now done while calculating the weights
  • ignore nan values while scaling distances
  • avoid calculating surface distances if not needed for a gradient. This calculation is computationally expensive and only needs to be performed if the gradient mode is surface

Grid creation:

  • reduced chunk size for determining grid points inside-outside compartments
  • allow reassigning grid points for downstream compartments: this assumes that outer compartments are created before the inner nested compartments.

Grid visualization:

  • sort grid point values and remove nans before visualizing
  • set the size of grid points relative to the grid spacing

Steps to Verify:

pack -r examples/recipes/v2/peroxisomes_surface_gradient.json -c examples/packing-configs/peroxisome_packing_config.json

Screenshots (optional):

Time for packing peroxisomes_surface_gradient:

fix/multiple_compartments: image

Keyfiles (delete if not relevant):

  1. Compartment.py
  2. Gradient.py

@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (2c9db6d) 98.52% compared to head (8d76176) 98.52%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #192   +/-   ##
=======================================
  Coverage   98.52%   98.52%           
=======================================
  Files          16       16           
  Lines         476      476           
=======================================
  Hits          469      469           
  Misses          7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link

github-actions bot commented Sep 18, 2023

Packing analysis report

Analysis for packing results located at cellpack/tests/outputs/test_spheres/spheresSST

Ingredient name Encapsulating radius Average number packed
ext_A 25 236.0

Packing image

Packing image

Distance analysis

Expected minimum distance: 50.00
Actual minimum distance: 50.01

Ingredient key Pairwise distance distribution
ext_A Distance distribution ext_A

@mogres mogres marked this pull request as ready for review September 19, 2023 19:25
@mogres mogres changed the title Grid creation updates Fix assignment of compartment grid points Sep 19, 2023
@mogres mogres self-assigned this Sep 19, 2023
Copy link
Member

@meganrm meganrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@rugeli
Copy link
Collaborator

rugeli commented Sep 22, 2023

Thanks for fixing it! I can finally run and pack the peroxisomes_surface_gradient recipe. However, it took me 1212.10s. Should we look into it further?

Screenshot 2023-09-22 at 1 44 02 PM

@mogres
Copy link
Collaborator Author

mogres commented Sep 22, 2023

Thanks for fixing it! I can finally run and pack the peroxisomes_surface_gradient recipe. However, it took me 1212.10s. Should we look into it further?

Screenshot 2023-09-22 at 1 44 02 PM

Did you run this on your local machine? If so, the timing sounds about right! I was running this on the dgx workstation which would be faster than a laptop.

@mogres mogres merged commit 58c0256 into main Sep 25, 2023
7 checks passed
@mogres mogres deleted the fix/multiple_compartments branch September 25, 2023 22:35
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.

4 participants