Configure Editor
PoPy is script driven, so it is very important to have a suitable editor installed on your system.
We recommended that you use Notepad++ to edit PoPy text files.
Note
It is especially important that you follow the advice in Configure Notepad++ Tabs for Indentation.
Notepad++
Notepad++ is a text editor that uses tabs and context highlighting, both of which are helpful when editing PoPy script files.
Install Notepad++
Download the installer from https://notepad-plus-plus.org/download/ and run it.
If you install the 64-bit binary installer the default install directory is C:\Program Files\Notepad++
but you may install Notepad++ at another location.
Configure Notepad++ Tabs for Indentation
PoPy is written in Python, and Python does not like tabs for indentation. It is essential that you set this from within Notepad++:-
Settings->Preferences->Indentation->Indent Using: Space character(s)
The default tab size is 4, which is a sensible choice.
Note this means that when you hit the tab key you will get 4 space characters instead of a tab character. To check that this is the case do:-
View->Show Symbol->Show Space and Tab
Then Notepad++ will give you a faint orange dot for a space character and an arrow for a tab. You are advised to delete any tabs you have in your *.pyml files.
Note that it is still possible to introduce tabs into your text file accidentally using cut and paste.
Python using spaces instead of the more conventional curly brackets is an endearing, perhaps controversial, language feature. (See https://jayconrod.com/posts/101/how-python-parses-white-space for a fairly balanced discussion of the pros and cons of white spacing.)
However PoPy uses Python, so it is white space for us.
Configure Notepad++ Colouring
It is highly advisable to load in the PoPy xml syntax highlighting file. You do this by opening Notepad++ and doing:-
Language->User Defined Language->Define your language...
Import...
Then selecting the c:\PoPy\conf\notepadplusplus_popy.xml file.
You should then be able to open any *.pyml file and see the variables coloured like this:-
DERIVATIVES: |
# s[DEPOT,CENTRAL,PERI] = @dep_two_cmp_cl{dose:@bolus{amt:c[AMT]}}
d[DEPOT] = @bolus{amt:c[AMT]} - m[KA]*s[DEPOT]
d[CENTRAL] = (
m[KA]*s[DEPOT] - s[CENTRAL]*m[CL]/m[V1]
- s[CENTRAL]*m[Q]/m[V1] + s[PERI]*m[Q]/m[V2]
)
d[PERI] = s[CENTRAL]*m[Q]/m[V1] - s[PERI]*m[Q]/m[V2]
PREDICTIONS: |
p[DV_CENTRAL] = s[CENTRAL]/m[V1]
var = m[ANOISE]**2 + m[PNOISE]**2 * p[DV_CENTRAL]**2
c[DV_CENTRAL] ~ norm(p[DV_CENTRAL], var)
As opposed to the default (plain) Notepad++ text display, like this:-
DERIVATIVES: |
# s[DEPOT,CENTRAL,PERI] = @dep_two_cmp_cl{dose:@bolus{amt:c[AMT]}}
d[DEPOT] = @bolus{amt:c[AMT]} - m[KA]*s[DEPOT]
d[CENTRAL] = (
m[KA]*s[DEPOT] - s[CENTRAL]*m[CL]/m[V1]
- s[CENTRAL]*m[Q]/m[V1] + s[PERI]*m[Q]/m[V2]
)
d[PERI] = s[CENTRAL]*m[Q]/m[V1] - s[PERI]*m[Q]/m[V2]
PREDICTIONS: |
p[DV_CENTRAL] = s[CENTRAL]/m[V1]
var = m[ANOISE]**2 + m[PNOISE]**2 * p[DV_CENTRAL]**2
c[DV_CENTRAL] ~ norm(p[DV_CENTRAL], var)
Note that it might be necessary to restart Notepad++ to get the colouring file to work.
We find that the variable colouring, makes model editing easier and less error prone. For example, if you misspell a section header e.g “DERVIATIVES”, then you will notice because the section header will not appear in bold.
The colouring file also just makes PK/PD models look nicer.