Skip to content

Commit 3f6ae1f

Browse files
authored
Merge pull request MathCancer#20 from MathCancer/development
Development - 1.5.2 release
2 parents ddbc4b4 + ad10ba7 commit 3f6ae1f

File tree

14 files changed

+642
-46
lines changed

14 files changed

+642
-46
lines changed

BioFVM/BioFVM_basic_agent.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,7 @@ void Basic_Agent::register_microenvironment( Microenvironment* microenvironment_
180180
return;
181181
}
182182

183-
Microenvironment* Basic_Agent::get_microenvironment( void )
184-
{ return microenvironment; }
185-
186-
Basic_Agent::~Basic_Agent()
183+
void Basic_Agent::release_internalized_substrates( void )
187184
{
188185
Microenvironment* pS = get_default_microenvironment();
189186

@@ -198,11 +195,18 @@ Basic_Agent::~Basic_Agent()
198195

199196
// release this amount into the environment
200197

201-
(*pS)(current_voxel_index) += *internalized_substrates;
198+
(*pS)(current_voxel_index) += *internalized_substrates;
199+
200+
// zero out the now-removed substrates
201+
202+
internalized_substrates->assign( internalized_substrates->size() , 0.0 );
202203

203204
return;
204205
}
205206

207+
Microenvironment* Basic_Agent::get_microenvironment( void )
208+
{ return microenvironment; }
209+
206210
Basic_Agent* create_basic_agent( void )
207211
{
208212
Basic_Agent* pNew;

BioFVM/BioFVM_basic_agent.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class Basic_Agent
8888
std::vector<double> * internalized_substrates;
8989
std::vector<double> * fraction_released_at_death;
9090
std::vector<double> * fraction_transferred_when_ingested;
91+
void release_internalized_substrates( void );
9192

9293
void set_internal_uptake_constants( double dt ); // any time you update the cell volume or rates, should call this function.
9394

@@ -106,7 +107,7 @@ class Basic_Agent
106107
void update_position( double dt );
107108

108109
Basic_Agent();
109-
~Basic_Agent();
110+
110111
// simulate secretion and uptake at the nearest voxel at the indicated microenvironment.
111112
// if no microenvironment indicated, use the currently selected microenvironment.
112113
void simulate_secretion_and_uptake( Microenvironment* M, double dt );

CITATION.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
If you use PhysiCell in your project, please cite PhysiCell and the version
22
number, such as below:
33

4-
We implemented and solved the model using PhysiCell (Version 1.5.1) [1].
4+
We implemented and solved the model using PhysiCell (Version 1.5.2) [1].
55

66
[1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin,
77
PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu-
@@ -11,7 +11,7 @@ We implemented and solved the model using PhysiCell (Version 1.5.1) [1].
1111
Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM
1212
as below:
1313

14-
We implemented and solved the model using PhysiCell (Version 1.5.1) [1],
14+
We implemented and solved the model using PhysiCell (Version 1.5.2) [1],
1515
with BioFVM [2] to solve the transport equations.
1616

1717
[1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin,

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# PhysiCell: an Open Source Physics-Based Cell Simulator for 3-D Multicellular Systems.
22

3-
**Version:** 1.5.1
3+
**Version:** 1.5.2
44

5-
**Release date:** 7 June 2019
5+
**Release date:** 11 June 2019
66

77
## Overview:
88
PhysiCell is a flexible open source framework for building agent-based multicellular models in 3-D tissue environments.
99

10-
1110
**Reference:** A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellular Systems, PLoS Comput. Biol. 14(2): e1005991, 2018. DOI: [10.1371/journal.pcbi.1005991](https://dx.doi.org/10.1371/journal.pcbi.1005991)
1211

1312
Visit http://MathCancer.org/blog for the latest tutorials and help.
@@ -61,7 +60,9 @@ See changes.md for the full change log.
6160

6261
## Release summary:
6362

64-
This minor release fixes bugs in the new virus-macrophage sample project. Users should also consult the reslease notes for 1.5.0.
63+
This minor release fixes bugs that affected the release of internalized substrates at cell death on Linux and OSX operating systems, relating to system differences in order of evaluating destructor functions. The release of internalized substrates has been moved to a new function, and placed in cell death functions. There is no change in APIs or high-level usage / syntax for end users.
64+
65+
Users should also consult the release notes for 1.5.0.
6566

6667
**NOTE:** OSX users must now define PHYSICELL_CPP system variable. See the documentation.
6768

@@ -71,22 +72,30 @@ This minor release fixes bugs in the new virus-macrophage sample project. Users
7172

7273
### Minor new features and changes:
7374

74-
+ None
75+
+ Introduced new function Basic_Agent::release_internalized_substrates() to explicitly release a cell's internalized substrates, rather assuming it can be properly done in the Basic_Agent destructor function.
76+
77+
+ Removed the Basic_Agent destructor function to allow the compiler to automatically generate this.
78+
79+
+ Very minor revisions to the release protocol.
80+
81+
+ Minor updates to the user guide to reflect the release_internalized_substrates() function.
7582

7683
### Beta features (not fully supported):
7784

78-
+ None
85+
+ anim_svg.py - now plots correctly sized cells; manually step via arrow keys
86+
87+
+ anim_svg_cycle.py - same as above, but automatically cycles through .svg files
7988

8089
### Bugfixes:
8190

82-
+ In the virus-macrophage sample project, switch cell death (in epithelial_function) from apoptosis to cell_lysis to demonstrate the new function.
91+
+ Move code for internalized substrate release from the Basic_Agent destructor to the new Basic_Agent::release_internalized_substrates() function.
8392

84-
+ In the virus-macrophage sample project, enable internalized substrate tracking in the setup_microenvironment() function.
93+
+ Basic_Agent::release_internalized_substrates() is now called from delete_cell(int) in PhysiCell_cell.cpp.
8594

86-
+ In the virus-macrophage sample project, use a slower viral replication rate. (Should take 240 minutes to reach the lysis threshold.)
95+
+ Basic_Agent::release_internalized_substrates() explicitly sets internalized_substrates to a zero vector, just in case users want to call this function on non-dead cells.
8796

88-
+ In the virus-macrophage sample project, switched to a maximum simulation time of 24 hours (1440 minutes).
89-
97+
+ Cell::Cell() now initializes updated_current_mechanics_voxel_index = 0 (avoids a possible segfault in GDB)
98+
9099
### Notices for intended changes that may affect backwards compatibility:
91100

92101
+ We intend to merge Custom_Variable and Custom_Vector_Variable in the very near future.

VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.1
1+
1.5.2

beta/anim_svg_step.py renamed to beta/anim_svg.py

Lines changed: 102 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#
2-
# anim_svg_step.py: render/animate PhysiCell .svg files, using left/right arrows on keyboard
2+
# anim_svg.py: render/animate PhysiCell .svg files, using left/right arrows on keyboard
33
#
44
# Usage:
5-
# python anim_svg_step.py <show_nucleus start_index axes_min axes_max scale_radius>
5+
# python anim_svg.py <show_nucleus start_index axes_min axes_max>
66
# i.e., the arguments <...> are optional and have defaults.
77
#
88
# Keyboard arrows: right/left arrows will single step forward/backward; up/down will increment/decrement step size
99
#
1010
# Dependencies include matplotlib and numpy. We recommend installing the Anaconda Python3 distribution.
1111
#
1212
# Examples (run from directory containing the .svg files):
13-
# python anim_svg_step.py
14-
# python anim_svg_step.py 0 5 700 1300 12
13+
# python anim_svg.py
14+
# python anim_svg.py 0 5 700 1300
1515
#
16-
# Author: Randy Heiland
16+
# Author: Randy Heiland (except for the circles() function)
1717
#
1818
#
1919
__author__ = "Randy Heiland"
@@ -27,6 +27,8 @@
2727
try:
2828
import matplotlib
2929
import matplotlib.colors as mplc
30+
from matplotlib.patches import Circle, Ellipse, Rectangle
31+
from matplotlib.collections import PatchCollection
3032
except:
3133
print("\n---Error: cannot import matplotlib")
3234
print("---Try: python -m pip install matplotlib")
@@ -62,8 +64,7 @@
6264
current_idx = 0
6365
axes_min = 0.0
6466
axes_max = 1000 # but overridden by "width" attribute in .svg
65-
scale_radius = 1.0
66-
if (len(sys.argv) == 6):
67+
if (len(sys.argv) == 5):
6768
use_defaults = False
6869
kdx = 1
6970
show_nucleus = int(sys.argv[kdx])
@@ -73,14 +74,12 @@
7374
axes_min = float(sys.argv[kdx])
7475
kdx += 1
7576
axes_max = float(sys.argv[kdx])
76-
kdx += 1
77-
scale_radius = float(sys.argv[kdx])
7877
elif (len(sys.argv) != 1):
79-
print("Please provide either no args or 5 args:")
80-
usage_str = "show_nucleus start_index axes_min axes_max scale_radius"
78+
print("Please provide either no args or 4 args:")
79+
usage_str = "show_nucleus start_index axes_min axes_max"
8180
print(usage_str)
8281
print("e.g.,")
83-
eg_str = "%s 0 0 0 2000 1" % (sys.argv[0])
82+
eg_str = "%s 0 0 0 2000" % (sys.argv[0])
8483
print(eg_str)
8584
sys.exit(1)
8685

@@ -89,7 +88,6 @@
8988
print("current_idx=",current_idx)
9089
print("axes_min=",axes_min)
9190
print("axes_max=",axes_max)
92-
print("scale_radius=",scale_radius)
9391
#"""
9492

9593
"""
@@ -98,14 +96,12 @@
9896
if (len(sys.argv) > 2):
9997
axes_min = float(sys.argv[2])
10098
axes_max = float(sys.argv[3])
101-
if (len(sys.argv) == 5):
102-
scale_radius = float(sys.argv[4])
10399
104-
if (len(sys.argv) > 5):
105-
usage_str = "[<start_index> [<axes_min axes_max [scale_radius]]]"
100+
if (len(sys.argv) > 4):
101+
usage_str = "[<start_index> [<axes_min axes_max>]]"
106102
print(usage_str)
107103
print("e.g.,")
108-
eg_str = "%s 10 700 1300 4" % (sys.argv[0])
104+
eg_str = "%s 1 10 700 1300" % (sys.argv[0])
109105
print(eg_str)
110106
sys.exit(1)
111107
"""
@@ -134,6 +130,82 @@
134130

135131
count = -1
136132
#while True:
133+
134+
#-----------------------------------------------------
135+
def circles(x, y, s, c='b', vmin=None, vmax=None, **kwargs):
136+
"""
137+
See https://gist.github.com/syrte/592a062c562cd2a98a83
138+
139+
Make a scatter plot of circles.
140+
Similar to plt.scatter, but the size of circles are in data scale.
141+
Parameters
142+
----------
143+
x, y : scalar or array_like, shape (n, )
144+
Input data
145+
s : scalar or array_like, shape (n, )
146+
Radius of circles.
147+
c : color or sequence of color, optional, default : 'b'
148+
`c` can be a single color format string, or a sequence of color
149+
specifications of length `N`, or a sequence of `N` numbers to be
150+
mapped to colors using the `cmap` and `norm` specified via kwargs.
151+
Note that `c` should not be a single numeric RGB or RGBA sequence
152+
because that is indistinguishable from an array of values
153+
to be colormapped. (If you insist, use `color` instead.)
154+
`c` can be a 2-D array in which the rows are RGB or RGBA, however.
155+
vmin, vmax : scalar, optional, default: None
156+
`vmin` and `vmax` are used in conjunction with `norm` to normalize
157+
luminance data. If either are `None`, the min and max of the
158+
color array is used.
159+
kwargs : `~matplotlib.collections.Collection` properties
160+
Eg. alpha, edgecolor(ec), facecolor(fc), linewidth(lw), linestyle(ls),
161+
norm, cmap, transform, etc.
162+
Returns
163+
-------
164+
paths : `~matplotlib.collections.PathCollection`
165+
Examples
166+
--------
167+
a = np.arange(11)
168+
circles(a, a, s=a*0.2, c=a, alpha=0.5, ec='none')
169+
plt.colorbar()
170+
License
171+
--------
172+
This code is under [The BSD 3-Clause License]
173+
(http://opensource.org/licenses/BSD-3-Clause)
174+
"""
175+
176+
if np.isscalar(c):
177+
kwargs.setdefault('color', c)
178+
c = None
179+
180+
if 'fc' in kwargs:
181+
kwargs.setdefault('facecolor', kwargs.pop('fc'))
182+
if 'ec' in kwargs:
183+
kwargs.setdefault('edgecolor', kwargs.pop('ec'))
184+
if 'ls' in kwargs:
185+
kwargs.setdefault('linestyle', kwargs.pop('ls'))
186+
if 'lw' in kwargs:
187+
kwargs.setdefault('linewidth', kwargs.pop('lw'))
188+
# You can set `facecolor` with an array for each patch,
189+
# while you can only set `facecolors` with a value for all.
190+
191+
zipped = np.broadcast(x, y, s)
192+
patches = [Circle((x_, y_), s_)
193+
for x_, y_, s_ in zipped]
194+
collection = PatchCollection(patches, **kwargs)
195+
if c is not None:
196+
c = np.broadcast_to(c, zipped.shape).ravel()
197+
collection.set_array(c)
198+
collection.set_clim(vmin, vmax)
199+
200+
ax = plt.gca()
201+
ax.add_collection(collection)
202+
ax.autoscale_view()
203+
plt.draw_if_interactive()
204+
if c is not None:
205+
plt.sci(collection)
206+
return collection
207+
208+
#-----------------------------------------------------
137209
def plot_svg():
138210
global current_idx, axes_max
139211
fname = "snapshot%08d.svg" % current_idx
@@ -218,12 +290,13 @@ def plot_svg():
218290
break
219291

220292
rval = float(circle.attrib['r'])
221-
# if (rgb[0] > rgb[1]):
222-
# print(num_cells,rgb, rval)
293+
# print('rval=',rval)
294+
223295
xlist.append(xval)
224296
ylist.append(yval)
225297
rlist.append(rval)
226298
rgb_list.append(rgb)
299+
# print('rgb_list = ',rgb_list)
227300

228301
# For .svg files with cells that *have* a nucleus, there will be a 2nd
229302
if (show_nucleus == 0):
@@ -242,6 +315,8 @@ def plot_svg():
242315
yvals = np.array(ylist)
243316
rvals = np.array(rlist)
244317
rgbs = np.array(rgb_list)
318+
# print('type(rgbs) = ',type(rgbs))
319+
# print('rgbs = ',rgbs)
245320
#print("xvals[0:5]=",xvals[0:5])
246321
#print("rvals[0:5]=",rvals[0:5])
247322
# print("rvals.min, max=",rvals.min(),rvals.max())
@@ -251,7 +326,13 @@ def plot_svg():
251326
plt.title(title_str)
252327
plt.xlim(axes_min,axes_max)
253328
plt.ylim(axes_min,axes_max)
254-
plt.scatter(xvals,yvals, s=rvals*scale_radius, c=rgbs)
329+
# plt.scatter(xvals,yvals, s=rvals*scale_radius, c=rgbs)
330+
# plt.scatter(xvals,yvals, s=rvals*scale_radius, c=rgbs, alpha=0.5, edgecolor='black')
331+
# plt.scatter(xvals,yvals, s=rvals*scale_radius, c=rgbs, alpha=1.0, edgecolor='black')
332+
# circles(xvals,yvals, s=rvals, c=rgbs, alpha=1.0, edgecolor='black')
333+
# circles(xvals,yvals, s=rvals)
334+
# circles(xvals,yvals, s=rvals, c=rgbs)
335+
circles(xvals,yvals, s=rvals, color=rgbs)
255336
#plt.xlim(0,2000) # TODO - get these values from width,height in .svg at top
256337
#plt.ylim(0,2000)
257338
plt.pause(time_delay)

0 commit comments

Comments
 (0)