"
+ ]
+ },
+ "execution_count": 12,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
@@ -159,7 +186,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 13,
"metadata": {},
"outputs": [
{
@@ -216,7 +243,7 @@
" [-1000, -1000, -1000, ..., -1000, -1000, -1000]]], dtype=int16)"
]
},
- "execution_count": 7,
+ "execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@@ -235,7 +262,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 14,
"metadata": {},
"outputs": [
{
@@ -275,7 +302,7 @@
" [0., 0., 1.]])}"
]
},
- "execution_count": 8,
+ "execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@@ -302,7 +329,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
@@ -311,7 +338,7 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
@@ -352,7 +379,7 @@
" [0., 0., 1.]])}"
]
},
- "execution_count": 10,
+ "execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
@@ -373,7 +400,7 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
@@ -382,7 +409,7 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 18,
"metadata": {},
"outputs": [
{
@@ -427,7 +454,7 @@
" [0., 0., 1.]])}"
]
},
- "execution_count": 12,
+ "execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
@@ -457,7 +484,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 19,
"metadata": {},
"outputs": [
{
@@ -494,6 +521,7 @@
"}\n",
"\n",
"html[theme=dark],\n",
+ "body[data-theme=dark],\n",
"body.vscode-dark {\n",
" --xr-font-color0: rgba(255, 255, 255, 1);\n",
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
@@ -506,7 +534,7 @@
"}\n",
"\n",
".xr-wrap {\n",
- " display: block;\n",
+ " display: block !important;\n",
" min-width: 300px;\n",
" max-width: 700px;\n",
"}\n",
@@ -723,6 +751,11 @@
" grid-column: 4;\n",
"}\n",
"\n",
+ ".xr-index-preview {\n",
+ " grid-column: 2 / 5;\n",
+ " color: var(--xr-font-color2);\n",
+ "}\n",
+ "\n",
".xr-var-name,\n",
".xr-var-dims,\n",
".xr-var-dtype,\n",
@@ -744,14 +777,16 @@
"}\n",
"\n",
".xr-var-attrs,\n",
- ".xr-var-data {\n",
+ ".xr-var-data,\n",
+ ".xr-index-data {\n",
" display: none;\n",
" background-color: var(--xr-background-color) !important;\n",
" padding-bottom: 5px !important;\n",
"}\n",
"\n",
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
- ".xr-var-data-in:checked ~ .xr-var-data {\n",
+ ".xr-var-data-in:checked ~ .xr-var-data,\n",
+ ".xr-index-data-in:checked ~ .xr-index-data {\n",
" display: block;\n",
"}\n",
"\n",
@@ -761,13 +796,16 @@
"\n",
".xr-var-name span,\n",
".xr-var-data,\n",
+ ".xr-index-name div,\n",
+ ".xr-index-data,\n",
".xr-attrs {\n",
" padding-left: 25px !important;\n",
"}\n",
"\n",
".xr-attrs,\n",
".xr-var-attrs,\n",
- ".xr-var-data {\n",
+ ".xr-var-data,\n",
+ ".xr-index-data {\n",
" grid-column: 1 / -1;\n",
"}\n",
"\n",
@@ -805,7 +843,8 @@
"}\n",
"\n",
".xr-icon-database,\n",
- ".xr-icon-file-text2 {\n",
+ ".xr-icon-file-text2,\n",
+ ".xr-no-icon {\n",
" display: inline-block;\n",
" vertical-align: middle;\n",
" width: 1em;\n",
@@ -814,7 +853,7 @@
" stroke: currentColor;\n",
" fill: currentColor;\n",
"}\n",
- "<xarray.DataArray (z: 51, y: 1024, x: 1024)>\n",
+ "<xarray.DataArray 'image' (z: 51, y: 1024, x: 1024)>\n",
"array([[[-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
" [-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
" [-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
@@ -873,7 +912,7 @@
" Site: 5\n",
" SliceIncrement: 0.036000000000000004\n",
" SliceThickness: 0.036000000000000004\n",
- " Version: CTDATA-HEADER_V1
-1000 -1000 -1000 -1000 -1000 -1000 ... -1000 -1000 -1000 -1000 -1000
array([[[-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
+ " Version: CTDATA-HEADER_V1
-1000 -1000 -1000 -1000 -1000 -1000 ... -1000 -1000 -1000 -1000 -1000
array([[[-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
" [-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
" [-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
" ...,\n",
@@ -913,19 +952,55 @@
" ...,\n",
" [-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
" [-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
- " [-1000, -1000, -1000, ..., -1000, -1000, -1000]]], dtype=int16)
x
(x)
float64
0.0 0.036 0.072 ... 36.79 36.83
array([0.0000e+00, 3.6000e-02, 7.2000e-02, ..., 3.6756e+01, 3.6792e+01,\n",
- " 3.6828e+01])
y
(y)
float64
0.0 0.036 0.072 ... 36.79 36.83
array([0.0000e+00, 3.6000e-02, 7.2000e-02, ..., 3.6756e+01, 3.6792e+01,\n",
- " 3.6828e+01])
z
(z)
float64
0.0 0.036 0.072 ... 1.728 1.764 1.8
array([0. , 0.036, 0.072, 0.108, 0.144, 0.18 , 0.216, 0.252, 0.288, 0.324,\n",
+ " [-1000, -1000, -1000, ..., -1000, -1000, -1000]]], dtype=int16)
x
(x)
float64
0.0 0.036 0.072 ... 36.79 36.83
array([0.0000e+00, 3.6000e-02, 7.2000e-02, ..., 3.6756e+01, 3.6792e+01,\n",
+ " 3.6828e+01])
y
(y)
float64
0.0 0.036 0.072 ... 36.79 36.83
array([0.0000e+00, 3.6000e-02, 7.2000e-02, ..., 3.6756e+01, 3.6792e+01,\n",
+ " 3.6828e+01])
z
(z)
float64
0.0 0.036 0.072 ... 1.728 1.764 1.8
array([0. , 0.036, 0.072, 0.108, 0.144, 0.18 , 0.216, 0.252, 0.288, 0.324,\n",
" 0.36 , 0.396, 0.432, 0.468, 0.504, 0.54 , 0.576, 0.612, 0.648, 0.684,\n",
" 0.72 , 0.756, 0.792, 0.828, 0.864, 0.9 , 0.936, 0.972, 1.008, 1.044,\n",
" 1.08 , 1.116, 1.152, 1.188, 1.224, 1.26 , 1.296, 1.332, 1.368, 1.404,\n",
" 1.44 , 1.476, 1.512, 1.548, 1.584, 1.62 , 1.656, 1.692, 1.728, 1.764,\n",
- " 1.8 ])
- direction :
- [[1. 0. 0.]\n",
+ " 1.8 ])
PandasIndex
PandasIndex(Float64Index([ 0.0, 0.036000000000000004, 0.07200000000000001,\n",
+ " 0.10800000000000001, 0.14400000000000002, 0.18000000000000002,\n",
+ " 0.21600000000000003, 0.252, 0.28800000000000003,\n",
+ " 0.32400000000000007,\n",
+ " ...\n",
+ " 36.504000000000005, 36.540000000000006, 36.57600000000001,\n",
+ " 36.612, 36.648, 36.684000000000005,\n",
+ " 36.720000000000006, 36.75600000000001, 36.792,\n",
+ " 36.828],\n",
+ " dtype='float64', name='x', length=1024))
PandasIndex
PandasIndex(Float64Index([ 0.0, 0.036000000000000004, 0.07200000000000001,\n",
+ " 0.10800000000000001, 0.14400000000000002, 0.18000000000000002,\n",
+ " 0.21600000000000003, 0.252, 0.28800000000000003,\n",
+ " 0.32400000000000007,\n",
+ " ...\n",
+ " 36.504000000000005, 36.540000000000006, 36.57600000000001,\n",
+ " 36.612, 36.648, 36.684000000000005,\n",
+ " 36.720000000000006, 36.75600000000001, 36.792,\n",
+ " 36.828],\n",
+ " dtype='float64', name='y', length=1024))
PandasIndex
PandasIndex(Float64Index([ 0.0, 0.036000000000000004, 0.07200000000000001,\n",
+ " 0.10800000000000001, 0.14400000000000002, 0.18000000000000002,\n",
+ " 0.21600000000000003, 0.252, 0.28800000000000003,\n",
+ " 0.32400000000000007, 0.36000000000000004, 0.396,\n",
+ " 0.43200000000000005, 0.4680000000000001, 0.504,\n",
+ " 0.54, 0.5760000000000001, 0.6120000000000001,\n",
+ " 0.6480000000000001, 0.684, 0.7200000000000001,\n",
+ " 0.7560000000000001, 0.792, 0.8280000000000001,\n",
+ " 0.8640000000000001, 0.9000000000000001, 0.9360000000000002,\n",
+ " 0.9720000000000001, 1.008, 1.044,\n",
+ " 1.08, 1.116, 1.1520000000000001,\n",
+ " 1.1880000000000002, 1.2240000000000002, 1.2600000000000002,\n",
+ " 1.2960000000000003, 1.332, 1.368,\n",
+ " 1.4040000000000001, 1.4400000000000002, 1.4760000000000002,\n",
+ " 1.5120000000000002, 1.5480000000000003, 1.584,\n",
+ " 1.62, 1.6560000000000001, 1.6920000000000002,\n",
+ " 1.7280000000000002, 1.7640000000000002,\n",
+ " 1.8000000000000003],\n",
+ " dtype='float64', name='z'))
- direction :
- [[1. 0. 0.]\n",
" [0. 1. 0.]\n",
" [0. 0. 1.]]
- CalibrationData :
- 45 kVp, 0.5mm Al, BH: 1200mg HA/ccm, Scaling 4096
- CreationDate :
- 5-JUN-2015 11:09:18.880
- DataRange :
- (-2813.0, 32767.0)
- Energy :
- 45.0
- Intensity :
- 0.177
- MeasurementIndex :
- 4937
- ModificationDate :
- 5-JUN-2015 11:09:18.880
- MuScaling :
- 4096.0
- MuWater :
- 0.7032999992370605
- NumberOfProjections :
- 500
- NumberOfSamples :
- 1024
- PatientIndex :
- 78
- PatientName :
- COLE-BPBP
- ReconstructionAlg :
- 3
- ReferenceLine :
- 0.0
- RescaleIntercept :
- -1000.0
- RescaleSlope :
- 0.34713582434927287
- RescaleType :
- 2
- RescaleUnits :
- mg HA/ccm
- SampleTime :
- 400.0
- ScanDistance :
- 36.864000000000004
- ScannerID :
- 2135
- ScannerType :
- 10
- Site :
- 5
- SliceIncrement :
- 0.036000000000000004
- SliceThickness :
- 0.036000000000000004
- Version :
- CTDATA-HEADER_V1
"
],
"text/plain": [
- "\n",
+ "\n",
"array([[[-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
" [-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
" [-1000, -1000, -1000, ..., -1000, -1000, -1000],\n",
@@ -987,7 +1062,7 @@
" Version: CTDATA-HEADER_V1"
]
},
- "execution_count": 13,
+ "execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@@ -999,7 +1074,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
@@ -1010,7 +1085,7 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
@@ -1019,7 +1094,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 22,
"metadata": {},
"outputs": [
{
@@ -1058,7 +1133,7 @@
" [0., 0., 1.]])}"
]
},
- "execution_count": 16,
+ "execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -1071,7 +1146,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -1085,9 +1160,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.9.2"
+ "version": "3.10.8"
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/examples/ReadISQ.ipynb b/examples/ReadISQ.ipynb
index d2522c5..3c3ddfc 100644
--- a/examples/ReadISQ.ipynb
+++ b/examples/ReadISQ.ipynb
@@ -8,7 +8,7 @@
"source": [
"# Install notebook dependencies\n",
"import sys\n",
- "!{sys.executable} -m pip install itk-ioscanco tqdm requests itkwidgets"
+ "!{sys.executable} -m pip install itk-ioscanco tqdm pooch 'itkwidgets[all]>=1.0a21'"
]
},
{
@@ -17,9 +17,7 @@
"metadata": {},
"outputs": [],
"source": [
- "import requests\n",
- "from tqdm.notebook import tqdm\n",
- "import os\n",
+ "import pooch\n",
"\n",
"from itkwidgets import view\n",
"\n",
@@ -32,22 +30,10 @@
"metadata": {},
"outputs": [],
"source": [
- "# Download example data\n",
- "def download_data(url, filename):\n",
- " if not os.path.exists(filename):\n",
- " chunk_size = 32 * 1024\n",
- " r = requests.get(url, stream=True)\n",
- " total_size = int(r.headers.get('content-length', 0))\n",
- " pbar = tqdm(unit=\"B\", unit_scale=True, total=int(total_size))\n",
- " with open(filename, 'wb') as f:\n",
- " for chunk in r.iter_content(chunk_size=chunk_size): \n",
- " if chunk: # filter out keep-alive new chunks\n",
- " pbar.update(len(chunk))\n",
- " f.write(chunk)\n",
- " \n",
"file_name = 'C0004255.ISQ'\n",
"file_url = 'https://data.kitware.com/api/v1/file/591e56178d777f16d01e0d20/download'\n",
- "download_data(file_url, file_name)"
+ "file_sha256 = 'c2a3750c75826cb077d92093d43976cc0350198b55edecd681265eebabfb438b'\n",
+ "file_path = pooch.retrieve(file_url, file_sha256, fname=file_name, progressbar=True)"
]
},
{
@@ -56,8 +42,7 @@
"metadata": {},
"outputs": [],
"source": [
- "imageio = itk.ScancoImageIO.New()\n",
- "image = itk.imread(file_name, imageio=imageio)"
+ "image = itk.imread(file_path)"
]
},
{
@@ -67,17 +52,58 @@
"outputs": [
{
"data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "1dc71affddad4730ba2778e62534c472",
- "version_major": 2,
- "version_minor": 0
- },
+ "text/html": [
+ "\n",
+ " \n",
+ " \n",
+ " "
+ ],
"text/plain": [
- "Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image="
]
},
"metadata": {},
"output_type": "display_data"
+ },
+ {
+ "data": {
+ "application/javascript": [
+ "window.connectPlugin && window.connectPlugin(\"268f936d-91fb-48a4-af3f-e27de70d428f\")"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
@@ -87,7 +113,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -101,9 +127,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.0"
+ "version": "3.10.8"
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}