필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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

채택된 답변

Arthur Goldsipe
Arthur Goldsipe 2018년 10월 29일
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

추가 답변 (6개)

Arthur Goldsipe
Arthur Goldsipe 2018년 10월 26일
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 2018년 10월 27일
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
Arthur Goldsipe
Arthur Goldsipe 2018년 10월 27일
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.

댓글을 달려면 로그인하십시오.


CLang
CLang 2018년 10월 29일
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
Arthur Goldsipe
Arthur Goldsipe 2018년 10월 29일
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.

댓글을 달려면 로그인하십시오.


CLang
CLang 2018년 10월 29일
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
Arthur Goldsipe
Arthur Goldsipe 2018년 10월 30일
편집: Arthur Goldsipe 2018년 10월 30일
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');

댓글을 달려면 로그인하십시오.


CLang
CLang 2018년 10월 30일
That solved the problem. Now I'll continue to work through the rest of the program. Many thanks!

Iraj Hosseini
Iraj Hosseini 2018년 11월 5일
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

커뮤니티

더 많은 답변 보기:  SimBiology Community

카테고리

Help CenterFile Exchange에서 Biotech and Pharmaceutical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by