# fundyn/dfcwalk architecture

> Architecture diagram of the GitHub repository fundyn/dfcwalk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fundyn/dfcwalk
- Repository: https://github.com/fundyn/dfcwalk

## Overview

##### Project type and purpose
- This is an open-source MATLAB toolbox (“dFCwalk”) for analyzing dynamic Functional Connectivity (dFC) in neural time-series. It implements two core workflows:
a. dFC Speed Analysis – computes time-resolved reconfiguration rates (“speeds”) of functional networks.
b. Meta-Connectivity (MC) Analysis – groups links whose fluctuations co-vary into modules and analyzes module-specific dFC speed.
- There is no traditional frontend/backend: it’s a computational library invoked in MATLAB, providing functions, utilities, and plotting routines.

##### File structure
- All .m files reside at top level – no subfolders.
- Key clusters of functions by name patterns:
- Speed analyses: BuildSpeedHistogram.m, PlotSpeedHisto.m, dFC_Speeds.m
- Stream conversion & metrics: TS2FC.m, TS2dFCstream.m, TS2eFC.m, dFCstream2MC.m, dFCstream2dFC.m
- MC analyses: Pick_MCModuleStream.m, Which_MCIndex_ThisLink.m, Which_StreamIndices_ThisMCmodule.m
- Utility / indexing: Which_Link_ThisMCIndex.m, Which_StreamIndex_ThisLink.m, Which_StreamIndex_ThisLink.m
- Statistical surrogates and info theory: PhaseRand_surrogates.m, Mutual_Information_Labels.m
- Community detection: community_louvain.m (from Brain Connectivity Toolbox)
- Vectorization: Matrix2Vec.m
- No build scripts or deployment configs beyond MATLAB path instructions.

##### README for additional insights
- Confirms toolbox scope: speed analyses and MC analyses.
- Suggests companion toolboxes: Brain Connectivity Toolbox, Fluctuation Analysis Toolbox.
- Encourages using function‐level help for syntaxes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Input
    DataInput["Data Input & Preprocessing"]:::core

    %% dFC Calculation Layer
    subgraph "dFC Calculation Layer"
        direction TB
        TS2FC["TS2FC.m"]:::core
        TS2dFCstream["TS2dFCstream.m"]:::core
    end

    %% dFC Speed Module
    subgraph "dFC Speed Module"
        direction TB
        dFC_Speeds["dFC_Speeds.m"]:::core
        BuildSpeedHistogram["BuildSpeedHistogram.m"]:::core
        PlotSpeedHisto["PlotSpeedHisto.m"]:::viz
        TS2eFC["TS2eFC.m"]:::core
    end

    %% Meta-Connectivity Module
    subgraph "Meta-Connectivity Module"
        direction TB
        dFCstream2MC["dFCstream2MC.m"]:::core
        community_louvain["community_louvain.m"]:::external
        Pick_MCModuleStream["Pick_MCModuleStream.m"]:::core
        Pick_StarStream["Pick_StarStream.m"]:::core
        Pick_SubgraphStream["Pick_SubgraphStream.m"]:::core
        Which_StreamIndices["Which_StreamIndices_ThisMCmodule.m"]:::core
        Which_MCIndex["Which_MCIndex_ThisLink.m"]:::core
        Which_LinkMC["Which_Link_ThisMCIndex.m"]:::core
        Which_StreamIndexLink["Which_StreamIndex_ThisLink.m"]:::core
    end

    %% Statistical & Utility Functions
    subgraph "Statistical & Utility Functions"
        direction TB
        PhaseRand["PhaseRand_surrogates.m"]:::util
        MutualInfo["Mutual_Information_Labels.m"]:::util
        Matrix2Vec["Matrix2Vec.m"]:::util
    end

    %% Visualization & Output
    subgraph "Visualization & Output"
        direction TB
        PlotSpeedHistoVis["PlotSpeedHisto.m"]:::viz
        BuildSpeedHistogramVis["BuildSpeedHistogram.m"]:::viz
    end

    %% External Toolboxes
    subgraph "External Dependencies"
        direction TB
        BCT["Brain Connectivity Toolbox"]:::external
        FAT["Fluctuation Analysis Toolbox"]:::external
    end

    %% MATLAB Environment
    MATLABEnv["MATLAB Environment\n(Runtime & Path)"]:::external

    %% Connections
    DataInput --> TS2FC
    DataInput --> TS2dFCstream
    TS2FC -->|"FC matrices"| dFC_Speeds
    TS2dFCstream -->|"dFC stream"| dFC_Speeds
    TS2dFCstream --> dFCstream2MC

    dFCstream2MC --> Pick_MCModuleStream
    Pick_MCModuleStream --> Which_StreamIndices
    Which_StreamIndices --> Which_MCIndex
    Which_MCIndex --> Which_LinkMC
    Which_LinkMC --> Which_StreamIndexLink
    dFCstream2MC --> community_louvain
    community_louvain --> Pick_StarStream
    community_louvain --> Pick_SubgraphStream
    Pick_StarStream --> Which_StreamIndexLink
    Pick_SubgraphStream --> Which_StreamIndexLink

    dFC_Speeds --> PlotSpeedHistoVis
    BuildSpeedHistogram --> BuildSpeedHistogramVis
    TS2eFC --> PlotSpeedHistoVis

    %% Statistical & Utility interconnections
    PhaseRand --> dFC_Speeds
    MutualInfo --> dFCstream2MC
    Matrix2Vec --> dFCstream2MC

    %% External dependencies
    community_louvain --> BCT
    PhaseRand --> FAT

    %% Visualization consumption
    PlotSpeedHistoVis --> MATLABEnv
    BuildSpeedHistogramVis --> MATLABEnv

    %% Click Events
    click TS2FC "https://github.com/fundyn/dfcwalk/blob/main/TS2FC.m"
    click TS2dFCstream "https://github.com/fundyn/dfcwalk/blob/main/TS2dFCstream.m"
    click dFC_Speeds "https://github.com/fundyn/dfcwalk/blob/main/dFC_Speeds.m"
    click BuildSpeedHistogram "https://github.com/fundyn/dfcwalk/blob/main/BuildSpeedHistogram.m"
    click PlotSpeedHisto "https://github.com/fundyn/dfcwalk/blob/main/PlotSpeedHisto.m"
    click TS2eFC "https://github.com/fundyn/dfcwalk/blob/main/TS2eFC.m"
    click dFCstream2MC "https://github.com/fundyn/dfcwalk/blob/main/dFCstream2MC.m"
    click community_louvain "https://github.com/fundyn/dfcwalk/blob/main/community_louvain.m"
    click Pick_MCModuleStream "https://github.com/fundyn/dfcwalk/blob/main/Pick_MCModuleStream.m"
    click Pick_StarStream "https://github.com/fundyn/dfcwalk/blob/main/Pick_StarStream.m"
    click Pick_SubgraphStream "https://github.com/fundyn/dfcwalk/blob/main/Pick_SubgraphStream.m"
    click Which_StreamIndices "https://github.com/fundyn/dfcwalk/blob/main/Which_StreamIndices_ThisMCmodule.m"
    click Which_MCIndex "https://github.com/fundyn/dfcwalk/blob/main/Which_MCIndex_ThisLink.m"
    click Which_LinkMC "https://github.com/fundyn/dfcwalk/blob/main/Which_Link_ThisMCIndex.m"
    click Which_StreamIndexLink "https://github.com/fundyn/dfcwalk/blob/main/Which_StreamIndex_ThisLink.m"
    click PhaseRand "https://github.com/fundyn/dfcwalk/blob/main/PhaseRand_surrogates.m"
    click MutualInfo "https://github.com/fundyn/dfcwalk/blob/main/Mutual_Information_Labels.m"
    click Matrix2Vec "https://github.com/fundyn/dfcwalk/blob/main/Matrix2Vec.m"
    click PlotSpeedHistoVis "https://github.com/fundyn/dfcwalk/blob/main/PlotSpeedHisto.m"
    click BuildSpeedHistogramVis "https://github.com/fundyn/dfcwalk/blob/main/BuildSpeedHistogram.m"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef util fill:#98FB98,stroke:#000,stroke-width:1px
    classDef viz fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
```
