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

Feature/results in memory #193

Merged
merged 41 commits into from
Oct 13, 2023
Merged

Feature/results in memory #193

merged 41 commits into from
Oct 13, 2023

Conversation

meganrm
Copy link
Member

@meganrm meganrm commented Sep 21, 2023

Problem

In working on the variable sized ingredient setting we realized how many different places and ways the packed data was being stored. See this wiki

Solution

We created a new class PackedObjects. At first I didn't store the ingredient in the object, but it ended up making more sense to do it (I was calling "get_ingredient_by_name" a lot).

Other changes:

  1. Delete unused functions
  2. Move functions into Environment if all the code was related to that class
  3. change compNum to compartment_id

with @mogres

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Steps to Verify:

  1. pack -r '/Users/meganr/dev/mesoscope/cellpack/cellpack/tests/recipes/v2/test_variable_size.json'

Screenshots (optional):

Screenshot 2023-09-21 at 4 28 20 PM

@meganrm meganrm changed the base branch from feature/variable_size to main September 21, 2023 23:30
@github-actions
Copy link

github-actions bot commented Sep 21, 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

@meganrm meganrm changed the base branch from main to feature/variable_size September 22, 2023 21:26
@meganrm meganrm changed the base branch from feature/variable_size to main September 22, 2023 21:30
@@ -59,7 +59,7 @@ def add_square(self, side_length, pos, rotMat, color, opacity=1):
)

def add_ingredient_positions(self, env):
for pos, rot, ingr, ptInd in env.molecules:
for pos, rot, ingr, ptInd, radius in env.molecules:
Copy link
Member Author

@meganrm meganrm Sep 22, 2023

Choose a reason for hiding this comment

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

  • test and fix 2D plotly results

Copy link
Member Author

@meganrm meganrm Oct 11, 2023

Choose a reason for hiding this comment

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

  • 3d sphere tree looks questionable

* formatting using black
Copy link
Collaborator

@mogres mogres left a comment

Choose a reason for hiding this comment

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

This was breaking image export so I made some changes to fix that. Looks good otherwise and a super useful update going forward!

cellpack/autopack/ingredient/Ingredient.py Outdated Show resolved Hide resolved
cellpack/autopack/ingredient/Ingredient.py Outdated Show resolved Hide resolved
cellpack/autopack/ingredient/Ingredient.py Outdated Show resolved Hide resolved
cellpack/autopack/ingredient/Ingredient.py Outdated Show resolved Hide resolved
@@ -1339,11 +1242,12 @@ def get_new_pos(self, ingr, pos, rot, positions_to_adjust):
return self.transformPoints(pos, rot, positions_to_adjust)

def check_against_one_packed_ingr(self, index, level, search_tree):
overlapped_ingr = self.env.rIngr[index]
packed_ingredient = self.env.packed_objects.get()[index]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can maybe get ingredient here directly?

@@ -96,6 +98,28 @@ def __init__(
self.encapsulating_radius = radius
self.min_radius = radius

@staticmethod
def create_voxelization(
self, image_data, bounding_box, voxel_size, image_size, position, rotation, radius, hollow=None, mesh_store=None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to test if this still works

Suggested change
self, image_data, bounding_box, voxel_size, image_size, position, rotation, radius, hollow=None, mesh_store=None,
image_data, bounding_box, voxel_size, image_size, position, rotation, radius, hollow=None, mesh_store=None,

Copy link
Member Author

Choose a reason for hiding this comment

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

I reverted this, we did this because we weren't originally storing the ingredient

cellpack/autopack/utils.py Outdated Show resolved Hide resolved
@@ -1302,7 +1302,7 @@ def displayCytoplasmIngredients(self):
else:
return
if self.doSpheres:
for pos, rot, ingr, ptInd in self.histo.molecules:
for pos, rot, ingr, ptInd, _ in self.histo.molecules:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we using Graphics.py for anything? These functions are still using histo.molecules -- should get rid of them at some point.

Copy link
Member Author

Choose a reason for hiding this comment

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

we're not, I can delete it in a separate simple PR

nbFreePoints = self.onePrevIngredient(
i, mingrs, distance, nbFreePoints, organelle.molecules
)
# TODO: refactor this to work with new placed_objects data structure
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we ever have object already packed while building a grid? This could also be removed if unused.

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (2c9db6d) 98.52% compared to head (d35738d) 98.52%.
Report is 4 commits behind head on main.

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #193   +/-   ##
=======================================
  Coverage   98.52%   98.52%           
=======================================
  Files          16       16           
  Lines         476      476           
=======================================
  Hits          469      469           
  Misses          7        7           
Files Coverage Δ
cellpack/tests/test_ingredient.py 100.00% <ø> (ø)

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

@mogres
Copy link
Collaborator

mogres commented Oct 10, 2023

I also made a couple of minor changes to get partner packing to work with variable size since I needed it to create some synthetic data.

Copy link
Collaborator

@mogres mogres left a comment

Choose a reason for hiding this comment

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

New updates look good!

  • Image export is working with compartments
  • 2D plots are working
  • Sphere tree packing is working

@mogres
Copy link
Collaborator

mogres commented Oct 12, 2023

Closes #178

@meganrm meganrm merged commit aae7ed1 into main Oct 13, 2023
7 checks passed
@meganrm meganrm deleted the feature/results-in-memory branch October 13, 2023 21:38
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.

3 participants