Is there an object associated with simulate task in the simbiology desktop that contains the name of the task?

2 visualizzazioni (ultimi 30 giorni)
I use State_Subplots in "Plots to Generate" in simbiology simulation tasks a lot. "Plots to Generate" allows scripts to be used on simulation outputs. State subplot gives all the model outputs for species and parameters taht one choses, in separate subplots with time as abscissa. But when I run two different tasks (each with a different name signifying, for example, different variants) , each plot generated is labeled "State Subplot - Figure x". Like this:
Capture.GIF
This can get confusing - aboslutely nothing differentiates these plots!. Ideally, the tabs generated would show the task name used to generate them. For example, "Subplots - Mass Balance" and "Subplots - Energy Balance" for tasks named Mass and Energy Balance. Alternately, if I could access the task name I could put that name on the plot with sgtitle. The only objects returned to the workspace by the simulate task seem to be tobj (which contains states and parameters) and obj (which contains the model). There is no "task" object which presumably could contain the unique name for the task. For some "Plots to Generate" scripts there exists a taskresult object, but I see no documentation on what it contains, and it doesn't appear to be generated by the simulation task.
Also, its not clear where/how the tab names for the plots generated by the "Plots to generate" are specified.
So I'm asking
1) is there a task object which contains the name of the simulation task accessible within the "Plots to Generate" script?
2) Is there a way to specify "Plots to Generate" tab names?
If there is a task object with the name, at least this could use the sgtitle matlab function to put a name over the subplots. But ideally, I'd like to be able to add
tname = taskresults.taskname;
figuretab = tname;
sgtitle(tname);
This would allow me to keep results straight when I have a few tasks on the screen.
The following is a related, but different suggestion:
An approach which might be useful to users would be to have plot_group objects. So I could (for example) set up a live plot with the variables I want, and then could save the list as a plot_group. plot_groups would contain variables, external data, and math constructs, with the order being signficant. I could run a simulation with the "mass balance" plot group specified in live plots. If that worked, I could specify (for example) "glucose_balance" in live plots and would see the new group of variables without resimulation. Suppose that glucose was balanced. I could then look at the PK plot_group. The model matches the data? Great. Now "PD". Whoops, we've got a problem! I could then look at "mechanism" or other plot_groups to diagnose stuff. All without resimulation. Plus, if you created another task, it would be easy to specify the variables you want in the live view plot.
Right now, I have to create a separate task for each view (live view and state subplots, specified above). Then I have to run the model once per task. Then, if I change the states I want in the subplot, I I have to go back and change every task manually. I think that this could be improved to be more useful and efficient for the user. Thanks!

Risposta accettata

Sietse Braakman
Sietse Braakman il 6 Mar 2019
Hi Jim,
These are good questions.
  • Currently, there is no way to access the task name from the desktop, or from MATLAB. One solution you could explore is create scripts for your tasks that you run in MATLAB, rather than running the tasks in SimBiology. As you might know, for each task you can access the task code by clicking Task Code --> View task code. The task code will be a MATLAB function that you can adjust to your needs. E.g. you could give it a task name - or derive a task name from a variant name - and use that to label your plots.
viewTaskCode.png
  • You can dock plots and change the name of the tabs using the following code:
set(0,'DefaultFigureWindowStyle','docked') % set default graphics options to dock plots
% change name of plot tab/figure, remove numbered figures
fig = figure('Name','Subplot State 1','NumberTitle','off');
% plot some SimBiology state simulation
plot(t,x(:,1))
% create the next tab.
fig2 = figure('Name','Subplot State 2','NumberTitle','off');
plot(t,x(:,2))
% return to normal plotting:
set(0,'DefaultFigureWindowStyle','normal')
More info here:
If I understand your idea of plot groups correctly, these are groups of species you would like to plot together? So the group of mass balance plot group would contain all the species that represent masses in your model, plus e.g. a sum of masses. If so, this is currently not possible in the SimBiology desktop. However, you could write a script that groups your species by their indices use those as an input for a simulation or plotting task (providing you logged the species for each of the plot groups during your first simulation). Or you could plot all your species in a single figure and hide/show only those that belong to a certain plot group using their handle.
Thanks for your valuable suggestions, we will take these on board and investigate how we might implement these in the future. Best,
Sietse
  2 Commenti
Jim Bosley
Jim Bosley il 6 Mar 2019
Useful reply, Sietse, thanks!
It's amazing what one learns
1) Doing stuff
2) Asking "Can I do different stuff?"
3) Asking "Why can't I do this different stuff?"
I know from experience that a lot of the power in simbiology is released when you are writing scripts to exercise and modulate the model. But right now I'm extensively using the Desktop (or is it Dashboard?). So these little things, like being able to differentiate state_subplot results from different tasks, and to efficiently look at model results, are important. I can see that one can do this unambiguously, but with more effort, in scripts.
I think you have the basic idea of plot_groups, but the utility I see for this is a little different. The idea came from working with Herbert Sauro and Pathway Designer (formerly JDesigner). He implemented this in PD and I used it a lot and can testify it works pretty well.
You create a simulation task and select some species and variables to plot. In the dialog box where you select the lines to plot, there would be a "save selections as a plot group" button. You click it and it prompts you for a name. "Mass_Balance", might be an example. You then clear/modify or choose new plot selections and save that, e.g. "Energy_Balance". And so forth. There'd also be a "Select group to plot" pull down menu. Right click on that and you see all your saved plot groups. Select one, and the desired plot comes up in live view. Ideally, you could switch between views without resimulation - very powerful.
Ideally, the plot_group structure would also be usable in scripts such as those you mention in "Plots to Generate". I've taken the "State Subplot" and other plotting scripts and created a "State SortedSubplot". So right now, the dialog passes a cell array (I think) "names" of variables to plot. There might be a utility pg2pta (plot group to plot cell array) allowing scripts to use plot_groups.
Another reason why this would be useful is illustrated as follows:
Suppose I create a simulation task with a signficant number of plotted values. Perhaps including external data, or math constructs. That's quite doable now.
But the power of computation is in seeing what happens under different conditions. For this I'd use variants, right? So I could duplicate the inital task (with all the plots in it) and add a variant. Useful, and doable.
To make this more clear, imagine creating three or for more duplicate simulation tasks. All have the same plotted lines, which is great, because I can compare. So I have ten tasks with different variants and different views.
Now I realize I need a "bosley_messed_up_need_a_fudge_factor" species. Call the new species bmunaff. I want to plot bmunaff to see how badly I messed up. Plus there's a few other values I have to add to plots. So I have to go into ten tasks and search for each of three values in a list that is somewhat disorded. This is the tedium I'm trying to avoid.
A last benefit of plot_Groups woud be in ordering the plots. Right now, the plots appear in pretty much random order in the state subplot script.
Jim Bosley
Jim Bosley il 6 Mar 2019
PS I've added sorting to state_subplot to get a State_SubplotSort script. Probably obvious, but may be useful to others:
function State_SubplotSort(tobj, y)
%STATE_SUBPLOT Plots states in separate subplots
%
% Plots states in separate subplots
%
% Get Data to be plotted - y is the list of variables to plot
% Apparently output is of form [t,y,names]
if strcmpi(y, '<all>')
[time, data, names] = getdata(tobj);
else
yy = sort(y); % All I did was add this line and the next... JRB
y = yy;
[time, data, names] = selectbyname(tobj, y);
end
rootnplots = sqrt(numel(names));
nrows = round(rootnplots);
ncolumns = ceil(rootnplots);
for i = 1:numel(names)
subplot(nrows,ncolumns,i)
plot(time, data(:,i));
title(names(i),'Interpreter','none');
end

Accedi per commentare.

Più risposte (0)

Community

Più risposte nel  SimBiology Community

Categorie

Scopri di più su Import Data in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by