syntropy-phi-c 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- syntropy_phi_c-0.1.0/LICENSE +59 -0
- syntropy_phi_c-0.1.0/PKG-INFO +19 -0
- syntropy_phi_c-0.1.0/README.md +64 -0
- syntropy_phi_c-0.1.0/phi_c/__init__.py +9 -0
- syntropy_phi_c-0.1.0/phi_c/motifs.py +33 -0
- syntropy_phi_c-0.1.0/phi_c/pacemaker.py +31 -0
- syntropy_phi_c-0.1.0/phi_c/topology.py +34 -0
- syntropy_phi_c-0.1.0/setup.cfg +4 -0
- syntropy_phi_c-0.1.0/setup.py +21 -0
- syntropy_phi_c-0.1.0/syntropy_phi_c.egg-info/PKG-INFO +19 -0
- syntropy_phi_c-0.1.0/syntropy_phi_c.egg-info/SOURCES.txt +12 -0
- syntropy_phi_c-0.1.0/syntropy_phi_c.egg-info/dependency_links.txt +1 -0
- syntropy_phi_c-0.1.0/syntropy_phi_c.egg-info/requires.txt +2 -0
- syntropy_phi_c-0.1.0/syntropy_phi_c.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Copyright (C) 2026 Syntropy Project (Alex Lopes da Silva) e Colaboradores.
|
|
2
|
+
|
|
3
|
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
|
4
|
+
Version 3, 19 November 2007
|
|
5
|
+
|
|
6
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
7
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
8
|
+
of this license document, but changing it is not allowed.
|
|
9
|
+
|
|
10
|
+
Preamble
|
|
11
|
+
|
|
12
|
+
The GNU Affero General Public License is a free, copyleft license for
|
|
13
|
+
software and other kinds of works, specifically designed to ensure
|
|
14
|
+
cooperation with the community in the case of network server software.
|
|
15
|
+
|
|
16
|
+
The licenses for most software and other practical works are designed
|
|
17
|
+
to take away your freedom to share and change the works. By contrast,
|
|
18
|
+
our General Public Licenses are intended to guarantee your freedom to
|
|
19
|
+
share and change all versions of a program--to make sure it remains free
|
|
20
|
+
software for all its users.
|
|
21
|
+
|
|
22
|
+
When we speak of free software, we are referring to freedom, not
|
|
23
|
+
price. Our General Public Licenses are designed to make sure that you
|
|
24
|
+
have the freedom to distribute copies of free software (and charge for
|
|
25
|
+
them if you wish), that you receive source code or can get it if you
|
|
26
|
+
want it, that you can change the software or use pieces of it in new
|
|
27
|
+
free programs, and that you know you can do these things.
|
|
28
|
+
|
|
29
|
+
Developers that use our General Public Licenses protect your rights
|
|
30
|
+
with two steps: (1) assert copyright on the software, and (2) offer
|
|
31
|
+
you this License which gives you legal permission to copy, distribute
|
|
32
|
+
and/or modify the software.
|
|
33
|
+
|
|
34
|
+
A secondary benefit of defending all users' freedom is that
|
|
35
|
+
improvements made in alternate versions of the program, if they
|
|
36
|
+
receive widespread use, become available for other developers to
|
|
37
|
+
incorporate. Many developers of free software are heartened and
|
|
38
|
+
encouraged by the resulting cooperation. However, in the case of
|
|
39
|
+
software used on network servers, this result may fail to come about.
|
|
40
|
+
The GNU General Public License permits making a modified version and
|
|
41
|
+
letting the public access it on a server without ever releasing its
|
|
42
|
+
source code to the public.
|
|
43
|
+
|
|
44
|
+
The GNU Affero General Public License is designed specifically to
|
|
45
|
+
ensure that, in such cases, the modified source code becomes available
|
|
46
|
+
to the community. It requires the operator of a network server to
|
|
47
|
+
provide the source code of the modified version running there to the
|
|
48
|
+
users of that server. Therefore, public use of a modified version, on
|
|
49
|
+
a publicly accessible server, gives the public access to the source
|
|
50
|
+
code of the modified version.
|
|
51
|
+
|
|
52
|
+
An older license, called the Affero General Public License and
|
|
53
|
+
published by Affero, was designed to accomplish similar goals. This is
|
|
54
|
+
a different license, not a version of the Affero GPL, but Affero has
|
|
55
|
+
released a new version of the Affero GPL which permits relicensing under
|
|
56
|
+
this license.
|
|
57
|
+
|
|
58
|
+
The precise terms and conditions for copying, distribution and
|
|
59
|
+
modification follow.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: syntropy-phi-c
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Fast Topological Heuristic for Connectome Pacemakers
|
|
5
|
+
Author: Syntropy Project (Alex Lopes da Silva)
|
|
6
|
+
Classifier: Development Status :: 3 - Alpha
|
|
7
|
+
Classifier: Intended Audience :: Science/Research
|
|
8
|
+
Classifier: Intended Audience :: Healthcare Industry
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: numpy>=1.20.0
|
|
14
|
+
Requires-Dist: networkx>=2.5
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
Dynamic: requires-dist
|
|
19
|
+
Dynamic: summary
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Phi-C ($\Phi_C$): Topological Connectome Pacemaker
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
**Phi-C** is a high-performance Python library designed to rapidly identify Central Pattern Generators (CPGs) and rhythmic pacemakers in massive biological connectomes using algebraic topology.
|
|
8
|
+
|
|
9
|
+
Developed by the **Syntropy Project** (Alex Lopes da Silva).
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 🧠The Problem
|
|
14
|
+
Finding autonomous oscillating regions in a brain (like the ones controlling breathing or locomotion) usually requires simulating the entire dynamic chemistry of the network, which becomes computationally intractable $O(2^N)$ in large mammalian brains.
|
|
15
|
+
|
|
16
|
+
Furthermore, naive structural density metrics often fall into the **"Cerebellar Trap"**: flagging massive, dense, but purely feed-forward structures (like the cerebellum) as pacemakers.
|
|
17
|
+
|
|
18
|
+
## âš¡ The Solution
|
|
19
|
+
`phi-c` acts as a structural $O(N)$ pre-filter. We combine two mathematical concepts:
|
|
20
|
+
1. **Simplicial Nerve Scaling**: A fast approximation of topological integration space using local clustering and eigenvector centrality.
|
|
21
|
+
2. **Motif Discriminator**: A strict graph-theoretic filter that penalizes unidirectional cliques and actively seeks reciprocal feedback loops ($A \rightleftharpoons B$).
|
|
22
|
+
|
|
23
|
+
By crossing these two metrics, the library instantly filters out false-positives and returns the absolute topological anatomical hotspots driving the network rhythm.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 📦 Installation
|
|
28
|
+
|
|
29
|
+
*(Pending PyPI release)*
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/alexlopesdasilva/phi-c.git
|
|
32
|
+
cd phi-c
|
|
33
|
+
pip install .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🚀 Quick Start
|
|
39
|
+
|
|
40
|
+
The library takes any standard directed graph (like a connectome exported from Electron Microscopy data) and returns the top pacemaker nodes.
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import networkx as nx
|
|
44
|
+
from phi_c.pacemaker import find_pacemaker
|
|
45
|
+
|
|
46
|
+
# 1. Load a brain connectome (e.g., C. elegans)
|
|
47
|
+
connectome = nx.read_graphml("worm_brain.graphml")
|
|
48
|
+
|
|
49
|
+
# 2. Extract the top 5 Central Pattern Generators in milliseconds
|
|
50
|
+
cpg_hotspots = find_pacemaker(connectome, top_k=5)
|
|
51
|
+
|
|
52
|
+
# 3. View the results
|
|
53
|
+
for rank, (neuron, score) in enumerate(cpg_hotspots, 1):
|
|
54
|
+
print(f"#{rank} - Neuron: {neuron} | Phi-C Score: {score:.2f}")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 📜 License
|
|
60
|
+
This project is dual-licensed:
|
|
61
|
+
1. **Open Source**: GNU AGPLv3 (Free for academic research and non-commercial public use).
|
|
62
|
+
2. **Commercial License**: For enterprise usage in proprietary medical software or SaaS APIs without AGPL obligations, please contact the author.
|
|
63
|
+
|
|
64
|
+
Copyright (C) 2026 Syntropy Project (Alex Lopes da Silva) and Contributors.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import networkx as nx
|
|
2
|
+
|
|
3
|
+
def compute_motif_discrimination(G: nx.DiGraph) -> dict:
|
|
4
|
+
"""
|
|
5
|
+
The 'Cerebellum Filter'.
|
|
6
|
+
Identifies strict rhythmic feedback loops (A <-> B) and penalizes
|
|
7
|
+
nodes that only participate in dense feed-forward structures.
|
|
8
|
+
|
|
9
|
+
Returns:
|
|
10
|
+
dict: Mapping of node to its Motif Reciprocity Multiplier (0.0 to 1.0+).
|
|
11
|
+
"""
|
|
12
|
+
reciprocity_scores = {}
|
|
13
|
+
|
|
14
|
+
for node in G.nodes():
|
|
15
|
+
out_edges = set(G.successors(node))
|
|
16
|
+
in_edges = set(G.predecessors(node))
|
|
17
|
+
|
|
18
|
+
# Reciprocal edges: where A -> B and B -> A
|
|
19
|
+
reciprocal = out_edges.intersection(in_edges)
|
|
20
|
+
total_connections = len(out_edges.union(in_edges))
|
|
21
|
+
|
|
22
|
+
if total_connections == 0:
|
|
23
|
+
reciprocity_scores[node] = 0.0
|
|
24
|
+
else:
|
|
25
|
+
# Ratio of purely bidirectional edges over all edges
|
|
26
|
+
# A true pacemaker has high bidirectionality (rhythmic feedback)
|
|
27
|
+
ratio = len(reciprocal) / total_connections
|
|
28
|
+
|
|
29
|
+
# Penalize pure feed-forward (ratio near 0)
|
|
30
|
+
# Boost high feedback (ratio > 0.5)
|
|
31
|
+
reciprocity_scores[node] = ratio ** 2
|
|
32
|
+
|
|
33
|
+
return reciprocity_scores
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import networkx as nx
|
|
2
|
+
from .topology import compute_simplicial_nerve
|
|
3
|
+
from .motifs import compute_motif_discrimination
|
|
4
|
+
|
|
5
|
+
def find_pacemaker(G: nx.DiGraph, top_k: int = 5) -> list:
|
|
6
|
+
"""
|
|
7
|
+
The main Phi_C algorithm.
|
|
8
|
+
Crosses raw structural density (Simplicial Nerve) with the
|
|
9
|
+
directional feedback filter (Motif Discriminator) to output
|
|
10
|
+
the absolute Central Pattern Generator (CPG) hot-spots.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
G (nx.DiGraph): The connectome graph.
|
|
14
|
+
top_k (int): Number of top pacemaker candidate nodes to return.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
list: Top K nodes sorted by final Phi_C pacemaker score.
|
|
18
|
+
"""
|
|
19
|
+
raw_density = compute_simplicial_nerve(G)
|
|
20
|
+
motif_multiplier = compute_motif_discrimination(G)
|
|
21
|
+
|
|
22
|
+
final_scores = {}
|
|
23
|
+
for node in G.nodes():
|
|
24
|
+
# The Final Phi_C metric:
|
|
25
|
+
# High Density * High Reciprocity = True Pacemaker
|
|
26
|
+
# High Density * Low Reciprocity (Cerebellum trap) = Dropped to 0
|
|
27
|
+
final_scores[node] = raw_density[node] * motif_multiplier[node]
|
|
28
|
+
|
|
29
|
+
# Sort by score descending
|
|
30
|
+
ranked_nodes = sorted(final_scores.items(), key=lambda item: item[1], reverse=True)
|
|
31
|
+
return ranked_nodes[:top_k]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import networkx as nx
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
def compute_simplicial_nerve(G: nx.DiGraph) -> dict:
|
|
5
|
+
"""
|
|
6
|
+
Computes the fast O(N) structural simplicial nerve density (Phi_C proxy)
|
|
7
|
+
for each node in a Directed Graph.
|
|
8
|
+
|
|
9
|
+
Instead of calculating exact O(2^N) Integration Information (Phi),
|
|
10
|
+
we measure the local graph density (clique-like structures) and
|
|
11
|
+
eigenvector centrality to act as a topological pre-filter.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
dict: Mapping of node to its raw structural density score.
|
|
15
|
+
"""
|
|
16
|
+
# Use undirected version for pure structural density
|
|
17
|
+
G_undirected = G.to_undirected()
|
|
18
|
+
|
|
19
|
+
# 1. Local Clustering Coefficient (measure of local simplices/triangles)
|
|
20
|
+
clustering = nx.clustering(G_undirected)
|
|
21
|
+
|
|
22
|
+
# 2. Eigenvector Centrality (measure of global network influence)
|
|
23
|
+
try:
|
|
24
|
+
centrality = nx.eigenvector_centrality_numpy(G)
|
|
25
|
+
except Exception:
|
|
26
|
+
# Fallback if matrix is perfectly un-diagonalizable
|
|
27
|
+
centrality = nx.degree_centrality(G)
|
|
28
|
+
|
|
29
|
+
scores = {}
|
|
30
|
+
for node in G.nodes():
|
|
31
|
+
# The topological heuristic Phi_C raw
|
|
32
|
+
scores[node] = clustering[node] * centrality[node] * 1000
|
|
33
|
+
|
|
34
|
+
return scores
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='syntropy-phi-c',
|
|
5
|
+
version='0.1.0',
|
|
6
|
+
description='A Fast Topological Heuristic for Connectome Pacemakers',
|
|
7
|
+
author='Syntropy Project (Alex Lopes da Silva)',
|
|
8
|
+
packages=find_packages(),
|
|
9
|
+
install_requires=[
|
|
10
|
+
'numpy>=1.20.0',
|
|
11
|
+
'networkx>=2.5',
|
|
12
|
+
],
|
|
13
|
+
classifiers=[
|
|
14
|
+
'Development Status :: 3 - Alpha',
|
|
15
|
+
'Intended Audience :: Science/Research',
|
|
16
|
+
'Intended Audience :: Healthcare Industry',
|
|
17
|
+
'License :: OSI Approved :: MIT License',
|
|
18
|
+
'Programming Language :: Python :: 3',
|
|
19
|
+
'Topic :: Scientific/Engineering :: Medical Science Apps.',
|
|
20
|
+
],
|
|
21
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: syntropy-phi-c
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Fast Topological Heuristic for Connectome Pacemakers
|
|
5
|
+
Author: Syntropy Project (Alex Lopes da Silva)
|
|
6
|
+
Classifier: Development Status :: 3 - Alpha
|
|
7
|
+
Classifier: Intended Audience :: Science/Research
|
|
8
|
+
Classifier: Intended Audience :: Healthcare Industry
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: numpy>=1.20.0
|
|
14
|
+
Requires-Dist: networkx>=2.5
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
Dynamic: requires-dist
|
|
19
|
+
Dynamic: summary
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
phi_c/__init__.py
|
|
5
|
+
phi_c/motifs.py
|
|
6
|
+
phi_c/pacemaker.py
|
|
7
|
+
phi_c/topology.py
|
|
8
|
+
syntropy_phi_c.egg-info/PKG-INFO
|
|
9
|
+
syntropy_phi_c.egg-info/SOURCES.txt
|
|
10
|
+
syntropy_phi_c.egg-info/dependency_links.txt
|
|
11
|
+
syntropy_phi_c.egg-info/requires.txt
|
|
12
|
+
syntropy_phi_c.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
phi_c
|