135 lines (134 with data), 4.6 kB
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "d111d29e",
"metadata": {},
"outputs": [],
"source": [
"import pymskt as mskt\n",
"from pymskt.mesh import BoneMesh, CartilageMesh\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "789c7b95",
"metadata": {},
"outputs": [],
"source": [
"location_seg = '../data/right_knee_example.nrrd'"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "8d3b74d5",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/gattia/opt/miniconda3/envs/imaging/lib/python3.8/site-packages/pyvista/core/dataset.py:1401: PyvistaDeprecationWarning: Use of `point_arrays` is deprecated. Use `point_data` instead.\n",
" warnings.warn(\n",
"/Users/gattia/opt/miniconda3/envs/imaging/lib/python3.8/site-packages/pyvista/core/dataset.py:1541: PyvistaDeprecationWarning: Use of `cell_arrays` is deprecated. Use `cell_data` instead.\n",
" warnings.warn(\n"
]
}
],
"source": [
"# initiate the bone mesh object\n",
"femur = BoneMesh(path_seg_image=location_seg, # path to the segmentation iamge being used\n",
" label_idx=5, # what is the label of this bone\n",
" list_cartilage_labels=[1]) # a list of labels for cartialge associated w/ this bone\n",
"# Create the bone mesh\n",
"femur.create_mesh(smooth_image_var=1.0)\n",
"# Resample the bone surface to have a specified number of nodes. \n",
"femur.resample_surface(clusters=20000)\n",
"# Calcualte cartialge thickness for the cartialge meshes associated with the bone\n",
"femur.calc_cartilage_thickness(image_smooth_var_cart=0.5)\n",
"\n",
"# initiate the bone mesh object\n",
"tibia = BoneMesh(path_seg_image=location_seg, # path to the segmentation iamge being used\n",
" label_idx=6, # what is the label of this bone\n",
" list_cartilage_labels=[2,3]) # a list of labels for cartialge associated w/ this bone\n",
"# Create the bone mesh\n",
"tibia.create_mesh(smooth_image_var=1.0)\n",
"# Resample the bone surface to have a specified number of nodes. \n",
"tibia.resample_surface(clusters=20000)\n",
"# Calcualte cartialge thickness for the cartialge meshes associated with the bone\n",
"tibia.calc_cartilage_thickness(image_smooth_var_cart=0.5)\n",
"\n",
"# initiate the bone mesh object\n",
"patella = BoneMesh(path_seg_image=location_seg, # path to the segmentation iamge being used\n",
" label_idx=7, # what is the label of this bone\n",
" list_cartilage_labels=[4]) # a list of labels for cartialge associated w/ this bone\n",
"# Create the bone mesh\n",
"patella.create_mesh(smooth_image_var=1.0)\n",
"# Resample the bone surface to have a specified number of nodes. \n",
"patella.resample_surface(clusters=20000)\n",
"# Calcualte cartialge thickness for the cartialge meshes associated with the bone\n",
"patella.calc_cartilage_thickness(image_smooth_var_cart=0.5)\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "c8545c2b",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "93f0b8b465c242c7baa89c10d50e8a1f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[{'vtkClass': 'vtkPolyData', 'points': {'vtkClass': 'vtkPoints', 'name': '_points', 'numberO…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from itkwidgets import view\n",
"\n",
"view(geometries=[femur.mesh, tibia.mesh, patella.mesh])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ebcd94a9",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.12 64-bit ('imaging': conda)",
"language": "python",
"name": "python3812jvsc74a57bd06c87bace85be111efbe28079ae26f740e5c4bf58b006b66c98bd87f126cf4b07"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}