Skip to content

Commit

Permalink
feat(itkwasm-image-io): initial addition
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Nov 4, 2023
1 parent 1b0a814 commit 815d901
Show file tree
Hide file tree
Showing 102 changed files with 3,418 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from pathlib import Path

from itkwasm import PixelTypes, IntTypes

from itkwasm_image_io_wasi import read_image, imread, write_image, imwrite
Expand Down
11 changes: 11 additions & 0 deletions packages/image-io/python/itkwasm-image-io/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# itkwasm-image-io

[![PyPI version](https://badge.fury.io/py/itkwasm-image-io.svg)](https://badge.fury.io/py/itkwasm-image-io)

Input and output for scientific and medical image file formats.

## Installation

```sh
pip install itkwasm-image-io
```
20 changes: 20 additions & 0 deletions packages/image-io/python/itkwasm-image-io/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions packages/image-io/python/itkwasm-image-io/docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

from datetime import date

project = 'itkwasm-image-io'
copyright = f'{date.today().year}, NumFOCUS'
author = 'Insight Software Consortium'

extensions = [
'sphinx.ext.autosummary',
'autodoc2',
'myst_parser',
'sphinx.ext.intersphinx',
'sphinx_copybutton',
'sphinxext.opengraph',
'sphinx_design',
]

myst_enable_extensions = ["colon_fence", "fieldlist"]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

autodoc2_packages = [
{
"path": "../itkwasm_image_io",
"exclude_files": ["_version.py"],
},
]
autodoc2_render_plugin = "myst"

intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"numpy": ("https://numpy.org/doc/stable", None),
"itkwasm": ("https://itkwasm.readthedocs.io/en/latest/", None),
}

html_theme = 'furo'
html_static_path = ['_static']
html_logo = "_static/logo.svg"
html_favicon = "_static/favicon.png"
html_title = f"{project}"

# Furo options
html_theme_options = {
"top_of_page_button": "edit",
"source_repository": "https://github.com/InsightSoftwareConsortium/itk-wasm",
"source_branch": "main",
"source_directory": "docs",
}
35 changes: 35 additions & 0 deletions packages/image-io/python/itkwasm-image-io/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
itkwasm-image-io
=======

> Input and output for scientific and medical image file formats.
[![itkwasm-image-io version](https://badge.fury.io/py/itkwasm_image_io.svg)](https://pypi.org/project/itkwasm_image_io/)

## Installation

::::{tab-set}

:::{tab-item} System
```shell
pip install itkwasm-image-io
```
:::

:::{tab-item} Browser
In Pyodide, e.g. the [Pyodide REPL](https://pyodide.org/en/stable/console.html) or [JupyterLite](https://jupyterlite.readthedocs.io/en/latest/try/lab),

```python
import micropip
await micropip.install('itkwasm-image-io')
:::

::::

```{toctree}
:hidden:
:maxdepth: 3
:caption: 📖 Reference

apidocs/index.rst
itkwasm docs <https://itkwasm.readthedocs.io/>
```
35 changes: 35 additions & 0 deletions packages/image-io/python/itkwasm-image-io/docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
astroid<3
sphinx
furo
sphinx-autodoc2
myst-parser
sphinx-copybutton
sphinxext-opengraph
sphinx-design
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
"""itkwasm-image-io: Input and output for scientific and medical image file formats."""

from .read_image import read_image, imread
from .write_image import write_image, imwrite

from .bio_rad_read_image_async import bio_rad_read_image_async
from .bio_rad_read_image import bio_rad_read_image
from .bio_rad_write_image_async import bio_rad_write_image_async
from .bio_rad_write_image import bio_rad_write_image
from .bmp_read_image_async import bmp_read_image_async
from .bmp_read_image import bmp_read_image
from .bmp_write_image_async import bmp_write_image_async
from .bmp_write_image import bmp_write_image
from .fdf_read_image_async import fdf_read_image_async
from .fdf_read_image import fdf_read_image
from .fdf_write_image_async import fdf_write_image_async
from .fdf_write_image import fdf_write_image
from .gdcm_read_image_async import gdcm_read_image_async
from .gdcm_read_image import gdcm_read_image
from .gdcm_write_image_async import gdcm_write_image_async
from .gdcm_write_image import gdcm_write_image
from .ge_adw_read_image_async import ge_adw_read_image_async
from .ge_adw_read_image import ge_adw_read_image
from .ge_adw_write_image_async import ge_adw_write_image_async
from .ge_adw_write_image import ge_adw_write_image
from .ge4_read_image_async import ge4_read_image_async
from .ge4_read_image import ge4_read_image
from .ge4_write_image_async import ge4_write_image_async
from .ge4_write_image import ge4_write_image
from .ge5_read_image_async import ge5_read_image_async
from .ge5_read_image import ge5_read_image
from .ge5_write_image_async import ge5_write_image_async
from .ge5_write_image import ge5_write_image
from .gipl_read_image_async import gipl_read_image_async
from .gipl_read_image import gipl_read_image
from .gipl_write_image_async import gipl_write_image_async
from .gipl_write_image import gipl_write_image
from .jpeg_read_image_async import jpeg_read_image_async
from .jpeg_read_image import jpeg_read_image
from .jpeg_write_image_async import jpeg_write_image_async
from .jpeg_write_image import jpeg_write_image
from .lsm_read_image_async import lsm_read_image_async
from .lsm_read_image import lsm_read_image
from .lsm_write_image_async import lsm_write_image_async
from .lsm_write_image import lsm_write_image
from .meta_read_image_async import meta_read_image_async
from .meta_read_image import meta_read_image
from .meta_write_image_async import meta_write_image_async
from .meta_write_image import meta_write_image
from .mgh_read_image_async import mgh_read_image_async
from .mgh_read_image import mgh_read_image
from .mgh_write_image_async import mgh_write_image_async
from .mgh_write_image import mgh_write_image
from .mrc_read_image_async import mrc_read_image_async
from .mrc_read_image import mrc_read_image
from .mrc_write_image_async import mrc_write_image_async
from .mrc_write_image import mrc_write_image
from .nifti_read_image_async import nifti_read_image_async
from .nifti_read_image import nifti_read_image
from .nifti_write_image_async import nifti_write_image_async
from .nifti_write_image import nifti_write_image
from .nrrd_read_image_async import nrrd_read_image_async
from .nrrd_read_image import nrrd_read_image
from .nrrd_write_image_async import nrrd_write_image_async
from .nrrd_write_image import nrrd_write_image
from .png_read_image_async import png_read_image_async
from .png_read_image import png_read_image
from .png_write_image_async import png_write_image_async
from .png_write_image import png_write_image
from .scanco_read_image_async import scanco_read_image_async
from .scanco_read_image import scanco_read_image
from .scanco_write_image_async import scanco_write_image_async
from .scanco_write_image import scanco_write_image
from .tiff_read_image_async import tiff_read_image_async
from .tiff_read_image import tiff_read_image
from .tiff_write_image_async import tiff_write_image_async
from .tiff_write_image import tiff_write_image
from .vtk_read_image_async import vtk_read_image_async
from .vtk_read_image import vtk_read_image
from .vtk_write_image_async import vtk_write_image_async
from .vtk_write_image import vtk_write_image
from .wasm_read_image_async import wasm_read_image_async
from .wasm_read_image import wasm_read_image
from .wasm_write_image_async import wasm_write_image_async
from .wasm_write_image import wasm_write_image
from .wasm_zstd_read_image_async import wasm_zstd_read_image_async
from .wasm_zstd_read_image import wasm_zstd_read_image
from .wasm_zstd_write_image_async import wasm_zstd_write_image_async
from .wasm_zstd_write_image import wasm_zstd_write_image

from ._version import __version__
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.3.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated file. Do not edit.

import os
from typing import Dict, Tuple, Optional, List, Any

from itkwasm import (
environment_dispatch,
BinaryFile,
Image,
)

def bio_rad_read_image(
serialized_image: os.PathLike,
information_only: bool = False,
) -> Tuple[Any, Image]:
"""Read an image file format and convert it to the itk-wasm file format
:param serialized_image: Input image serialized in the file format
:type serialized_image: os.PathLike
:param information_only: Only read image metadata -- do not read pixel data.
:type information_only: bool
:return: Whether the input could be read. If false, the output image is not valid.
:rtype: Any
:return: Output image
:rtype: Image
"""
func = environment_dispatch("itkwasm_image_io", "bio_rad_read_image")
output = func(serialized_image, information_only=information_only)
return output
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated file. Do not edit.

import os
from typing import Dict, Tuple, Optional, List, Any

from itkwasm import (
environment_dispatch,
BinaryFile,
Image,
)

async def bio_rad_read_image_async(
serialized_image: os.PathLike,
information_only: bool = False,
) -> Tuple[Any, Image]:
"""Read an image file format and convert it to the itk-wasm file format
:param serialized_image: Input image serialized in the file format
:type serialized_image: os.PathLike
:param information_only: Only read image metadata -- do not read pixel data.
:type information_only: bool
:return: Whether the input could be read. If false, the output image is not valid.
:rtype: Any
:return: Output image
:rtype: Image
"""
func = environment_dispatch("itkwasm_image_io", "bio_rad_read_image_async")
output = await func(serialized_image, information_only=information_only)
return output
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated file. Do not edit.

import os
from typing import Dict, Tuple, Optional, List, Any

from itkwasm import (
environment_dispatch,
Image,
BinaryFile,
)

def bio_rad_write_image(
image: Image,
serialized_image: str,
information_only: bool = False,
use_compression: bool = False,
) -> Tuple[Any]:
"""Write an itk-wasm file format converted to an image file format
:param image: Input image
:type image: Image
:param serialized_image: Output image serialized in the file format.
:type serialized_image: str
:param information_only: Only write image metadata -- do not write pixel data.
:type information_only: bool
:param use_compression: Use compression in the written file
:type use_compression: bool
:return: Whether the input could be written. If false, the output image is not valid.
:rtype: Any
"""
func = environment_dispatch("itkwasm_image_io", "bio_rad_write_image")
output = func(image, serialized_image, information_only=information_only, use_compression=use_compression)
return output
Loading

0 comments on commit 815d901

Please sign in to comment.