-
Notifications
You must be signed in to change notification settings - Fork 2
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
Use multiple gradients on a single ingredient #270
Changes from 1 commit
f09d574
5614cd0
6cb4258
3735a1a
dcd0ea3
0a2c546
7a880a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1700,7 +1700,24 @@ def getPointToDrop( | |
# get the most probable point using the gradient | ||
# use the gradient weighted map and get mot probabl point | ||
self.log.info("pick point from gradients %d", (len(allIngrPts))) | ||
ptInd = self.gradients[ingr.gradient].pickPoint(allIngrPts) | ||
if isinstance(ingr.gradient, list) and len(ingr.gradient) > 1: | ||
if not hasattr(ingr, "combined_weight"): | ||
gradient_list = [ | ||
gradient | ||
for gradient_name, gradient in self.gradients.items() | ||
if gradient_name in ingr.gradient | ||
] | ||
combined_weight = Gradient.get_combined_gradient_weight( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you push the logic above into a generic Gradient.pick_point_from_weight that figures out wether it needs to combine weights and returns the ptInd There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call! I added a static method |
||
gradient_list | ||
) | ||
ingr.combined_weight = combined_weight | ||
|
||
ptInd = Gradient.pick_point_from_weight( | ||
ingr.combined_weight, allIngrPts | ||
) | ||
|
||
else: | ||
ptInd = self.gradients[ingr.gradient].pickPoint(allIngrPts) | ||
else: | ||
# pick a point randomly among free points | ||
# random or uniform? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "show_grid_plot", | ||
"out": "cellpack/tests/outputs/", | ||
"load_from_grid_file": false, | ||
"overwrite_place_method": true, | ||
"place_method": "spheresSST", | ||
"save_analyze_result": true, | ||
"show_grid_plot": true | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
{ | ||
"version": "1.0.0", | ||
"format_version": "2.0", | ||
"name": "test_combined_gradient", | ||
"bounding_box": [ | ||
[ | ||
0, | ||
0, | ||
0 | ||
], | ||
[ | ||
1000, | ||
1000, | ||
1 | ||
] | ||
], | ||
"gradients": { | ||
"X_gradient": { | ||
"description": "X gradient", | ||
"mode": "X", | ||
"pick_mode": "rnd", | ||
"weight_mode": "exponential", | ||
"weight_mode_settings": { | ||
"decay_length": 0.3 | ||
} | ||
}, | ||
"Y_gradient": { | ||
"description": "Y gradient", | ||
"mode": "Y", | ||
"pick_mode": "rnd", | ||
"weight_mode": "exponential", | ||
"weight_mode_settings": { | ||
"decay_length": 0.3 | ||
} | ||
} | ||
}, | ||
"objects": { | ||
"base": { | ||
"jitter_attempts": 10, | ||
"orient_bias_range": [ | ||
-3.1415927, | ||
3.1415927 | ||
], | ||
"rotation_range": 6.2831, | ||
"cutoff_boundary": 0, | ||
"max_jitter": [ | ||
1, | ||
1, | ||
0 | ||
], | ||
"perturb_axis_amplitude": 0.1, | ||
"packing_mode": "random", | ||
"principal_vector": [ | ||
0, | ||
0, | ||
1 | ||
], | ||
"rejection_threshold": 50, | ||
"place_method": "spheresSST", | ||
"cutoff_surface": 42, | ||
"rotation_axis": [ | ||
0, | ||
0, | ||
1 | ||
], | ||
"available_regions": { | ||
"interior": {}, | ||
"surface": {}, | ||
"outer_leaflet": {}, | ||
"inner_leaflet": {} | ||
} | ||
}, | ||
"sphere_25": { | ||
"type": "single_sphere", | ||
"inherit": "base", | ||
"color": [ | ||
0.5, | ||
0.5, | ||
0.5 | ||
], | ||
"radius": 25, | ||
"max_jitter": [ | ||
1, | ||
1, | ||
0 | ||
], | ||
"packing_mode": "gradient", | ||
"gradient": [ | ||
"X_gradient", | ||
"Y_gradient" | ||
] | ||
} | ||
}, | ||
"composition": { | ||
"space": { | ||
"regions": { | ||
"interior": [ | ||
"A" | ||
] | ||
} | ||
}, | ||
"A": { | ||
"object": "sphere_25", | ||
"count": 500 | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe simply reverse
if
andelse
statements for readability?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Ruge! This reminded me of another edge case of a single gradient in a list so I added that in as well here.