PhysiCell-Tools / PhysiCell-Studio

PhysiCell Studio is a graphical tool to allow easy editing of a (XML) model, create initial positions of cells, run a simulation, and visualize results. To contribute, fork and make PRs to the development branch.
GNU General Public License v3.0
22 stars 13 forks source link

Plotting cell types with .mat files #156

Open jeliason opened 11 months ago

jeliason commented 11 months ago

When plotting cells according to cell type using the .mat files, the color for some of the cell types does not stay consistent as different cell types come into the simulation (e.g. as T cells become exhausted), causing abrupt shifts in the cell type colors as the plotting of a simulation proceeds. Also, there isn't a good legend for the cell types - the color bar on the bottom just has integer labels, so it is hard to track which are the different cell types from the plot alone.

rheiland commented 11 months ago

If you have a config file that demonstrates this and are just using Rules and the template project executable (without any custom C++), please share (email or DM on Slack if you prefer). I don't understand exactly what the issues are. Does a T cell becoming exhausted cause it to become a different cell type? The integer labels on the discrete color bar should match the cell IDs in the Cell Types tab. Also, the Plot tab's "Population plot" button for "cell_type" should display a legend. If you have a suggestion for improving the situation, please share - better yet, consider submitting a pull request.

jeliason commented 11 months ago

Thanks for your quick response! I will see if I can figure out how to make the change and submit a PR - if I can't figure it out, I'll reach back out.

rheiland commented 11 months ago

Maybe what you're suggesting is the desire for a user-defined discrete colormap. Happy to discuss sometime.

jeliason commented 11 months ago

Let me see if I can be a little more precise - specifically, I'm wondering about the colors of the cell types, as seen in this image here image You can see that cell type 4 is green in this image. However, a few timesteps later, cell type 4 turns blue: image

So I am wondering if it is possible to fix the color for a given cell type, so that it doesn't flip mid-simulation.

Also, I am wondering if it is possible to label the cell type by their text label (e.g. "tumor cell", etc) instead of the cell type integer ID on the discrete colormap.

Thanks again for any help or guidance you can offer!

rheiland commented 11 months ago

Ah, thank you for making the issue very obvious with these screenshots. As a first attempt at a partial solution, I think it should be fairly easy (I don't like that phrase though) to display the entire list of cell types (integer IDs) in the color bar for each frame, regardless of whether they are present (notice the first image is missing 3).

About using cell type names instead of integer IDs as labels on the color bar, that becomes trickier, primarily due to space constraints. What may be another option is to allow for a separate, "floating" popup color bar with the cell type names. Will ponder that.

jeliason commented 11 months ago

I made a PR with some changes that fixed the issue - let me know if you see any issues!

rheiland commented 11 months ago

I made a comment on that PR, but I also made what I hope is a partial fix to this issue. It does not label the cell_type colors on the colorbar by their cell type name (still use ID, but integer now). But it should fix the actual bug you reported. Please test if you can: https://github.com/PhysiCell-Tools/PhysiCell-Studio/releases/latest

Would you mind sharing why you chose this approach - using cell_type scalars, instead of just the .svg? Maybe you wanted the colorbar as part of the plot window?

jeliason commented 11 months ago

Yes, your fix seems to work - thanks!

Primarily a memory issue - I was running a lot of simulations on a cluster, and saving both the svg and mat files was creating lots of relatively large datasets, so I opted just to save the mat files. Having the colorbar in the window is a nice feature as well, though.