Skip to content

ChrisMzz/OrientationField

Repository files navigation

OrientationField

License MIT PyPI Python Version tests codecov napari hub

A plugin to compute a nematic field and topological defects on an image.


This napari plugin was generated with copier using the napari-plugin-template.

Installation

You can install orientationfield via pip:

pip install git+https://github.com/ChrisMzz/OrientationField

Details

About nematics :

Nematics are (2,2)-shaped arrays of the form :

$$Q = \begin{pmatrix} Q_{xx} & Q_{xy} \\ Q_{xy} & -Q_{xx} \end{pmatrix}$$

representing an orientation in a hemisphere (like arrows without arrowheads). We have $Q_{xx} = \lvert Q \rvert \cos(2 \psi)$ and $Q_{xy} = \lvert Q \rvert \sin(2 \psi)$, so we can find $\lvert Q \rvert$ and $\psi$ from :

$$\lvert Q \rvert = \sqrt{Q_{xx}^2 + Q_{xy}^2}, \qquad \psi = \frac{1}{2} \arctan 2(Q_{xy}, Q_{xx})$$

We can use builtin SciPy convolutions with kernels $K_{xx}$ and $K_{xy}$, built specifically for this, to get a per-pixel approximation of the nematic field of an image :

$$K_{xx \vert ij} = e^{-\frac{\rho_{ij}^2}{\sigma^2}} \cos(2 \theta)$$

$$K_{xy \vert ij} = e^{-\frac{\rho_{ij}^2}{\sigma^2}} \sin(2 \theta)$$

For all $i,j$ such that $\rho_{ij} < r$, otherwise the kernels are worth 0. Here, $\rho_{ij}$ is the distance from the center of the kernel (the kernels are always of shape (2r+1,2r+1) where r is the radius of a circle defined by a specified parameter), $\theta$ is the angle formed by the position $(i,j)$ compared to the center, and $\sigma$ is a parameter representing kernel bandwidth.

Because of the equivalent amount of information carried by the tuples $(Q_{xx}, Q_{xy})$ and $(\lvert Q \rvert, \psi)$, we can provide both types of data according to different situations.

Usage

Will write more when paper gets closer to being published. For now, installing the package in an environment and running napari in the environment will load the plugin in napari, which can be used with the interface directly.

Some images


Here is what the plugin widget looks like :


A brief overview of the parameters :


The tool can be used on non biological data :

Here is an example on The Starry Night by Van Gogh, this time showcasing defect computation :

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, "orientationfield" is free and open source software

Issues

If you encounter any problems, please [file an issue] along with a detailed description.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages