Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getters improvements #702

Merged
merged 16 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/notebook-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:

- name: Test notebooks
run: |
pytest --nbmake --nbmake-timeout=3000 examples/*.ipynb examples/integrations/**/*.ipynb
pytest --nbmake --nbmake-timeout=3000 examples/EnvironmentCheck.ipynb examples/Hello3DWorld.ipynb examples/NumPyArrayPointSet.ipynb examples/integrations/**/*.ipynb
364 changes: 265 additions & 99 deletions examples/GettersAndSetters.ipynb

Large diffs are not rendered by default.

25 changes: 7 additions & 18 deletions examples/Hello3DWorld.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,31 +119,20 @@
},
{
"cell_type": "code",
"execution_count": 5,
"id": "79deafd4-a8bf-4332-bda1-6dacf37e1ec9",
"metadata": {},
"execution_count": null,
"id": "842e3626-658f-4a00-b4c9-59e3c79c77ba",
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": [
"annotations = viewer.get_annotations_enabled()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "2f677bbb-91b1-4bf1-b4bf-1911ad1df326",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": null,
"id": "6b15413a-9bc1-42af-8fb0-7b583b0dc792",
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": [
"annotations"
]
Expand Down
4 changes: 2 additions & 2 deletions examples/NumPyArrayPointSet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"cell_type": "code",
"execution_count": 5,
"id": "83dfad1a-7199-4647-81da-57ce7cb1088e",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": [
"number_of_points_2 = 3000\n",
Expand All @@ -121,7 +121,7 @@
"cell_type": "code",
"execution_count": 6,
"id": "5eac65f8-e50f-4ba6-bd27-4386739ca805",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": [
"viewer.add_point_set(point_set_2)"
Expand Down
2 changes: 1 addition & 1 deletion examples/integrations/MONAI/transform_visualization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
"cell_type": "code",
"execution_count": null,
"id": "278dc2c6-9fcf-4d83-9894-4401e7348d34",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": []
}
Expand Down
8 changes: 4 additions & 4 deletions examples/integrations/PyImageJ/ImageJImgLib2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"cell_type": "code",
"execution_count": null,
"id": "48b151f6-cfc4-4522-aa02-04c8301d3667",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": [
"print(type(image))\n",
Expand All @@ -108,7 +108,7 @@
"cell_type": "code",
"execution_count": null,
"id": "b4db443d-f430-484b-a738-11b493944d8e",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": [
"# Invoke the Frangi vesselness op.\n",
Expand All @@ -123,7 +123,7 @@
"cell_type": "code",
"execution_count": null,
"id": "1afc55a1-35d3-475d-83fa-9ec04fb6fa28",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": [
"view(vessels)"
Expand All @@ -133,7 +133,7 @@
"cell_type": "code",
"execution_count": null,
"id": "cbc436a7-5928-4017-b5d4-07f3ca21f3a0",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": []
}
Expand Down
18 changes: 15 additions & 3 deletions examples/integrations/dask/DaskArray.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@
"cell_type": "code",
"execution_count": 5,
"id": "d1792a9c-5120-4627-b7cb-ddf98f0451dd",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -284,7 +288,11 @@
"cell_type": "code",
"execution_count": 6,
"id": "b37a638b-3c96-41fc-bc75-67ce22cfdcf4",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -350,7 +358,11 @@
"cell_type": "code",
"execution_count": null,
"id": "6f20fc74-bd0d-4355-9f61-fe892a8a54cf",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": []
}
Expand Down
14 changes: 4 additions & 10 deletions examples/integrations/itk/IDC_Seg_Primer_Examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,7 @@
"cell_type": "code",
"execution_count": 9,
"id": "de4dfee3-1f5e-41d4-a599-02d1d9cbdf0e",
"metadata": {
"tags": []
},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": [
"segthor_viewer.set_image_color_range([-1260, 2385])\n",
Expand Down Expand Up @@ -321,9 +319,7 @@
"cell_type": "code",
"execution_count": 10,
"id": "03988ee1-90eb-4e75-99af-2c56d932fad9",
"metadata": {
"tags": []
},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": [
"head_image_file = pooch.retrieve('https://data.kitware.com/api/v1/file/61b61cd74acac99f42a7ec84/download',\n",
Expand All @@ -336,9 +332,7 @@
"cell_type": "code",
"execution_count": 11,
"id": "091d4d0e-fdc5-4034-b6a5-a4d7350b98d5",
"metadata": {
"tags": []
},
"metadata": { "tags": ["skip-execution"] },
"outputs": [
{
"data": {
Expand Down Expand Up @@ -394,7 +388,7 @@
"cell_type": "code",
"execution_count": null,
"id": "0f4633af-fd01-4ab5-8202-3fb642276040",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": []
}
Expand Down
8 changes: 4 additions & 4 deletions examples/integrations/itk/MulticomponentNumPy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [
{
"name": "stdout",
Expand All @@ -174,7 +174,7 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [
{
"name": "stdout",
Expand All @@ -194,7 +194,7 @@
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [
{
"data": {
Expand Down Expand Up @@ -259,7 +259,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": []
}
Expand Down
798 changes: 401 additions & 397 deletions examples/integrations/itk/ThinPlateSpline.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/integrations/itkwasm/3DImage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [
{
"data": {
Expand Down
6 changes: 3 additions & 3 deletions examples/integrations/xarray/DataArray.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@
"cell_type": "code",
"execution_count": 5,
"id": "a8e4938c-e769-4f8e-97de-42dbb39caa1e",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [
{
"data": {
Expand Down Expand Up @@ -1109,7 +1109,7 @@
"cell_type": "code",
"execution_count": 6,
"id": "7b584e3a-6630-4f74-9f89-a95ba1b3af79",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [
{
"data": {
Expand Down Expand Up @@ -1189,7 +1189,7 @@
"cell_type": "code",
"execution_count": null,
"id": "40201a35-4dc6-40de-8af4-c227d7afa9dd",
"metadata": {},
"metadata": { "tags": ["skip-execution"] },
"outputs": [],
"source": []
}
Expand Down
14 changes: 11 additions & 3 deletions itkwidgets/_initialization_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from itkwidgets.viewer_config import MUI_HREF, PYDATA_SPHINX_HREF


INPUT_OPTIONS = ["image", "label_image", "point_set", "data"]

DATA_OPTIONS = ["image", "label_image", "point_set", "data", "fixed_image"]
INPUT_OPTIONS = [*DATA_OPTIONS, "compare"]

def init_params_dict(itk_viewer):
return {
Expand Down Expand Up @@ -75,7 +75,7 @@ def parse_input_data(init_data_kwargs):

def build_init_data(input_data):
result= None
for input_type in INPUT_OPTIONS:
for input_type in DATA_OPTIONS:
data = input_data.pop(input_type, None)
if data is None:
continue
Expand All @@ -84,6 +84,9 @@ def build_init_data(input_data):
if input_type == 'label_image':
result = _get_viewer_image(data, label=True)
render_type = RenderType.LABELIMAGE
elif input_type == 'fixed_image':
result = _get_viewer_image(data)
render_type = RenderType.FIXEDIMAGE
else:
result = _get_viewer_image(data, label=False)
elif render_type is RenderType.POINT_SET:
Expand All @@ -92,3 +95,8 @@ def build_init_data(input_data):
raise RuntimeError(f"Could not process the viewer {input_type}")
input_data[render_type.value] = result
return input_data


def defer_for_data_render(init_data):
deferred_keys = ['image', 'labelImage', 'fixedImage']
return any([k in init_data.keys() for k in deferred_keys])
47 changes: 0 additions & 47 deletions itkwidgets/_method_types.py

This file was deleted.

Loading