A package to generate all possible graphs for wildlife individual identification, and visualize them
Project description
LeOpardLink
This package is designed to assemble visual networks of detections of marked animal individuals (e.g., leopards, snow leopards, tigers, etc.) from camera-trapping datasets. We define detections as nodes in the graph, and the relationships of any pair of detections to be edges in the graph. The edges can be certain (two detections are/aren't the same individual), or uncertain (we do not know if the two detections are the same or not, e.g., detection 1 captures the left flank while detection 2 captures the right flank).
While this package was motivated for the use of wildlife camera trap images, it has many applications in other picture-relationship-based projects.
Installation
To install the package, download our repo first. Under the repo directory, use the following command:
pip install -e .
Dependencies
The package requires the following dependencies:
-
numpy -
pandas -
networkx -
jaal>=0.1.7
Features
-
Network Visualization: Generate an interactive plot of the current network.
-
Graph Generation: Generate all possible graphs from an identification matrix with uncertain edges.
-
Individual Counts: Calculate the number of individuals, mean, standard deviation, and 95% confidence interval.
Functions
-
checkInput: Check if the input adjacency matrix is valid. The identification matrix should only contain 3 numeric values: 1 (two detections are the same individual), 0 (two detections are not the same individual), -1 (uncertain relationship between the two detections) . -
createAdjList: Create an adjacency list from an adjacency matrix. Adjcency list and matrix are two different ways to store graph information. -
adjListToMatrix: Convert an adjacency list to an adjacency matrix. -
sumWeights: Calculate the sum of weights connected to a node. -
checkSymmetric: Check if the graph is symmetric. -
checkTransitivityWeighted: Check if the graph is transitive. -
detect_conflicts: Detect conflicts in the adjacency list. -
strictTransitiveClosure: Compute the strict transitive closure of an adjacency matrix. -
generateGraphsWithTransitivity: Generate all possible graphs with transitivity from an adjacency list. -
GraphProperty: Generate a dataframe of all graphs and their properties, including the number of clusters (connected nodes). -
JaalDataPrepareNode: Prepare node data for Jaal plotting. -
JaalDataPrepareEdge: Prepare edge data for Jaal plotting. -
JaalPlot: Plot the graph using Jaal. -
simulationMatrix: Generate a simulation adjacency matrix.
How does it work?
See the network below for a simulation dataset. 21 nodes represent 21 images from wildlife camera traps. Known matches are represented by edges. Based on this figure, there are 7 individuals.
import numpy as np
from LeOpardLink import matrices
# Example adjacency matrix
example_matrix = matrices.simulationMatrix()
# Check input
matrices.checkInput(example_matrix)
# Create adjacency list
adj_list = matrices.createAdjList(example_matrix)
# Check symmetry
matrices.checkSymmetric(adj_list)
# Check transitivity
is_transitive = matrices.checkTransitivityWeighted(adj_list)
# Generate graphs with transitivity
all_graphs = matrices.generateGraphsWithTransitivity(adj_list)
# Get graph properties
graph_properties = matrices.GraphProperty(all_graphs)
# Plot the graph using Jaal
G = nx.from_numpy_array(allgraphs[0])
node_df = matrices.JaalDataPrepareNode(G)
edge_df = matrices.JaalDataPrepareEdge(G)
matrices.JaalPlot(node_df, edge_df)
Contributing
Contributions are welcome! Please see the issues page for ways you can help.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Authors
- PLEASE WRITE YOUR CONTRIBUTIONS HERE
- PLEASE WRITE YOUR CONTRIBUTIONS HERE
- PLEASE WRITE YOUR CONTRIBUTIONS HERE
- Wrote python functions
- Wrote tests
- Wrote documentation
- Set up packaging
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file leopardlink-0.1.0.tar.gz.
File metadata
- Download URL: leopardlink-0.1.0.tar.gz
- Upload date:
- Size: 4.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88b07de8e58f3e03b8e5621823817c14fe9a13b479a930b8c59635ec626c4277
|
|
| MD5 |
f51001ac64490676dba7b5ed794dd9ca
|
|
| BLAKE2b-256 |
1568cd1f1ff16141b82b1b966cadcdc76bd6783d363b646564ea13e7805287ca
|
File details
Details for the file LeOpardLink-0.1.0-py3-none-any.whl.
File metadata
- Download URL: LeOpardLink-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb04735145214ab0bf7f1dd1fffab8d0fccc017b70d8add1be5c4178c82f6074
|
|
| MD5 |
7ce3fb50e015ae1119d490245dc3d8b9
|
|
| BLAKE2b-256 |
ac45edd1f923612b808ef8407fe7183aa602088445f51bdd04f53f2bd33f080f
|