syntropy-phi-c 0.1.0__py3-none-any.whl

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.
phi_c/__init__.py ADDED
@@ -0,0 +1,9 @@
1
+ from .topology import compute_simplicial_nerve
2
+ from .motifs import compute_motif_discrimination
3
+ from .pacemaker import find_pacemaker
4
+
5
+ __all__ = [
6
+ 'compute_simplicial_nerve',
7
+ 'compute_motif_discrimination',
8
+ 'find_pacemaker'
9
+ ]
phi_c/motifs.py ADDED
@@ -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
phi_c/pacemaker.py ADDED
@@ -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]
phi_c/topology.py ADDED
@@ -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,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,9 @@
1
+ phi_c/__init__.py,sha256=S1eYFp7AEcdmCjokf-EuXfuRO3RA3hRG_TyZp3FIJPA,238
2
+ phi_c/motifs.py,sha256=CkcGD11cE4jYOtkAaYXjqaroogBxHWoDKWlLD7oUt1o,1193
3
+ phi_c/pacemaker.py,sha256=P_P4q7g2gtIPE-HUWCytwS8SZ7g7X2T5GnCwk4GiZVs,1187
4
+ phi_c/topology.py,sha256=OHdwQQKCXHyp1bbnZKhMzb7a-84jGFFQ_2BaKsJ5rmU,1201
5
+ syntropy_phi_c-0.1.0.dist-info/licenses/LICENSE,sha256=HiGEABO2XU-NCZW0p2cBXyiFvXh57aGErJ9YzzwMQdo,2963
6
+ syntropy_phi_c-0.1.0.dist-info/METADATA,sha256=K-FFr1dItTnsaN86VsxOj9sjmGeACBk7Ydsztvwmbtw,681
7
+ syntropy_phi_c-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
8
+ syntropy_phi_c-0.1.0.dist-info/top_level.txt,sha256=ouZQrnAz7ELdGdYsoQM4RXL2L1GLaWxTEYYD99QXvEE,6
9
+ syntropy_phi_c-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -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 @@
1
+ phi_c