ndbioimage


Namendbioimage JSON
Version 2024.4.8 PyPI version JSON
download
home_pagehttps://github.com/wimpomp/ndbioimage
SummaryBio image reading, metadata and some affine registration.
upload_time2024-04-29 11:20:43
maintainerNone
docs_urlNone
authorW. Pomp
requires_python<4.0,>=3.10
licenseGPLv3
keywords bioformats imread numpy metadata
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Pytest](https://github.com/wimpomp/ndbioimage/actions/workflows/pytest.yml/badge.svg)](https://github.com/wimpomp/ndbioimage/actions/workflows/pytest.yml)

# ndbioimage - Work in progress

Exposes (bio) images as a numpy ndarray-like object, but without loading the whole
image into memory, reading from the file only when needed. Some metadata is read
and stored in an [ome](https://genomebiology.biomedcentral.com/articles/10.1186/gb-2005-6-5-r47) structure.
Additionally, it can automatically calculate an affine transform that corrects for chromatic aberrations etc. and apply
it on the fly to the image.

Currently, it supports imagej tif files, czi files, micromanager tif sequences and anything
[bioformats](https://www.openmicroscopy.org/bio-formats/) can handle. 

## Installation

```
pip install ndbioimage
```

## Usage

- Reading an image file and plotting the frame at channel=2, time=1

```
import matplotlib.pyplot as plt
from ndbioimage import Imread
with Imread('image_file.tif', axes='ctyx', dtype=int) as im:
    plt.imshow(im[2, 1])
```        
        
- Showing some image metadata

```
from ndbioimage import Imread
from pprint import pprint
with Imread('image_file.tif') as im:
    pprint(im)
```

- Slicing the image without loading the image into memory

```
from ndbioimage import Imread
with Imread('image_file.tif', axes='cztyx') as im:
    sliced_im = im[1, :, :, 100:200, 100:200]
```

sliced_im is an instance of Imread which will load any image data from file only when needed


- Converting (part) of the image to a numpy ndarray

```
from ndbioimage import Imread
import numpy as np
with Imread('image_file.tif', axes='cztyx') as im:
    array = np.asarray(im[0, 0])
```

## Adding more formats
Readers for image formats subclass AbstractReader. When an image reader is imported, Imread will
automatically recognize it and use it to open the appropriate file format. Image readers
are required to implement the following methods:

- staticmethod _can_open(path): return True if path can be opened by this reader
- \_\_frame__(self, c, z, t): return the frame at channel=c, z-slice=z, time=t from the file

Optional methods:
- get_ome: reads metadata from file and adds them to an OME object imported
from the ome-types library 
- open(self): maybe open some file handle
- close(self): close any file handles

Optional fields:
- priority (int): Imread will try readers with a lower number first, default: 99
- do_not_pickle (strings): any attributes that should not be included when the object is pickled,
for example: any file handles

# TODO
- more image formats


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/wimpomp/ndbioimage",
    "name": "ndbioimage",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "bioformats, imread, numpy, metadata",
    "author": "W. Pomp",
    "author_email": "w.pomp@nki.nl",
    "download_url": "https://files.pythonhosted.org/packages/ae/66/cfa8e06e7f713b4459b30939158ad5ec487b8f5d21074e369f6d88ae0231/ndbioimage-2024.4.8.tar.gz",
    "platform": null,
    "description": "[![Pytest](https://github.com/wimpomp/ndbioimage/actions/workflows/pytest.yml/badge.svg)](https://github.com/wimpomp/ndbioimage/actions/workflows/pytest.yml)\n\n# ndbioimage - Work in progress\n\nExposes (bio) images as a numpy ndarray-like object, but without loading the whole\nimage into memory, reading from the file only when needed. Some metadata is read\nand stored in an [ome](https://genomebiology.biomedcentral.com/articles/10.1186/gb-2005-6-5-r47) structure.\nAdditionally, it can automatically calculate an affine transform that corrects for chromatic aberrations etc. and apply\nit on the fly to the image.\n\nCurrently, it supports imagej tif files, czi files, micromanager tif sequences and anything\n[bioformats](https://www.openmicroscopy.org/bio-formats/) can handle. \n\n## Installation\n\n```\npip install ndbioimage\n```\n\n## Usage\n\n- Reading an image file and plotting the frame at channel=2, time=1\n\n```\nimport matplotlib.pyplot as plt\nfrom ndbioimage import Imread\nwith Imread('image_file.tif', axes='ctyx', dtype=int) as im:\n    plt.imshow(im[2, 1])\n```        \n        \n- Showing some image metadata\n\n```\nfrom ndbioimage import Imread\nfrom pprint import pprint\nwith Imread('image_file.tif') as im:\n    pprint(im)\n```\n\n- Slicing the image without loading the image into memory\n\n```\nfrom ndbioimage import Imread\nwith Imread('image_file.tif', axes='cztyx') as im:\n    sliced_im = im[1, :, :, 100:200, 100:200]\n```\n\nsliced_im is an instance of Imread which will load any image data from file only when needed\n\n\n- Converting (part) of the image to a numpy ndarray\n\n```\nfrom ndbioimage import Imread\nimport numpy as np\nwith Imread('image_file.tif', axes='cztyx') as im:\n    array = np.asarray(im[0, 0])\n```\n\n## Adding more formats\nReaders for image formats subclass AbstractReader. When an image reader is imported, Imread will\nautomatically recognize it and use it to open the appropriate file format. Image readers\nare required to implement the following methods:\n\n- staticmethod _can_open(path): return True if path can be opened by this reader\n- \\_\\_frame__(self, c, z, t): return the frame at channel=c, z-slice=z, time=t from the file\n\nOptional methods:\n- get_ome: reads metadata from file and adds them to an OME object imported\nfrom the ome-types library \n- open(self): maybe open some file handle\n- close(self): close any file handles\n\nOptional fields:\n- priority (int): Imread will try readers with a lower number first, default: 99\n- do_not_pickle (strings): any attributes that should not be included when the object is pickled,\nfor example: any file handles\n\n# TODO\n- more image formats\n\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "Bio image reading, metadata and some affine registration.",
    "version": "2024.4.8",
    "project_urls": {
        "Homepage": "https://github.com/wimpomp/ndbioimage",
        "Repository": "https://github.com/wimpomp/ndbioimage"
    },
    "split_keywords": [
        "bioformats",
        " imread",
        " numpy",
        " metadata"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e050efccc39d964fdb69091566b0e1ed0b74793372ebaab5eeecad75dd389905",
                "md5": "a27d900772ccdc267b1781e3fae45e95",
                "sha256": "39e931edaf61c6dbcfabf5e3054ae3fbcb8f2b759cdca4d17564aa4609b73bff"
            },
            "downloads": -1,
            "filename": "ndbioimage-2024.4.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a27d900772ccdc267b1781e3fae45e95",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 49291,
            "upload_time": "2024-04-29T11:20:40",
            "upload_time_iso_8601": "2024-04-29T11:20:40.899805Z",
            "url": "https://files.pythonhosted.org/packages/e0/50/efccc39d964fdb69091566b0e1ed0b74793372ebaab5eeecad75dd389905/ndbioimage-2024.4.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ae66cfa8e06e7f713b4459b30939158ad5ec487b8f5d21074e369f6d88ae0231",
                "md5": "e2123fe33b30ba343ec691c738c478a9",
                "sha256": "1bd2411a5a96cef150f1b660a689028b7e828bc62fe6d4dc2d3ae6d33c728c62"
            },
            "downloads": -1,
            "filename": "ndbioimage-2024.4.8.tar.gz",
            "has_sig": false,
            "md5_digest": "e2123fe33b30ba343ec691c738c478a9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 45196,
            "upload_time": "2024-04-29T11:20:43",
            "upload_time_iso_8601": "2024-04-29T11:20:43.625688Z",
            "url": "https://files.pythonhosted.org/packages/ae/66/cfa8e06e7f713b4459b30939158ad5ec487b8f5d21074e369f6d88ae0231/ndbioimage-2024.4.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-29 11:20:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wimpomp",
    "github_project": "ndbioimage",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ndbioimage"
}
        
Elapsed time: 0.29551s