|
152 | 152 | "cell_type": "markdown",
|
153 | 153 | "metadata": {},
|
154 | 154 | "source": [
|
155 |
| - "### Observables\n", |
| 155 | + "### Observation model\n", |
156 | 156 | "\n",
|
157 |
| - "Specifying observables is beyond the scope of SBML. Here we define them manually.\n", |
| 157 | + "Specifying the observation model (i.e., the quantities that are observed, as well as the respective error models) is beyond the scope of SBML. Here we define that manually.\n", |
| 158 | + "\n", |
| 159 | + "If you are looking for a more scalable way of defining observables, then checkout [PEtab](https://github.com/PEtab-dev/PEtab). Another possibility is using SBML's [`AssignmentRule`s](https://sbml.org/software/libsbml/5.18.0/docs/formatted/python-api/classlibsbml_1_1_assignment_rule.html) to specify model outputs within the SBML file.\n", |
158 | 160 | "\n",
|
159 |
| - "If you are looking for a more scalable way for defining observables, then checkout [PEtab](https://github.com/PEtab-dev/PEtab). Another possibility is using SBML's [`AssignmentRule`s](https://sbml.org/software/libsbml/5.18.0/docs/formatted/python-api/classlibsbml_1_1_assignment_rule.html) to specify model outputs within the SBML file." |
160 |
| - ] |
161 |
| - }, |
162 |
| - { |
163 |
| - "cell_type": "code", |
164 |
| - "execution_count": 5, |
165 |
| - "metadata": {}, |
166 |
| - "outputs": [], |
167 |
| - "source": [ |
168 |
| - "# Define observables\n", |
169 |
| - "observables = {\n", |
170 |
| - " \"observable_x1\": {\"name\": \"\", \"formula\": \"x1\"},\n", |
171 |
| - " \"observable_x2\": {\"name\": \"\", \"formula\": \"x2\"},\n", |
172 |
| - " \"observable_x3\": {\"name\": \"\", \"formula\": \"x3\"},\n", |
173 |
| - " \"observable_x1_scaled\": {\"name\": \"\", \"formula\": \"scaling_x1 * x1\"},\n", |
174 |
| - " \"observable_x2_offsetted\": {\"name\": \"\", \"formula\": \"offset_x2 + x2\"},\n", |
175 |
| - " \"observable_x1withsigma\": {\"name\": \"\", \"formula\": \"x1\"},\n", |
176 |
| - "}" |
177 |
| - ] |
178 |
| - }, |
179 |
| - { |
180 |
| - "cell_type": "markdown", |
181 |
| - "metadata": {}, |
182 |
| - "source": [ |
183 |
| - "### $\\sigma$ parameters\n", |
184 | 161 | "\n",
|
185 |
| - "To specify measurement noise as a parameter, we simply provide a dictionary with (preexisting) parameter names as keys and a list of observable names as values to indicate which sigma parameter is to be used for which observable." |
| 162 | + "\n", |
| 163 | + "For model import in AMICI, the different types of measurements are represented as `MeasurementChannels`.\n", |
| 164 | + "The measurement channel is characterized by an ID, an optional name, the observation function (`MeasurementChannels.formula`), the type of noise distribution (`MeasurementChannels.noise_distribution`, defaults to a normal distribution), and the scale parameter of that distribution (`MeasurementChannels.sigma`).\n", |
| 165 | + "The symbols used in the observation function and for the scale parameter must already be defined in the model." |
186 | 166 | ]
|
187 | 167 | },
|
188 | 168 | {
|
189 | 169 | "cell_type": "code",
|
190 |
| - "execution_count": 6, |
| 170 | + "execution_count": 5, |
191 | 171 | "metadata": {},
|
192 | 172 | "outputs": [],
|
193 | 173 | "source": [
|
194 |
| - "sigmas = {\"observable_x1withsigma\": \"observable_x1withsigma_sigma\"}" |
| 174 | + "# Define observation model\n", |
| 175 | + "from amici import MeasurementChannel as MC\n", |
| 176 | + "\n", |
| 177 | + "observation_model = [\n", |
| 178 | + " MC(id_=\"observable_x1\", formula=\"x1\"),\n", |
| 179 | + " MC(id_=\"observable_x2\", formula=\"x2\"),\n", |
| 180 | + " MC(id_=\"observable_x3\", formula=\"x3\"),\n", |
| 181 | + " MC(id_=\"observable_x1_scaled\", formula=\"scaling_x1 * x1\"),\n", |
| 182 | + " MC(id_=\"observable_x2_offsetted\", formula=\"offset_x2 + x2\"),\n", |
| 183 | + " MC(\n", |
| 184 | + " id_=\"observable_x1withsigma\",\n", |
| 185 | + " formula=\"x1\",\n", |
| 186 | + " sigma=\"observable_x1withsigma_sigma\",\n", |
| 187 | + " ),\n", |
| 188 | + "]" |
195 | 189 | ]
|
196 | 190 | },
|
197 | 191 | {
|
|
340 | 334 | " model_name,\n",
|
341 | 335 | " model_output_dir,\n",
|
342 | 336 | " verbose=logging.INFO,\n",
|
343 |
| - " observables=observables,\n", |
| 337 | + " observation_model=observation_model,\n", |
344 | 338 | " constant_parameters=constant_parameters,\n",
|
345 |
| - " sigmas=sigmas,\n", |
346 | 339 | ")"
|
347 | 340 | ]
|
348 | 341 | },
|
|
0 commit comments