{"id":28389858,"url":"https://github.com/nabilalibou/connectivity_segmentation","last_synced_at":"2025-06-29T23:38:29.976Z","repository":{"id":218249943,"uuid":"744654621","full_name":"nabilalibou/connectivity_segmentation","owner":"nabilalibou","description":"Track and segment the dynamics of brain connectivity networks","archived":false,"fork":false,"pushed_at":"2024-09-28T11:34:08.000Z","size":739,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-31T11:58:27.439Z","etag":null,"topics":["connectivity","eeg","eeg-analysis","functional-connectivity","kmeans-clustering","microstates"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nabilalibou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-17T18:35:29.000Z","updated_at":"2025-05-16T12:30:47.000Z","dependencies_parsed_at":"2024-01-23T22:29:07.521Z","dependency_job_id":"707ca077-eebd-4bba-8296-4a11960293b3","html_url":"https://github.com/nabilalibou/connectivity_segmentation","commit_stats":null,"previous_names":["nabil-al/connectivity_segmentation","nabilalibou/connectivity_segmentation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nabilalibou/connectivity_segmentation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabilalibou%2Fconnectivity_segmentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabilalibou%2Fconnectivity_segmentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabilalibou%2Fconnectivity_segmentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabilalibou%2Fconnectivity_segmentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nabilalibou","download_url":"https://codeload.github.com/nabilalibou/connectivity_segmentation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabilalibou%2Fconnectivity_segmentation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262335901,"owners_count":23295759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["connectivity","eeg","eeg-analysis","functional-connectivity","kmeans-clustering","microstates"],"created_at":"2025-05-31T02:37:21.171Z","updated_at":"2025-06-29T23:38:29.967Z","avatar_url":"https://github.com/nabilalibou.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Connectivity Microstates Segmentation\n\nPython library to track the spatiotemporal dynamics of brain network based on a modified k-means clustering algorithm \n[[1]](#1) adapted to EEG connectivity graphs with a methodology similar to [[2]](#2) (see [Figure 1](#fig1) and [Figure 2](#fig2)). \n\nIn order to identify the different clusters sequentially involved in the cognitive process, the algorithm aims at \nidentify and segment the connectivity microstates [[3]](#3)[[4]](#4).  \n\u003cbr/\u003e\u003cbr/\u003e\n\u003ca id=\"fig1\"\u003e \u003c/a\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"docs\\Kmeans_diagram.png\" width=\"800\" height=\"358\"\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\nMethodology of the Modified K-Means Clustering adapted to connectivity graphs.  \n\nInitialise a number of cluster, select randomly K connectivity graphs (aka adjacent matrices) Gk, compute the spatial correlation between them and every others matrices from the connectivity graph pool.  \nEach graph are assigned to cluster with which they had been the most correlated. Update the centroids of the clusters by taking the mean graph of all assigned graph until the global explained variance (GEV) explained by each cluster (for a certain K) converges.  \nUse a criterion like the cross validation criterion which is a ratio GEV to number of clusters to determine a good trade-off between variance explained and number of clusters.  \n\u003c/div\u003e\n\u003cbr/\u003e\n\n\u003cbr/\u003e\u003cbr/\u003e\n\u003ca id=\"fig2\"\u003e \u003c/a\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"docs\\segmentation_example.png\" width=\"720\" height=\"518\"\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\nResult of the connectivity spatiotemporal segmentation process applied to adjacency matrix from subjects who performed \na picture recognition and naming task.  \nIllustrates the Event related potentials for the picture naming task and the obtained sequential clusters associated \nto their corresponding brain connectivity networks.  \nFigure taken from [2].\n\u003c/div\u003e\n\u003cbr/\u003e\n\n# Installation\n\n```\ngit clone https://github.com/nabilalibou/connectivity_segmentation.git\npip install -r requirements.txt\n```\n\n# How to use\n\nconnectivity-segmentation relies on 2 convenient classes: \n```\nconnectivity_segmentation.kmeans.ModKMeans \nconnectivity_segmentation.segmentation.Segmentation\n```\n\nWe start by fitting the modified kmeans algorithm to a dataset using \nthe ```ModKMeans.fit()``` method before the ```ModKMeans.predict()``` method which will return the microstate ```Segmentation``` object.   \nThe segmentation can be visualised using the method ```segmentation.Segmentation.plot()```.\n\nThe package implement other methods and functions to compute, visualise and save various metrics and statistics to \nevaluate the clustering solution.\n\n_Note: The Segmentation class is an adaptation of the \\_BaseSegmentation class from the library pycrostate [[5]](#5) \n(https://github.com/vferat/pycrostates, Copyright (c) 2020, Victor Férat, All rights reserved.)_\n\n# References\n\n\u003ca id=\"1\"\u003e[1]\u003c/a\u003e\nPascual-Marqui RD, Michel CM, Lehmann D. Segmentation of brain electrical activity into microstates: model estimation \nand validation. Biomedical Engineering, IEEE Transactions on. 1995; 42:658–665\n\n\u003ca id=\"2\"\u003e[2]\u003c/a\u003e\nMheich, A.; Hassan, M.; Khalil, M.; Berrou, C.; Wendling, F. (2015). A new algorithm for spatiotemporal analysis of \nbrain functional connectivity. Journal of Neuroscience Methods, 242(), 77–81. doi:10.1016/j.jneumeth.2015.01.002 \n\n\u003ca id=\"3\"\u003e[3]\u003c/a\u003e\nChristoph M. Michel and Thomas Koenig. Eeg microstates as a tool for studying the temporal dynamics of whole-brain \nneuronal networks: a review. NeuroImage, 180:577–593, 2018. doi:10.1016/j.neuroimage.2017.11.062.\n\n\u003ca id=\"4\"\u003e[4]\u003c/a\u003e\nMicah M. Murray; Denis Brunet; Christoph M. Michel (2008). Topographic ERP Analyses: A Step-by-Step Tutorial Review. , \n20(4), 249–264. doi:10.1007/s10548-008-0054-5\n\n\u003ca id=\"4\"\u003e[5]\u003c/a\u003e\nVictor Férat, Mathieu Scheltienne, rkobler, AJQuinn, \u0026 Lou. (2023). vferat/pycrostates: 0.4.1 (0.4.1). Zenodo. \nhttps://doi.org/10.5281/zenodo.10176055\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabilalibou%2Fconnectivity_segmentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnabilalibou%2Fconnectivity_segmentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabilalibou%2Fconnectivity_segmentation/lists"}