|
19 | 19 | "from entitysdk.models import (\n", |
20 | 20 | " BrainLocation,\n", |
21 | 21 | " BrainRegion,\n", |
| 22 | + " CellMorphology,\n", |
| 23 | + " CellMorphologyProtocol,\n", |
22 | 24 | " Contribution,\n", |
23 | 25 | " MTypeClass,\n", |
24 | 26 | " MTypeClassification,\n", |
25 | 27 | " Organization,\n", |
26 | | - " ReconstructionMorphology,\n", |
27 | 28 | " Role,\n", |
28 | 29 | " Species,\n", |
29 | 30 | " Strain,\n", |
| 31 | + " Subject,\n", |
| 32 | + ")\n", |
| 33 | + "from entitysdk.types import (\n", |
| 34 | + " CellMorphologyGenerationType,\n", |
| 35 | + " CellMorphologyProtocolDesign,\n", |
| 36 | + " SlicingDirectionType,\n", |
30 | 37 | ")" |
31 | 38 | ] |
32 | 39 | }, |
|
130 | 137 | "rprint(brain_region)" |
131 | 138 | ] |
132 | 139 | }, |
| 140 | + { |
| 141 | + "cell_type": "markdown", |
| 142 | + "id": "65bea11e", |
| 143 | + "metadata": {}, |
| 144 | + "source": [ |
| 145 | + "### Create and register a new subject" |
| 146 | + ] |
| 147 | + }, |
| 148 | + { |
| 149 | + "cell_type": "markdown", |
| 150 | + "id": "40772ff8", |
| 151 | + "metadata": {}, |
| 152 | + "source": [ |
| 153 | + "Subjects should be reused if possible, but they can be created when needed." |
| 154 | + ] |
| 155 | + }, |
| 156 | + { |
| 157 | + "cell_type": "code", |
| 158 | + "execution_count": null, |
| 159 | + "id": "c78f0e4d", |
| 160 | + "metadata": {}, |
| 161 | + "outputs": [], |
| 162 | + "source": [ |
| 163 | + "subject = Subject(\n", |
| 164 | + " name=\"my-subject-for-morphology\",\n", |
| 165 | + " description=\"my-subject-description\",\n", |
| 166 | + " sex=\"male\",\n", |
| 167 | + " species=species,\n", |
| 168 | + " strain=strain,\n", |
| 169 | + ")\n", |
| 170 | + "\n", |
| 171 | + "subject = client.register_entity(subject)\n", |
| 172 | + "rprint(subject)" |
| 173 | + ] |
| 174 | + }, |
| 175 | + { |
| 176 | + "cell_type": "markdown", |
| 177 | + "id": "62e916c9", |
| 178 | + "metadata": {}, |
| 179 | + "source": [ |
| 180 | + "### Create and register a new morphology protocol" |
| 181 | + ] |
| 182 | + }, |
| 183 | + { |
| 184 | + "cell_type": "markdown", |
| 185 | + "id": "1b2dacaf", |
| 186 | + "metadata": {}, |
| 187 | + "source": [ |
| 188 | + "Morphology protocols should be reused if possible, but they can be created when needed." |
| 189 | + ] |
| 190 | + }, |
| 191 | + { |
| 192 | + "cell_type": "code", |
| 193 | + "execution_count": null, |
| 194 | + "id": "5200e8cf", |
| 195 | + "metadata": {}, |
| 196 | + "outputs": [], |
| 197 | + "source": [ |
| 198 | + "morphology_protocol = CellMorphologyProtocol(\n", |
| 199 | + " generation_type=CellMorphologyGenerationType.digital_reconstruction,\n", |
| 200 | + " protocol_document=\"https://example.com/\",\n", |
| 201 | + " protocol_design=CellMorphologyProtocolDesign.cell_patch,\n", |
| 202 | + " slicing_thickness=20.0,\n", |
| 203 | + " slicing_direction=SlicingDirectionType.horizontal,\n", |
| 204 | + ")\n", |
| 205 | + "rprint(morphology_protocol.__class__.__name__)\n", |
| 206 | + "morphology_protocol = client.register_entity(morphology_protocol)\n", |
| 207 | + "rprint(morphology_protocol)" |
| 208 | + ] |
| 209 | + }, |
| 210 | + { |
| 211 | + "cell_type": "markdown", |
| 212 | + "id": "ff0d1d01", |
| 213 | + "metadata": {}, |
| 214 | + "source": [ |
| 215 | + "### Optional, list morphology protocols" |
| 216 | + ] |
| 217 | + }, |
| 218 | + { |
| 219 | + "cell_type": "code", |
| 220 | + "execution_count": null, |
| 221 | + "id": "71818153", |
| 222 | + "metadata": {}, |
| 223 | + "outputs": [], |
| 224 | + "source": [ |
| 225 | + "protocols = client.search_entity(entity_type=CellMorphologyProtocol).all()\n", |
| 226 | + "rprint(protocols)" |
| 227 | + ] |
| 228 | + }, |
133 | 229 | { |
134 | 230 | "cell_type": "markdown", |
135 | 231 | "id": "a0193055-3448-4d1c-99cc-4d953727ef4e", |
|
150 | 246 | " y=1173.8499755859375,\n", |
151 | 247 | " z=4744.60009765625,\n", |
152 | 248 | ")\n", |
153 | | - "morphology = ReconstructionMorphology(\n", |
| 249 | + "morphology = CellMorphology(\n", |
| 250 | + " cell_morphology_protocol=morphology_protocol,\n", |
154 | 251 | " name=\"my-morph\",\n", |
155 | 252 | " description=\"A morphology\",\n", |
156 | | - " species=species,\n", |
157 | | - " strain=strain,\n", |
| 253 | + " subject=subject,\n", |
158 | 254 | " brain_region=brain_region,\n", |
159 | 255 | " location=brain_location,\n", |
160 | 256 | " legacy_id=None,\n", |
161 | | - " authorized_public=True,\n", |
| 257 | + " authorized_public=False,\n", |
162 | 258 | ")" |
163 | 259 | ] |
164 | 260 | }, |
|
190 | 286 | "registered = client.register_entity(entity=morphology)" |
191 | 287 | ] |
192 | 288 | }, |
| 289 | + { |
| 290 | + "cell_type": "code", |
| 291 | + "execution_count": null, |
| 292 | + "id": "6b029401", |
| 293 | + "metadata": {}, |
| 294 | + "outputs": [], |
| 295 | + "source": [ |
| 296 | + "rprint(registered)" |
| 297 | + ] |
| 298 | + }, |
193 | 299 | { |
194 | 300 | "cell_type": "markdown", |
195 | 301 | "id": "5a4482d8-d5d4-45b9-80cb-264c1a531216", |
|
274 | 380 | " # use a filepath to register first asset\n", |
275 | 381 | " asset1 = client.upload_file(\n", |
276 | 382 | " entity_id=registered.id,\n", |
277 | | - " entity_type=ReconstructionMorphology,\n", |
| 383 | + " entity_type=CellMorphology,\n", |
278 | 384 | " file_path=file1,\n", |
279 | 385 | " file_content_type=\"application/x-hdf5\",\n", |
280 | 386 | " asset_label=\"morphology\",\n", |
|
286 | 392 | "\n", |
287 | 393 | " asset2 = client.upload_content(\n", |
288 | 394 | " entity_id=registered.id,\n", |
289 | | - " entity_type=ReconstructionMorphology,\n", |
| 395 | + " entity_type=CellMorphology,\n", |
290 | 396 | " file_content=buffer,\n", |
291 | 397 | " file_name=\"buffer.swc\",\n", |
292 | 398 | " file_content_type=\"application/swc\",\n", |
|
311 | 417 | "outputs": [], |
312 | 418 | "source": [ |
313 | 419 | "# with assets and mtypes\n", |
314 | | - "fetched = client.get_entity(entity_id=registered.id, entity_type=ReconstructionMorphology)" |
| 420 | + "fetched = client.get_entity(entity_id=registered.id, entity_type=CellMorphology)" |
315 | 421 | ] |
316 | 422 | }, |
317 | 423 | { |
|
370 | 476 | "\n", |
371 | 477 | "rprint(deleted_asset)\n", |
372 | 478 | "\n", |
373 | | - "fetched = client.get_entity(entity_id=registered.id, entity_type=ReconstructionMorphology)\n", |
| 479 | + "fetched = client.get_entity(entity_id=registered.id, entity_type=CellMorphology)\n", |
374 | 480 | "rprint(fetched.assets)" |
375 | 481 | ] |
376 | 482 | }, |
|
390 | 496 | "outputs": [], |
391 | 497 | "source": [ |
392 | 498 | "hits = client.search_entity(\n", |
393 | | - " entity_type=ReconstructionMorphology,\n", |
| 499 | + " entity_type=CellMorphology,\n", |
394 | 500 | " query={\"name__ilike\": \"my-morph\", \"page\": 1, \"page_size\": 2},\n", |
395 | 501 | " limit=None,\n", |
396 | 502 | ").all()\n", |
|
426 | 532 | "## register a file\n", |
427 | 533 | "# asset = client.register_asset(\n", |
428 | 534 | "# entity_id=registered.id,\n", |
429 | | - "# entity_type=ReconstructionMorphology,\n", |
| 535 | + "# entity_type=CellMorphology,\n", |
430 | 536 | "# name=\"my-morphology.h5\",\n", |
431 | 537 | "# storage_path=\"path/to/morph.h5\",\n", |
432 | 538 | "# storage_type=\"aws_s3_open\",\n", |
|
458 | 564 | } |
459 | 565 | ], |
460 | 566 | "metadata": { |
461 | | - "kernelspec": { |
462 | | - "display_name": "entitysdk", |
463 | | - "language": "python", |
464 | | - "name": "python3" |
465 | | - }, |
466 | 567 | "language_info": { |
467 | | - "codemirror_mode": { |
468 | | - "name": "ipython", |
469 | | - "version": 3 |
470 | | - }, |
471 | | - "file_extension": ".py", |
472 | | - "mimetype": "text/x-python", |
473 | | - "name": "python", |
474 | | - "nbconvert_exporter": "python", |
475 | | - "pygments_lexer": "ipython3", |
476 | | - "version": "3.11.11" |
| 568 | + "name": "python" |
477 | 569 | } |
478 | 570 | }, |
479 | 571 | "nbformat": 4, |
|
0 commit comments