Help with code to convert Simbiology sbproj file into gPKPDSim session file in .mat format

1 Ansicht (letzte 30 Tage)
I'm trying to learn gPKPDSim and it seems my first step is to create a project file in Simbiology that will subsequently be changed into .mat format to load as a session file into gPKPDSim. Dr. Hosseini states in his paper "gPKPDSim: a SimBiology-based GUI application for PKPD modeling in drug development" that a program he provides called "Configuration.m" will make this conversation. I found the code for the "Configuration.m" file but am getting errors, probably due to my lack of knowledge of Matlab.
After I clear the screen, I enter "Analysis = PKPD.Analysis;", which works. I'm next supposed to enter "PathName = fileparts(which(mfilename));" so I enter
PathName = fileparts(which('C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\PPG Swine mean SD.sbproj'));
While no error is created, the variable PathName returns "0×0 empty char array", which I presume means it is empty. This impacts the subsequent code to produce an error. When I enter
exist 'C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\PPG Swine mean SD.sbproj'
I get an answer of 2, so I presume the file is there. I hate to ask such a simple question but what do I have wrong in the syntax?
Thanks

Akzeptierte Antwort

Arthur Goldsipe
Arthur Goldsipe am 29 Okt. 2018
Ah, I finally figured out what's going on. The function "which" can only be used to locate files that are in the current working directory or on the MATLAB path. So if you "cd" into your gPKPDSim directory (or add it to your MATLAB path) and then run the command, then you should see that PathName is not empty.
However, that's probably not even necessary. If you are hard-coding the path, then you can just replace the line of code with the directory, that is:
PathName = 'C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\';
But I think the intent of the code is that you don't have to replace "mfilename". mfilename is actually a MATLAB function that returns the name of the file that is currently running. So this allows the configuration file to programmatically determine the file path without you having to type it into the file.
Hopefully that solves your problem this time around.
-Arthur

Weitere Antworten (6)

Arthur Goldsipe
Arthur Goldsipe am 26 Okt. 2018
See if your problem is fixed by using two slashes when you define PathName. That is, change the line of code to the following:
PathName = fileparts(which('C:\\Users\\langston\\Documents\\Research\\Pharmacokinetics\\gPKPDSim\\PPG Swine mean SD.sbproj'));
The reason you didn't have to do this with exist is because you invoked it as a "command" rather than as a "function". (For more details, you can read this blog post .) You would have to do the same thing if you invoked it this way:
exist('C:\\Users\\langston\\Documents\\Research\\Pharmacokinetics\\gPKPDSim\\PPG Swine mean SD.sbproj');

CLang
CLang am 27 Okt. 2018
Thank you for the reply. I tried as you suggested, inserting "\\" into the the path name.
Trial>> PathName = fileparts(which('C:\\Users\\langston\\Documents\\Research\\Pharmacokinetics\\gPKPDSim\\PPG Swine mean SD.sbproj'));
Trial>> PathName
PathName =
0×0 empty char array
The variable PathName still appears empty. I also tried replacing "\" with "/" and had the same result.
  1 Kommentar
Arthur Goldsipe
Arthur Goldsipe am 27 Okt. 2018
Sorry, I was wrong. I think double backslashes are only needed when calling functions like sprintf or fprintf. I'll take a closer look again later.

Melden Sie sich an, um zu kommentieren.


CLang
CLang am 29 Okt. 2018
Thanks for the above answer! I made it through the next several lines of code successfully but eventually ran into a new error. I presume it's probably best to continue the dialog in troubleshooting this program here rather than starting a new post; let me know otherwise.
So, just to make sure the directory is correct and the file exists for MatLab I ran this code:
Trial>> cd('C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim')
Trial>> cd
C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim
Trial>> exist 'C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\PPG Swine mean SD.sbproj'
ans =
2
Now I ran the following code w/o a problem:
Trial>> Analysis = PKPD.Analysis;
Trial>> PathName = fileparts(which('C:/Users/langston/Documents/Research/Pharmacokinetics/gPKPDSim/PPG Swine mean SD.sbproj'));
Trial>> ProjectPath = fullfile(PathName,'models','PPG Swine mean SD.sbproj');
Trial>> ModelName = 'OneCompExtravascular';
This next line of code produces an error though:
Trial>> importModel(Analysis,ProjectPath,ModelName);
Error using sbioloadproject (line 71)
Unable to read file 'C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\models\PPG Swine
mean SD.sbproj': No such file or folder.
Error in PKPD.Analysis/importModel (line 337)
AllModels = sbioloadproject(ProjectPath);
I do not even see "importModel" as a Matlab command in Help. Once again I would appreciate your help!
Thanks
  1 Kommentar
Arthur Goldsipe
Arthur Goldsipe am 29 Okt. 2018
importModel is a method that's defined in gPKPDSim. Normally, this error indicates is caused by a typo in the file name or path.
Do you get the same error message if you try the following at the MATLAB command prompt?
sbioloadproject('C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\models\PPG Swine
mean SD.sbproj')
I think that's the command that importModel is running, so I would expect it to error to error here, too. If this command also errors, can you confirm that the following also errors?
exist('C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\models\PPG Swine
mean SD.sbproj')
I thought you wrote earlier that this command returned 2. But then I wouldn't expect sbioloadproject to error. So something doesn't add up.
What version of MATLAB are you using? I'd like to confirm I'm using the same one. It might also be helpful to include the output of the "ver" command.

Melden Sie sich an, um zu kommentieren.


CLang
CLang am 29 Okt. 2018
When I run he code with the exact path and file name specified I still get the same error:
Trial>> sbioloadproject('C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\models\PPG Swine mean SD.sbproj')
Error using sbioloadproject (line 71)
Unable to read file 'C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\models\PPG Swine mean
SD.sbproj': No such file or folder.
Yes, the exist command gives an answer of 2
Trial>> exist 'C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\PPG Swine mean SD.sbproj'
ans = 2
Dr. Hosseini had stated in his article that gPKPDSim had not been tested beyond MATLAB R2016b so that is what I'm running: MATLAB Version: 9.1.0.441655 (R2016b). (Though in a webinar last week he said it has now been tested in the 2017 versions, but not for 2018. I had already installed the 2016b version though so I stayed with it.)
  1 Kommentar
Arthur Goldsipe
Arthur Goldsipe am 30 Okt. 2018
Bearbeitet: Arthur Goldsipe am 30 Okt. 2018
It took me a while to see the difference, but the two paths are not the same. Note that the failing commands contain a "models" subfolder, which is not correct. Try removing the "models" part of the ProjectPath code:
ProjectPath = fullfile(PathName,'PPG Swine mean SD.sbproj');

Melden Sie sich an, um zu kommentieren.


CLang
CLang am 30 Okt. 2018
That solved the problem. Now I'll continue to work through the rest of the program. Many thanks!

Iraj Hosseini
Iraj Hosseini am 5 Nov. 2018
Hi
To learn gPKPDSim, you can also use the SimBiology models and corresponding session files that we have provided as supplements with the paper. For the config file, we have provided a template that you can modify for your SimBiology model and build the session file.
To run a config file, you need to make sure that the appropriate gPKPDSim folders have been added to PATH. To do so, please run the app and close it. This makes sure all the required folders are setup correctly in Matlab PATH. Then run the config file.
Thanks, Iraj

Communitys

Weitere Antworten in  SimBiology Community

Kategorien

Mehr zu Biotech and Pharmaceutical finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by