aicscytoparam


Nameaicscytoparam JSON
Version 0.1.12 PyPI version JSON
download
home_pagehttps://github.com/AllenCell/aics-cytoparam
SummaryCytoplasm parameterization using spherical harmonics
upload_time2024-04-06 18:52:07
maintainerNone
docs_urlNone
authorMatheus Viana
requires_python>=3.8
licenseAllen Institute Software License
keywords aicscytoparam
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 3D Cell Parameterization

[![Build Status](https://github.com/AllenCell/aics-cytoparam/workflows/Build%20Main/badge.svg)](https://github.com/AllenCell/aics-cytoparam/actions)
[![Documentation](https://github.com/AllenCell/aics-cytoparam/workflows/Documentation/badge.svg)](https://AllenCell.github.io/aics-cytoparam/)
[![Code Coverage](https://codecov.io/gh/AllenCell/aics-cytoparam/branch/main/graph/badge.svg)](https://codecov.io/gh/AllenCell/aics-cytoparam)

### Spherical harmonics coefficients-based parameterization of the cytoplasm and nucleoplasm for 3D cells

![Cuboid cell](docs/logo.jpg)

---
## Installation

**Stable Release:** `pip install aicscytoparam`<br>
**Development Head:** `pip install git+https://github.com/AllenCell/aics-cytoparam.git`

## How to use

Here we outline an example of how to use `aicscytoparam` to create a parameterization of a 3D cell. In this case, the 3D cells will be represented by a cell segementation, nuclear segmentation and a fluorescent protein (FP) image representing the fluorescent signal of a tagged protein.

```python
# Import required packages
import numpy as np
import matplotlib.pyplot as plt
from aicscytoparam import cytoparam
from skimage import morphology as skmorpho
```

```python
# First create a cuboid cell with an off-center cuboid nucleus
# and get the spherical harmonics coefficients of this cell and nucleus:
w = 100
mem = np.zeros((w, w, w), dtype = np.uint8)
mem[20:80, 20:80, 20:80] = 1
nuc = np.zeros((w, w, w), dtype = np.uint8)
nuc[40:60, 40:60, 30:50] = 1

# Create an FP signal located in the top half of the cell and outside the
# nucleus:
gfp = np.random.rand(w**3).reshape(w,w,w)
gfp[mem==0] = 0
gfp[:, w//2:] = 0
gfp[nuc>0] = 0

# Vizualize a center xy cross-section of our cell:
plt.imshow((mem + nuc)[w//2], cmap='gray')
plt.imshow(gfp[w // 2], cmap='gray', alpha=0.25)
plt.axis('off')
```

![Cuboid cell](docs/im1.jpg)

```python
# Use aicsshparam to expand both cell and nuclear shapes in terms of spherical
# harmonics:
coords, coeffs_centroid = cytoparam.parameterize_image_coordinates(
    seg_mem=mem,
    seg_nuc=nuc,
    lmax=16, # Degree of the spherical harmonics expansion
    nisos=[32, 32] # Number of interpolation layers
)
coeffs_mem, centroid_mem, coeffs_nuc, centroid_nuc = coeffs_centroid

# Run the cellular mapping to create a parameterized intensity representation
# for the FP image:
gfp_representation = cytoparam.cellular_mapping(
    coeffs_mem=coeffs_mem,
    centroid_mem=centroid_mem,
    coeffs_nuc=coeffs_nuc,
    centroid_nuc=centroid_nuc,
    nisos=[32, 32],
    images_to_probe=[('gfp', gfp)]
).data.squeeze()

# The FP image is now encoded into a representation of its shape:
print(gfp_representation.shape)
```

`(65, 8194)`

```python
# Now we want to morph the FP image into a round cell.
# First we create the round cell:

from skimage import morphology as skmorpho
mem_round = skmorpho.ball(w // 3) # radius of our round cell
nuc_round = skmorpho.ball( w// 3) # radius of our round nucleus
# Erode the nucleus so it becomes smaller than the cell
nuc_round = skmorpho.binary_erosion(
    nuc_round, selem=np.ones((20, 20, 20))
    ).astype(np.uint8)

# Vizualize a center xy cross-section of our round cell:
plt.imshow((mem_round + nuc_round)[w // 3], cmap='gray')
plt.axis('off')
```

![Cuboid cell](docs/im2.jpg)

```python
# Next we need to parameterize the coordinates of our round
# cell:
coords_round, _ = cytoparam.parameterize_image_coordinates(
    seg_mem=mem_round,
    seg_nuc=nuc_round,
    lmax=16,
    nisos=[32, 32]
)

# Now we are ready to morph the FP image into our round cell:
gfp_morphed = cytoparam.morph_representation_on_shape(
    img=mem_round + nuc_round,
    param_img_coords=coords_round,
    representation=gfp_representation
)
# Visualize the morphed FP image:
plt.imshow((mem_round + nuc_round)[w // 3], cmap='gray')
plt.imshow(gfp_morphed[w // 3], cmap='gray', alpha=0.25)
plt.axis('off')
```

![Cuboid cell](docs/im3.jpg)

## Reference

For an example of how this package was used to analyse a dataset of over 200k single-cell images at the Allen Institute for Cell Science, please check out our paper in [bioaRxiv](https://www.biorxiv.org/content/10.1101/2020.12.08.415562v1).

## Development

See [CONTRIBUTING.md](CONTRIBUTING.md) for information related to developing the code.

## Questions?

If you have any questions, feel free to leave a comment in our Allen Cell forum: [https://forum.allencell.org/](https://forum.allencell.org/). 


***Free software: Allen Institute Software License***



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AllenCell/aics-cytoparam",
    "name": "aicscytoparam",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "aicscytoparam",
    "author": "Matheus Viana",
    "author_email": "matheus.viana@alleninstitute.org",
    "download_url": "https://files.pythonhosted.org/packages/c2/62/a18650d39ef24106e00d776f65d17760123ef716a10df565419213d3259e/aicscytoparam-0.1.12.tar.gz",
    "platform": null,
    "description": "# 3D Cell Parameterization\n\n[![Build Status](https://github.com/AllenCell/aics-cytoparam/workflows/Build%20Main/badge.svg)](https://github.com/AllenCell/aics-cytoparam/actions)\n[![Documentation](https://github.com/AllenCell/aics-cytoparam/workflows/Documentation/badge.svg)](https://AllenCell.github.io/aics-cytoparam/)\n[![Code Coverage](https://codecov.io/gh/AllenCell/aics-cytoparam/branch/main/graph/badge.svg)](https://codecov.io/gh/AllenCell/aics-cytoparam)\n\n### Spherical harmonics coefficients-based parameterization of the cytoplasm and nucleoplasm for 3D cells\n\n![Cuboid cell](docs/logo.jpg)\n\n---\n## Installation\n\n**Stable Release:** `pip install aicscytoparam`<br>\n**Development Head:** `pip install git+https://github.com/AllenCell/aics-cytoparam.git`\n\n## How to use\n\nHere we outline an example of how to use `aicscytoparam` to create a parameterization of a 3D cell. In this case, the 3D cells will be represented by a cell segementation, nuclear segmentation and a fluorescent protein (FP) image representing the fluorescent signal of a tagged protein.\n\n```python\n# Import required packages\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom aicscytoparam import cytoparam\nfrom skimage import morphology as skmorpho\n```\n\n```python\n# First create a cuboid cell with an off-center cuboid nucleus\n# and get the spherical harmonics coefficients of this cell and nucleus:\nw = 100\nmem = np.zeros((w, w, w), dtype = np.uint8)\nmem[20:80, 20:80, 20:80] = 1\nnuc = np.zeros((w, w, w), dtype = np.uint8)\nnuc[40:60, 40:60, 30:50] = 1\n\n# Create an FP signal located in the top half of the cell and outside the\n# nucleus:\ngfp = np.random.rand(w**3).reshape(w,w,w)\ngfp[mem==0] = 0\ngfp[:, w//2:] = 0\ngfp[nuc>0] = 0\n\n# Vizualize a center xy cross-section of our cell:\nplt.imshow((mem + nuc)[w//2], cmap='gray')\nplt.imshow(gfp[w // 2], cmap='gray', alpha=0.25)\nplt.axis('off')\n```\n\n![Cuboid cell](docs/im1.jpg)\n\n```python\n# Use aicsshparam to expand both cell and nuclear shapes in terms of spherical\n# harmonics:\ncoords, coeffs_centroid = cytoparam.parameterize_image_coordinates(\n    seg_mem=mem,\n    seg_nuc=nuc,\n    lmax=16, # Degree of the spherical harmonics expansion\n    nisos=[32, 32] # Number of interpolation layers\n)\ncoeffs_mem, centroid_mem, coeffs_nuc, centroid_nuc = coeffs_centroid\n\n# Run the cellular mapping to create a parameterized intensity representation\n# for the FP image:\ngfp_representation = cytoparam.cellular_mapping(\n    coeffs_mem=coeffs_mem,\n    centroid_mem=centroid_mem,\n    coeffs_nuc=coeffs_nuc,\n    centroid_nuc=centroid_nuc,\n    nisos=[32, 32],\n    images_to_probe=[('gfp', gfp)]\n).data.squeeze()\n\n# The FP image is now encoded into a representation of its shape:\nprint(gfp_representation.shape)\n```\n\n`(65, 8194)`\n\n```python\n# Now we want to morph the FP image into a round cell.\n# First we create the round cell:\n\nfrom skimage import morphology as skmorpho\nmem_round = skmorpho.ball(w // 3) # radius of our round cell\nnuc_round = skmorpho.ball( w// 3) # radius of our round nucleus\n# Erode the nucleus so it becomes smaller than the cell\nnuc_round = skmorpho.binary_erosion(\n    nuc_round, selem=np.ones((20, 20, 20))\n    ).astype(np.uint8)\n\n# Vizualize a center xy cross-section of our round cell:\nplt.imshow((mem_round + nuc_round)[w // 3], cmap='gray')\nplt.axis('off')\n```\n\n![Cuboid cell](docs/im2.jpg)\n\n```python\n# Next we need to parameterize the coordinates of our round\n# cell:\ncoords_round, _ = cytoparam.parameterize_image_coordinates(\n    seg_mem=mem_round,\n    seg_nuc=nuc_round,\n    lmax=16,\n    nisos=[32, 32]\n)\n\n# Now we are ready to morph the FP image into our round cell:\ngfp_morphed = cytoparam.morph_representation_on_shape(\n    img=mem_round + nuc_round,\n    param_img_coords=coords_round,\n    representation=gfp_representation\n)\n# Visualize the morphed FP image:\nplt.imshow((mem_round + nuc_round)[w // 3], cmap='gray')\nplt.imshow(gfp_morphed[w // 3], cmap='gray', alpha=0.25)\nplt.axis('off')\n```\n\n![Cuboid cell](docs/im3.jpg)\n\n## Reference\n\nFor an example of how this package was used to analyse a dataset of over 200k single-cell images at the Allen Institute for Cell Science, please check out our paper in [bioaRxiv](https://www.biorxiv.org/content/10.1101/2020.12.08.415562v1).\n\n## Development\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for information related to developing the code.\n\n## Questions?\n\nIf you have any questions, feel free to leave a comment in our Allen Cell forum: [https://forum.allencell.org/](https://forum.allencell.org/). \n\n\n***Free software: Allen Institute Software License***\n\n\n",
    "bugtrack_url": null,
    "license": "Allen Institute Software License",
    "summary": "Cytoplasm parameterization using spherical harmonics",
    "version": "0.1.12",
    "project_urls": {
        "Homepage": "https://github.com/AllenCell/aics-cytoparam"
    },
    "split_keywords": [
        "aicscytoparam"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9f000e5180689512deb3c6f737e1a6308dabcf03e7a49910c4d531710dc2454d",
                "md5": "e6fc18dfafced59579cfe310395a0f2e",
                "sha256": "a621d95e9febbb02448309fb7b33803aa98386586703a1ed41623a4cb0d36279"
            },
            "downloads": -1,
            "filename": "aicscytoparam-0.1.12-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e6fc18dfafced59579cfe310395a0f2e",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 15352,
            "upload_time": "2024-04-06T18:52:05",
            "upload_time_iso_8601": "2024-04-06T18:52:05.626160Z",
            "url": "https://files.pythonhosted.org/packages/9f/00/0e5180689512deb3c6f737e1a6308dabcf03e7a49910c4d531710dc2454d/aicscytoparam-0.1.12-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c262a18650d39ef24106e00d776f65d17760123ef716a10df565419213d3259e",
                "md5": "96deb77aba1f86465c839f5b2e5ed3b8",
                "sha256": "13f3e622b24860ab47b0d2546e845d1fd56b66088e0edb38ed7f661f6017ad7a"
            },
            "downloads": -1,
            "filename": "aicscytoparam-0.1.12.tar.gz",
            "has_sig": false,
            "md5_digest": "96deb77aba1f86465c839f5b2e5ed3b8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 148226,
            "upload_time": "2024-04-06T18:52:07",
            "upload_time_iso_8601": "2024-04-06T18:52:07.522815Z",
            "url": "https://files.pythonhosted.org/packages/c2/62/a18650d39ef24106e00d776f65d17760123ef716a10df565419213d3259e/aicscytoparam-0.1.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-06 18:52:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AllenCell",
    "github_project": "aics-cytoparam",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "aicscytoparam"
}
        
Elapsed time: 0.21259s