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

Save gradient data as image #216

Merged
merged 14 commits into from
Feb 5, 2024
Merged

Save gradient data as image #216

merged 14 commits into from
Feb 5, 2024

Conversation

mogres
Copy link
Collaborator

@mogres mogres commented Dec 20, 2023

Note: Merge #215 before this PR

Problem

We want to export grid distances and weights as 3D images.
Closes #199

Solution

Used the ImageWriter class to export gradient distances and weights as 3D tiff images.

Type of change

  • New feature (non-breaking change which adds functionality)

Change summary:

  • add option to save grid data as image
  • move voxelization code to environment
  • add voxelization function for gradient distances and weights
  • refactor image writer export code
  • add recipe and config for testing

Steps to Verify:

  1. pack -r cellpack/tests/recipes/v2/test_nested_mesh_gradient.json -c cellpack/tests/packing-configs/test_gradient_data_image.json
  2. Open the output folder and navigate to figures/gradient_data_figures to view the exported image.

Screenshots:

Distances (mean intensity projection):
image

Weights (mean intensity projection):
image

Keyfiles (delete if not relevant):

  1. ImageWriter.py
  2. Gradients.py

mogres added 10 commits October 31, 2023 11:25
…to analysis/variable_count_and_size_experiment
…lpack into analysis/variable_count_and_size_experiment
* return count as integer
* allow specifying seed list in the recipe
…lpack into fix/parallel_packing_with_simularium
* add sphere mesh objects for tests
* add recipe for nested mesh testing
* move voxelization code to environment
* add voxelization function for gradient distances and weights
* refactor image writer export code
* add recipe and config for testing
@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6ba5a46) 98.63% compared to head (4d277df) 98.63%.
Report is 1 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     #216   +/-   ##
=======================================
  Coverage   98.63%   98.63%           
=======================================
  Files          18       18           
  Lines         511      511           
=======================================
  Hits          504      504           
  Misses          7        7           

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

Copy link

github-actions bot commented Dec 20, 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 requested review from rugeli and meganrm January 10, 2024 22:04
@mogres mogres marked this pull request as ready for review January 10, 2024 22:04
@mogres
Copy link
Collaborator Author

mogres commented Jan 12, 2024

Use nbvv or volume viewer to visualize the outputs of this data.

"voxel_size": [1,1,1],
"projection_axis": "z"
},
"save_gradient_data_as_image": true
Copy link
Member

@meganrm meganrm Jan 26, 2024

Choose a reason for hiding this comment

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

since this is a new config setting it should also have a default setting in the config loader.
I also think, for clarity, any settings here that are defaults should be removed. The configs are ballooning a bit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed the default entries from the config file and added the new setting to config_loader.py

@@ -70,6 +70,9 @@ def pack(recipe, config_path=None, analysis_config_path=None):
recipe_version=recipe_data["version"],
image_export_options=packing_config_data.get("image_export_options"),
parallel=packing_config_data.get("parallel", False),
save_gradient_data_as_image=packing_config_data.get(
"save_gradient_data_as_image", False
),
Copy link
Member

@meganrm meganrm Jan 26, 2024

Choose a reason for hiding this comment

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

this is starting to make me think we should just send the config into analysis instead of unpacking values here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created an issue #227 to track this

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, just one request that you add the new config setting to the config loader so we don't have mystery settings

Copy link
Collaborator

@rugeli rugeli left a comment

Choose a reason for hiding this comment

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

I ran the test recipe and was able to view the image without any problems. And I'm on board with adding save_gradient_data_as_image into config loader. Great work!

@@ -3129,50 +3129,47 @@ def applyStep(self, step):
self.traj.applyState_primitive_name(self, step)
# ho can we apply to parent instance the rotatiotn?

def create_voxelization(self, image_data, image_size, voxel_size, hollow=False):
def create_voxelization(self, image_writer):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good idea to trim down the parameters and make this function more flexible!

@mogres mogres merged commit 6edfb3c into main Feb 5, 2024
7 checks passed
@mogres mogres deleted the feature/save_grid_as_image branch February 5, 2024 19:27
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.

Export grid distances and weights as a tiff file
4 participants