https://github.com/brisvag/napari-cellular-automata

napari-cellular-automata

https://github.com/brisvag/napari-cellular-automata

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

napari-cellular-automata

Basic Info
  • Host: GitHub
  • Owner: brisvag
  • License: gpl-3.0
  • Language: Python
  • Default Branch: main
  • Size: 32.2 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created about 3 years ago · Last pushed about 3 years ago
Metadata Files
Readme License

README.md

napari-cellular-automata

License GNU GPL v3.0 PyPI Python Version tests codecov napari hub

A generalized n-dimensional cellular automata engine, using napari for visualisation.

https://user-images.githubusercontent.com/23482191/235496634-e4d56432-77dc-4acf-838a-61c98d32c1c0.mp4

Installation and Usage

pip install napari-cellular-automata

Open napari, then use the Initialize World widget to create a new layer with the automaton, of your choice. Use Populate World to randomize the initial state as you prefer. Then use the Run Automaton widget to run the simulation. You can select multiple states to plot some stats as well.


You can also use this as a library:

```python from napari-cellular-automata.engine import populateworldwithstate, stepworld, getstatedescriptions from napari-cellular-automata.automata import AUTOMATA import numpy as np

pyro = AUTOMATA['Pyroclastic'] world = np.zeros((100, 100, 100), dtype=np.uint8) populateworldwithstate(world, 9, blobnumber=1) states = getstatedescriptions(pyro)

while True: uniq, counts = np.unique(world, returncounts=True) for state, count in zip(uniq, counts): print(f'{states[state]}: {count}') world = stepworld(world, pyro, wrap=False, edge_value=10) ```

Rules and engines

In the generalized approach, rules are defined by transition dictionaries that encode how each state changes into a different state, plus some extra info such as color and state name for visualisation. This implementation is based on a series of videos by tsoding. Original typescript source code: https://github.com/tsoding/autocell.

For example, Conway's Game of Life can be defined as follows:

python [ { # state 0 (dead) 'transitions': { # if this cell has 3 neighbours of state 1 (alive), become state 1 # -1 means "any number" (only relevant with more than 2 states) (-1, 3): 1, }, # if none of the rules above apply, become/remain the "default" state 0 (dead) 'default': 0, # visualisation parameters 'color': 'transparent', 'name': 'dead', }, { # state 1 (alive) 'transitions': { # if this cell has 2 or 3 neighbours of state 1 (alive), remain state 1 (-1, 2): 1, (-1, 3): 1, }, # if none of the rules above apply, become the "default" state 0 (dead) 'default': 0, 'color': 'green', 'name': 'alive', }, ]


A second, more limited (but smaller and faster) engine is based on the Survival-Birth rules; neighbour types do not matter, just their number. Other than dead and alive, any number of decay states can be added, which simply "delay" the time of death of a cell. The Game of Life is defined as:

python { # number of non-dead neighbours necessary for survival 'survival': [2, 3], # number of non-dead neighbours necessary for birth 'birth': [3], # number of total states (including alive, dead, and decay) 'states': 2, }

or, in short form: '2-3/3/2'.

You can add a custom automaton by simply adding to the AUTOMATA dictionary:

```python from napari-cellular-automata.engine import rulesfromsurvival_birth from napari-cellular-automata.automata import AUTOMATA

AUTOMATA['My rules'] = { 'ndim': 2, 'mode': 'survival-birth', 'rules': rulesfromsurvival_birth('2-3,5/3/4'), } ```


This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-plugin template.

Installation

You can install napari-cellular-automata via pip:

pip install napari-cellular-automata

To install latest development version :

pip install git+https://github.com/brisvag/napari-cellular-automata.git

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 GNU GPL v3.0 license, "napari-cellular-automata" is free and open source software

Issues

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

Owner

  • Name: Lorenzo Gaifas
  • Login: brisvag
  • Kind: user
  • Company: @gutsche-lab

PhD student at @gutsche-lab, doing computational stuff with cryo-ET data.

GitHub Events

Total
Last Year

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 1
  • Total pull requests: 0
  • Average time to close issues: less than a minute
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • brisvag (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels