|
a |
|
b/examples/create meshes/Detailed Example of setting and updating parameters for pymskt Feb.3.2022.ipynb |
|
|
1 |
{ |
|
|
2 |
"cells": [ |
|
|
3 |
{ |
|
|
4 |
"cell_type": "code", |
|
|
5 |
"execution_count": 3, |
|
|
6 |
"id": "8e4667b0", |
|
|
7 |
"metadata": {}, |
|
|
8 |
"outputs": [], |
|
|
9 |
"source": [ |
|
|
10 |
"import pymskt as mskt\n", |
|
|
11 |
"from pymskt.mesh import BoneMesh, CartilageMesh\n", |
|
|
12 |
"import SimpleITK as sitk\n", |
|
|
13 |
"import matplotlib.pyplot as plt\n", |
|
|
14 |
"import numpy as np\n", |
|
|
15 |
"import os" |
|
|
16 |
] |
|
|
17 |
}, |
|
|
18 |
{ |
|
|
19 |
"cell_type": "code", |
|
|
20 |
"execution_count": 2, |
|
|
21 |
"id": "99154fe7", |
|
|
22 |
"metadata": {}, |
|
|
23 |
"outputs": [], |
|
|
24 |
"source": [ |
|
|
25 |
"location_seg = '../data/right_knee_example.nrrd'" |
|
|
26 |
] |
|
|
27 |
}, |
|
|
28 |
{ |
|
|
29 |
"cell_type": "markdown", |
|
|
30 |
"id": "a09da648", |
|
|
31 |
"metadata": {}, |
|
|
32 |
"source": [ |
|
|
33 |
"To create a mesh, we must first pass a segmentation image (simpleitk) to the mesh object. This can be done in multiple ways. " |
|
|
34 |
] |
|
|
35 |
}, |
|
|
36 |
{ |
|
|
37 |
"cell_type": "markdown", |
|
|
38 |
"id": "e7d2d9e0", |
|
|
39 |
"metadata": {}, |
|
|
40 |
"source": [ |
|
|
41 |
"- Show all of the ways to assign segmentations & meshes (bone & cartilage) to the BoneMesh object" |
|
|
42 |
] |
|
|
43 |
}, |
|
|
44 |
{ |
|
|
45 |
"cell_type": "code", |
|
|
46 |
"execution_count": null, |
|
|
47 |
"id": "e84de078", |
|
|
48 |
"metadata": {}, |
|
|
49 |
"outputs": [], |
|
|
50 |
"source": [ |
|
|
51 |
"# we can pass the location of the seg image directly to the function \n", |
|
|
52 |
"# right now, this takes only single files (.nrrd, .nii.gz, .dcm (3D))\n", |
|
|
53 |
"# there is currently an issue opened to allow passing a dicom folder. \n", |
|
|
54 |
"# https://github.com/gattia/pymskt/issues/16\n", |
|
|
55 |
"femur = BoneMesh(path_seg_image = location_seg)\n", |
|
|
56 |
"\n", |
|
|
57 |
"# alternatively, we can set or update the seg_image later using an actual SitkImage\n", |
|
|
58 |
"seg_image = sitk.ReadImage(location_seg)\n", |
|
|
59 |
"femur.seg_image = seg_image\n", |
|
|
60 |
"\n", |
|
|
61 |
"# or we can pass the path directly to the `Mesh.read_seg_image()` function: \n", |
|
|
62 |
"femur.read_seg_image(location_seg_image)\n", |
|
|
63 |
"\n" |
|
|
64 |
] |
|
|
65 |
}, |
|
|
66 |
{ |
|
|
67 |
"cell_type": "markdown", |
|
|
68 |
"id": "6a4f13a9", |
|
|
69 |
"metadata": {}, |
|
|
70 |
"source": [ |
|
|
71 |
"- Show details on how to crop bones" |
|
|
72 |
] |
|
|
73 |
}, |
|
|
74 |
{ |
|
|
75 |
"cell_type": "code", |
|
|
76 |
"execution_count": null, |
|
|
77 |
"id": "5034eac3", |
|
|
78 |
"metadata": {}, |
|
|
79 |
"outputs": [], |
|
|
80 |
"source": [] |
|
|
81 |
} |
|
|
82 |
], |
|
|
83 |
"metadata": { |
|
|
84 |
"kernelspec": { |
|
|
85 |
"display_name": "Python 3.8.12 64-bit ('imaging': conda)", |
|
|
86 |
"language": "python", |
|
|
87 |
"name": "python3812jvsc74a57bd06c87bace85be111efbe28079ae26f740e5c4bf58b006b66c98bd87f126cf4b07" |
|
|
88 |
}, |
|
|
89 |
"language_info": { |
|
|
90 |
"codemirror_mode": { |
|
|
91 |
"name": "ipython", |
|
|
92 |
"version": 3 |
|
|
93 |
}, |
|
|
94 |
"file_extension": ".py", |
|
|
95 |
"mimetype": "text/x-python", |
|
|
96 |
"name": "python", |
|
|
97 |
"nbconvert_exporter": "python", |
|
|
98 |
"pygments_lexer": "ipython3", |
|
|
99 |
"version": "3.8.12" |
|
|
100 |
} |
|
|
101 |
}, |
|
|
102 |
"nbformat": 4, |
|
|
103 |
"nbformat_minor": 5 |
|
|
104 |
} |