Catalog PyPI
Back to packageRELEASE DETAILS

0.1.11

PyPI

aicsshparam

Spherical harmonics parametrization for 3D starlike shapes

aicsshparam
Published25 Feb 2025
Direct dependencies22
Transitive dependenciesNot calculated

README

Version 0.1.11 documentation

AICS Spherical Harmonics Parametrization

Build Status Documentation

Spherical harmonics parametrization for 3D starlike shapes.

Parameterization of cell and nuclear shape

Installation:

Build Dependencies for Python 3.13.*

If you are using Python 3.13.*, you will need to install the following build dependencies:

  • fftw
  • openblas
  • cmake
  • pkg-config

One convenient way to install these dependencies is by using Conda. You can run the following command:

conda install -c conda-forge fftw openblas cmake pkg-config

Stable Release: pip install aicsshparam

Build from source to make customization:

git clone git@github.com:AllenCell/aics-shparam.git
cd aics-shparam
pip install -e .

How to use

Here we outline an example of how one could use spherical harmonics coefficients as shape descriptors on a synthetic dataset composed by 3 different shapes: spheres, cubes and octahedrons.

# Import required packages
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
from aicsshparam import shtools, shparam
from skimage.morphology import ball, cube, octahedron
np.random.seed(42) # for reproducibility
# Function that returns binary images containing one of the three
# shapes: cubes, spheres octahedrons of random sizes.
def get_random_3d_shape():
    idx = np.random.choice([0, 1, 2], 1)[0]
    element = [ball, cube, octahedron][idx]
    label = ['ball', 'cube', 'octahedron'][idx]
    img = element(10 + int(10 * np.random.rand()))
    img = np.pad(img, ((1, 1), (1, 1), (1, 1)))
    img = img.reshape(1, *img.shape)
    # Rotate shapes to increase dataset variability.
    img = shtools.rotate_image_2d(
        image=img,
        angle=360 * np.random.rand()
    ).squeeze()
    return label, img

# Compute spherical harmonics coefficients of shape and store them
# in a pandas dataframe.
df_coeffs = []
for i in range(30):
    # Get a random shape
    label, img = get_random_3d_shape()
    # Parameterize with L=4, which corresponds to50 coefficients
    # in total
    (coeffs, _), _ = shparam.get_shcoeffs(image=img, lmax=4)
    coeffs.update({'label': label})
    df_coeffs.append(coeffs)
df_coeffs = pd.DataFrame(df_coeffs)

# Vizualize the resulting dataframe
with pd.option_context('display.max_rows', 5, 'display.max_columns', 5):
    display(df_coeffs)

Coefficients dataframe

# Let's use PCA to reduce the dimensionality of the coefficients
# dataframe from 51 down to 2.
pca = PCA(n_components=2)
trans = pca.fit_transform(df_coeffs.drop(columns=['label']))
df_trans = pd.DataFrame(trans)
df_trans.columns = ['PC1', 'PC2']
df_trans['label'] = df_coeffs.label

# Vizualize the resulting dataframe
with pd.option_context('display.max_rows', 5, 'display.max_columns', 5):
    display(df_trans)

PCA dataframe

# Scatter plot to show how similar shapes are grouped together.
fig, ax = plt.subplots(1,1, figsize=(3,3))
for label, df_label in df_trans.groupby('label'):
    ax.scatter(df_label.PC1, df_label.PC2, label=label, s=50)
plt.legend(loc='upper left', bbox_to_anchor=(1.05, 1))
plt.xlabel('PC1')
plt.ylabel('PC2')
plt.show()

PC1 vs. PC2

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.

Development

See 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/.

Free software: Allen Institute Software License

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 51

Native requirements
22 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
numpy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
numpyruntime
scipy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
scipyruntime
scikit-image
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
scikit-imageruntime
scikit-learn
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
scikit-learnruntime
vtk
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
vtkruntime
pyshtools
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pyshtoolsruntime
pytest-runner
Environment
{
  "extras": "",
  "marker": "extra == \"setup\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-runner>=5.2; extra == "setup"runtime
black
Environment
{
  "extras": "",
  "marker": "extra == \"test\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
black; extra == "test"runtime
flake8
Environment
{
  "extras": "",
  "marker": "extra == \"test\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
flake8; extra == "test"runtime
flake8-debugger
Environment
{
  "extras": "",
  "marker": "extra == \"test\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
flake8-debugger; extra == "test"runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"test\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest; extra == "test"runtime
pytest-cov
Environment
{
  "extras": "",
  "marker": "extra == \"test\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-cov; extra == "test"runtime
pytest-raises
Environment
{
  "extras": "",
  "marker": "extra == \"test\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-raises; extra == "test"runtime
pytest-runner
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-runner>=5.2; extra == "dev"runtime
black
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
black; extra == "dev"runtime
flake8
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
flake8; extra == "dev"runtime
flake8-debugger
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
flake8-debugger; extra == "dev"runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest; extra == "dev"runtime
pytest-cov
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-cov; extra == "dev"runtime
pytest-raises
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-raises; extra == "dev"runtime
bump2version
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
bump2version; extra == "dev"runtime
coverage
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
coverage; extra == "dev"runtime
ipython
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
ipython; extra == "dev"runtime
myst-parser
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
myst-parser; extra == "dev"runtime
sphinx
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
sphinx; extra == "dev"runtime
furo
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
furo; extra == "dev"runtime
tox
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
tox; extra == "dev"runtime
twine
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
twine; extra == "dev"runtime
wheel
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
wheel; extra == "dev"runtime
numpy
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
numpy; extra == "all"runtime
scipy
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
scipy; extra == "all"runtime
scikit-image
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
scikit-image; extra == "all"runtime
scikit-learn
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
scikit-learn; extra == "all"runtime
vtk
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
vtk; extra == "all"runtime
pyshtools
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pyshtools; extra == "all"runtime
pytest-runner
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-runner>=5.2; extra == "all"runtime
black
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
black; extra == "all"runtime
flake8
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
flake8; extra == "all"runtime
flake8-debugger
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
flake8-debugger; extra == "all"runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest; extra == "all"runtime
pytest-cov
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-cov; extra == "all"runtime
pytest-raises
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
pytest-raises; extra == "all"runtime
bump2version
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
bump2version; extra == "all"runtime
coverage
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
coverage; extra == "all"runtime
ipython
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
ipython; extra == "all"runtime
myst-parser
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
myst-parser; extra == "all"runtime
sphinx
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
sphinx; extra == "all"runtime
furo
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
furo; extra == "all"runtime
tox
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
tox; extra == "all"runtime
twine
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
twine; extra == "all"runtime
wheel
Environment
{
  "extras": "",
  "marker": "extra == \"all\"",
  "requires_python": ">=3.9",
  "evaluation": "NOT_EVALUATED"
}
wheel; extra == "all"runtime

Distribution files

2 collected
aicsshparam-0.1.11-py2.py3-none-any.whl

bdist_wheel · 653.53 KB · Python py2.py3

Source file
aicsshparam-0.1.11.tar.gz

sdist · 656.48 KB · Python source

Source file

Repository

PENDING
allencell/aics-shparam

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 10:21 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:e8cdcccc19f1537ea9ad30feb70980087aa79ca0d4c95266fee852014a532b88

Other collected versions

View all collected versions →