# swharden/pyabf architecture

> Architecture diagram of the GitHub repository swharden/pyabf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/swharden/pyabf
- Repository: https://github.com/swharden/pyabf

## Overview

##### Main Components

a. Core Components:
- ABF File Parser (Central Component)
- ABF1 Format Handler
- ABF2 Format Handler
- ATF File Handler
- Data Processing Modules
- Analysis Tools

b. Supporting Components:
- File I/O System
- Data Structures
- Plotting Interface
- Filter System
- Stimulus Management

##### Data Access Layer
- ABF/ATF file inputs
- File readers (abfReader.py)
- File writers (abfWriter.py)

##### Format Processing Layer
- ABF1 handler (abf1/headerV1.py)
- ABF2 handler with sections (abf2/*.py)
- ATF handler (atf.py)

##### Core Processing Layer
- Main ABF class (abf.py)
- Stimulus processing (stimulus.py)
- Waveform handling (waveform.py)
- Filtering system (filter.py)

##### Analysis Tools Layer
- Membrane test tools (tools/memtest.py)
- Action potential analysis (tools/ap.py)
- Sweep analysis (tools/sweep.py)

##### Output/Interface Layer
- Plotting capabilities (plot.py)
- Data export functions
- API interfaces

Design Elements:

##### Modular design
- Clear separation between ABF1 and ABF2 handlers
- Extensible tools system
- Relationship with external plotting libraries

##### Data Flow
- How raw ABF data moves through the system
- How analysis tools interact with core components
- Demonstrate the stimulus and waveform processing pipeline

##### API Interface
- Simple public interface described in the README
- Pythonic nature of the API
- Example method calls

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#e6f3ff',
    'primaryTextColor': '#000',
    'primaryBorderColor': '#7C0000',
    'lineColor': '#000',
    'secondaryColor': '#006100',
    'tertiaryColor': '#fff'
  }
}}%%

flowchart TB
    classDef core fill:#e6f3ff,stroke:#333,stroke-width:2px
    classDef format fill:#fff7e6,stroke:#333,stroke-width:2px
    classDef processing fill:#e6ffe6,stroke:#333,stroke-width:2px
    classDef analysis fill:#ffe6e6,stroke:#333,stroke-width:2px
    classDef interface fill:#e6e6ff,stroke:#333,stroke-width:2px
    
    subgraph DataAccess["Data Access Layer"]
        Input[("ABF/ATF Files")]
        Reader["File Reader"]
        Writer["File Writer"]
    end

    subgraph FormatProcessing["Format Processing Layer"]
        ABF1["ABF1 Handler"]
        ABF2["ABF2 Handler"]
        ATF["ATF Handler"]
    end

    subgraph CoreProcessing["Core Processing Layer"]
        ABFCore["ABF Core Class"]
        Stimulus["Stimulus Processing"]
        Waveform["Waveform Handler"]
        Filter["Filter System"]
    end

    subgraph AnalysisTools["Analysis Tools Layer"]
        MemTest["Membrane Test"]
        AP["Action Potential Analysis"]
        Sweep["Sweep Analysis"]
    end

    subgraph OutputInterface["Output/Interface Layer"]
        Plot["Plotting System"]
        Export["Data Export"]
        API["API Interface"]
    end

    Input --> Reader
    Reader --> ABF1 & ABF2 & ATF
    ABF1 & ABF2 & ATF --> ABFCore
    ABFCore --> Stimulus
    ABFCore --> Waveform
    ABFCore --> Filter
    
    Stimulus & Waveform & Filter --> MemTest & AP & Sweep
    MemTest & AP & Sweep --> Plot
    MemTest & AP & Sweep --> Export
    Plot & Export --> API
    
    Writer --> Export

    click ABFCore "https://github.com/swharden/pyabf/blob/main/src/pyabf/abf.py"
    click ABF1 "https://github.com/swharden/pyabf/blob/main/src/pyabf/abf1/headerV1.py"
    click ABF2 "https://github.com/swharden/pyabf/blob/main/src/pyabf/abf2/headerV2.py"
    click ATF "https://github.com/swharden/pyabf/blob/main/src/pyabf/atf.py"
    click Reader "https://github.com/swharden/pyabf/blob/main/src/pyabf/abfReader.py"
    click Writer "https://github.com/swharden/pyabf/blob/main/src/pyabf/abfWriter.py"
    click MemTest "https://github.com/swharden/pyabf/blob/main/src/pyabf/tools/memtest.py"
    click AP "https://github.com/swharden/pyabf/blob/main/src/pyabf/tools/ap.py"
    click Sweep "https://github.com/swharden/pyabf/blob/main/src/pyabf/tools/sweep.py"
    click Plot "https://github.com/swharden/pyabf/blob/main/src/pyabf/plot.py"
    click Filter "https://github.com/swharden/pyabf/blob/main/src/pyabf/filter.py"
    click Stimulus "https://github.com/swharden/pyabf/blob/main/src/pyabf/stimulus.py"
    click Waveform "https://github.com/swharden/pyabf/blob/main/src/pyabf/waveform.py"

    class ABFCore,Reader,Writer core
    class ABF1,ABF2,ATF format
    class Stimulus,Waveform,Filter processing
    class MemTest,AP,Sweep analysis
    class Plot,Export,API interface
```
