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

Substrate heatmaps in SVGs, defined in config file #219

Conversation

drbergman
Copy link
Collaborator

@drbergman drbergman commented Mar 5, 2024

This extends the functionality of plotting substrate heatmaps on SVG output:

  • Allows for all colormaps permitted in studio for visualizing substrate concentrations
  • Allows for configuration of this heatmap in the XML configuration file
  • updates all sample projects so that they can use this functionality just by enabling SVG substrate plots in the XML

To utilize this, open a new project with the herein-modified template project and skip to Step 3 below. To make use of this in an existing project, do the following:

  1. Add the following line in main.cpp. Immediately after defining cell_coloring_function works.
std::string (*substrate_coloring_function)(double, double, double) = paint_by_density_percentage;
  1. Replace calls of SVG_plot in main.cpp with the following. There are likely 3 calls to replace.
SVG_plot( filename , microenvironment, 0.0 , PhysiCell_globals.current_time, cell_coloring_function, substrate_coloring_function );
  1. Replace the <SVG> node with the following block to the configuration file, e.g. config/PhysiCell_settings.xml. The colormap element can be any of YlOrRd, viridis, turbo, jet, plasma, original, or any of these with _r appended to reverse the colormap.
		<SVG>
			<interval units="min">60</interval>
			<enable>true</enable>
			<plot_substrate enabled="true" limits="false">
				<substrate>substrate</substrate>
				<min_conc>0</min_conc>
				<max_conc>1</max_conc>
				<colormap>viridis_r</colormap>
			</plot_substrate>
		</SVG>

This extends the functionality of plotting substrate heatmaps on SVG output:
* Allows for all colormaps permitted in studio for visualizing substrate concentrations
* Allows for configuration of this heatmap in the XML configuration file
* updates all sample projects so that they can use this functionality just by enabling SVG substrate plots in the XML
@drbergman
Copy link
Collaborator Author

Including previous discussions from PR #204 here:

Original PR message:

Two main changes being suggested here:

Make SVG plots with substrates easier: Add the substrate_coloring_function to the template main.cpp and pass it into the three calls to SVG_plot so that all projects starting from there can include the substrate plot in SVGs just by configuring via xml or studio. If it is not set, SVG_plot already cleverly ignores all this, even if not specified. In other words, it should not cause errors.
Make SVG plots with substrates more configurable: Allow users to specify the colormap used in plotting the substrate in SVGs. Options include all those included in studio as well as their reverse values. Marco Ruscone's original colormap is included as original. Default, however, is YlOrRd. The list of colormap names is then {"original","YlOrRd","viridis","turbo","jet","plasma"} as well as any of these with a "_r" appended to indicate it is reversed.
Minor change: substrate_coloring_function originally returned a vector of 4 strings, probably because it started from the cell_coloring_function template which uses four colors. However, only one of substrate_coloring_function were used, so that is now reflected in the code.

Most of the lines added are simply the specifications for turbo, jet, and plasma. These have higher resolution because it was when I was adding those that I realized I could easily get Matlab to print out what I needed to specify these colormaps to arbitrary precision.

Update on studio implementation

Follow up: the implementation in studio is already done and passed preliminary testing (just me).

Inclusion of other PR changes

Changes made in #216 included here as well.

Also, add the substrate element to the template project's SVG element in the config file. set to enabled="false" so as not to force this
@MathCancer
Copy link
Owner

On hold for some testing by Vincent

@drbergman drbergman force-pushed the feature-substrate-svg-improvements branch from 0f3c9e5 to 47c60e3 Compare June 3, 2024 20:41
@drbergman
Copy link
Collaborator Author

Here is my testing with it:

YlOrRd

image

YlOrRd_r

image

viridis

image

viridis_r

image

turbo

image

turbo_r

image

etc

Also allowed: jet, plasma, original, and all these with _r suffix.

@drbergman drbergman force-pushed the feature-substrate-svg-improvements branch from 47c60e3 to 6941b6c Compare June 3, 2024 22:43
@MathCancer
Copy link
Owner

Beautiful work, and cover dev discussion on slack confirms. Approved!

@MathCancer MathCancer merged commit e7f377a into MathCancer:development Jun 4, 2024
5 checks passed
@drbergman drbergman deleted the feature-substrate-svg-improvements branch August 16, 2024 23:08
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.

2 participants