Skip to main content

FlowCyPy Logo

FlowCyPy: Flow Cytometer Simulation Tool

Meta

Python

Documentation Status

Release

Testing

Unittest Status

Unittest coverage

Google Colab

PyPi

PyPi version

PyPI - Downloads

Anaconda

Anaconda version

Anaconda downloads

Latest release date

Overview

FlowCyPy is a cutting-edge Python library designed to simulate flow cytometer experiments. By generating realistic Forward Scatter (FSC) and Side Scatter (SSC) signals, FlowCyPy enables detailed modeling of flow cytometry setups, making it ideal for researchers and engineers working with extracellular vesicles (EVs) or other scatterers.

Key Features

  • Particle Event Simulation: Create detailed FSC/SSC signals with customizable particle size and refractive index distributions.

  • Noise and Signal Modeling: Incorporate realistic noise sources (thermal, shot, dark current) and baseline shifts.

  • Detector Configurations: Simulate real-world detector behaviors, including saturation and responsivity.

  • Fluorescence Modeling: Simulate fluorescence signals for labeled particles (e.g., EV surface markers).

  • Visualization Tools: Generate advanced plots, including density maps and signal traces.

For full documentation and examples, visit the FlowCyPy Documentation.

Installation

Install FlowCyPy via pip or conda`:

pip install FlowCyPy
conda install FlowCyPy --channels MartinPdeS

Requirements: Python 3.11 or higher with dependencies: numpy, pint, tabulate, seaborn, matplotlib, PyMieSim, pydantic>=2.6.3

Prebuilt wheels are published for Linux x86_64 and macOS ARM64. Other platforms require building from source with FFTW and OpenMP available.

Quick Start

Simulate a simple flow cytometer experiment:

from FlowCyPy.units import ureg
from FlowCyPy.fluidics import (
    Fluidics,
    FlowCell,
    ScattererCollection,
    populations,
    SampleFlowRate,
    SheathFlowRate,
)

# from FlowCyPy.sampling_method import GammaModel, ExplicitModel
from FlowCyPy.fluidics import distributions

flow_cell = FlowCell(
    sample_volume_flow=SampleFlowRate.MEDIUM.value,
    sheath_volume_flow=SheathFlowRate.MEDIUM.value,
    width=400 * ureg.micrometer,
    height=150 * ureg.micrometer,
)

scatterer_collection = ScattererCollection()

medium_refractive_index = distributions.Delta(1.33)

diameter_dist = distributions.RosinRammler(
    scale=200 * ureg.nanometer,
    shape=10,
)

ri_dist = distributions.Normal(
    mean=1.44,
    standard_deviation=0.002,
    low_cutoff=1.33,
)

sampling_method = populations.ExplicitModel()

population_0 = populations.SpherePopulation(
    name="Pop 0",
    medium_refractive_index=medium_refractive_index,
    concentration=1e10 * ureg.particle / ureg.milliliter,
    diameter=diameter_dist,
    refractive_index=ri_dist,
    sampling_method=sampling_method,
)


diameter_dist = distributions.RosinRammler(
    scale=30 * ureg.nanometer,
    shape=50,
)

ri_dist = distributions.Normal(
    mean=1.44,
    standard_deviation=0.002,
    low_cutoff=1.33,
)

population_1 = populations.SpherePopulation(
    name="Pop 1",
    medium_refractive_index=medium_refractive_index,
    concentration=5e11 * ureg.particle / ureg.milliliter,
    diameter=diameter_dist,
    refractive_index=ri_dist,
    sampling_method=populations.GammaModel(number_of_samples=5_000),
)

scatterer_collection.add_population(population_0, population_1)

scatterer_collection.dilute(factor=80)

fluidics = Fluidics(scatterer_collection=scatterer_collection, flow_cell=flow_cell)

# %%
# Step 2: Define Optical Subsystem
# --------------------------------
from FlowCyPy.opto_electronics import (
    Detector,
    Digitizer,
    OptoElectronics,
    Amplifier,
    source,
    circuits,
)

analog_processing = [
    circuits.BaselineRestorationServo(time_constant=100 * ureg.microsecond),
    circuits.BesselLowPass(cutoff_frequency=2 * ureg.megahertz, order=4, gain=2),
]

source = source.Gaussian(
    waist_z=10e-6 * ureg.meter,  # Beam waist along flow direction (z-axis)
    waist_y=60e-6 * ureg.meter,
    wavelength=405 * ureg.nanometer,
    optical_power=200 * ureg.milliwatt,
    rin=-140 * ureg.dB_per_Hz,
    bandwidth=10 * ureg.megahertz,
)

detectors = [
    Detector(
        name="side",
        phi_angle=90 * ureg.degree,
        numerical_aperture=1.1,
        responsivity=1 * ureg.ampere / ureg.watt,
    ),
    Detector(
        name="forward",
        phi_angle=0 * ureg.degree,
        numerical_aperture=0.3,
        cache_numerical_aperture=0.1,
        responsivity=1 * ureg.ampere / ureg.watt,
    ),
]

digitizer = Digitizer(
    sampling_rate=60 * ureg.megahertz,
    bit_depth=14,
    use_auto_range=True,
    channel_range_mode="shared",
)

amplifier = Amplifier(
    gain=10 * ureg.volt / ureg.ampere,
    bandwidth=10 * ureg.megahertz,
    voltage_noise_density=0.0 * ureg.nanovolt / ureg.sqrt_hertz,
    current_noise_density=0.0 * ureg.femtoampere / ureg.sqrt_hertz,
)

opto_electronics = OptoElectronics(
    digitizer=digitizer,
    detectors=detectors,
    source=source,
    amplifier=amplifier,
    analog_processing=analog_processing,
)


# %%
# Step 3: Signal Processing Configuration
# ---------------------------------------
from FlowCyPy.digital_processing import (
    DigitalProcessing,
    peak_locator,
    discriminator,
)

triggering = discriminator.FixedWindow(
    trigger_channel="side",
    threshold="4sigma",
    pre_buffer=40,
    post_buffer=40,
    max_triggers=-1,
)

peak_algo = peak_locator.GlobalPeakLocator()

digital_processing = DigitalProcessing(
    discriminator=triggering,
    peak_locator=peak_algo,
)

# %%
# Step 4: Run Simulation
# ----------------------
from FlowCyPy import FlowCytometer

cytometer = FlowCytometer(
    fluidics=fluidics,
    background_power=0.001 * ureg.milliwatt,
)

run_record = cytometer.run(
    opto_electronics=opto_electronics,
    digital_processing=digital_processing,
    run_time=1 * ureg.millisecond,
)

run_record.event_collection.plot(x="Diameter")

run_record.event_collection.plot(x="forward")

run_record.plot_analog()

run_record.plot_digital()


run_record.peaks.plot(x=("forward", "Height"))

Readme Events

_ = run_record.plot_analog(
    figure_size=(12, 8),
    show=False,
    save_as=f"{dir_path}/../images/readme_analog.png",
)

Readme Analog

_ = run_record.plot_digital(
    figure_size=(12, 8),
    show=False,
    save_as=f"{dir_path}/../images/readme_digital.png",
)

Readme Digital

Explore more examples in the FlowCyPy Examples.

Code structure

Here is the architecture for a standard workflow using FlowCyPy:

FlowCyPy Logo

Development and Contribution

Clone the Repository

git clone https://github.com/MartinPdeS/FlowCyPy.git
cd FlowCyPy

Install Locally

Install in editable mode with testing and documentation dependencies:

pip install -e .[testing,documentation] (on linux system)
pip install -e ".[testing,documentation]" (on macOS system)

Run Tests

Use pytest to validate functionality:

pytest

Build Documentation

Build the documentation locally:

cd docs
make html

Find the documentation in docs/_build/html.

Additional Resources

Contributions

Contributions are welcome! If you have suggestions, issues, or would like to collaborate, visit the GitHub repository.

Contact

For inquiries or collaboration, contact Martin Poinsinet de Sivry-Houle.

Metadata

Release files for FlowCyPy 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for FlowCyPy 1.6.0
File Actions
flowcypy-1.6.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for flowcypy-1.6.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
flowcypy-1.6.0-cp314-cp314-macosx_26_0_arm64.whl CPython 3.14 CPython 3.14 macOS 26.0+ ARM64 Details for flowcypy-1.6.0-cp314-cp314-macosx_26_0_arm64.whl
flowcypy-1.6.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for flowcypy-1.6.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
flowcypy-1.6.0-cp313-cp313-macosx_26_0_arm64.whl CPython 3.13 CPython 3.13 macOS 26.0+ ARM64 Details for flowcypy-1.6.0-cp313-cp313-macosx_26_0_arm64.whl
flowcypy-1.6.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for flowcypy-1.6.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
flowcypy-1.6.0-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details for flowcypy-1.6.0-cp312-cp312-macosx_26_0_arm64.whl
flowcypy-1.6.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for flowcypy-1.6.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
flowcypy-1.6.0-cp311-cp311-macosx_26_0_arm64.whl CPython 3.11 CPython 3.11 macOS 26.0+ ARM64 Details for flowcypy-1.6.0-cp311-cp311-macosx_26_0_arm64.whl

Total release size: 39.4 MB

Release files / flowcypy-1.6.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL flowcypy-1.6.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 4.6 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b41743966a668678dabbfd6875837c534ab4947812cff0c0b72728532e1ed5d6
BLAKE2b-256 checksum
How to use checksums
ee7491d337c6d8689310b5bb6a48fa77a902586d36d93b9afcd2cb2b6cbc374d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / flowcypy-1.6.0-cp314-cp314-macosx_26_0_arm64.whl

Download URL flowcypy-1.6.0-cp314-cp314-macosx_26_0_arm64.whl
Size 5.3 MB
Tags CPython 3.14 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
c064e57395ea026a368cdf11b80766a3466b030308d06ae524857424d9352d00
BLAKE2b-256 checksum
How to use checksums
e50fdc4c5d67393218d3ca12a64c733fd1a5a2224e15b10276ad672d45917ae5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / flowcypy-1.6.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL flowcypy-1.6.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 4.6 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0576f862370303a35bc1d9dc8042fdfb63d120f1e73f9065bbc5f11ebb75e1fc
BLAKE2b-256 checksum
How to use checksums
e73bafbc1313cc88862b013d66500b3295bb59ecd8a05932cc7ae2dadeccfdd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / flowcypy-1.6.0-cp313-cp313-macosx_26_0_arm64.whl

Download URL flowcypy-1.6.0-cp313-cp313-macosx_26_0_arm64.whl
Size 5.3 MB
Tags CPython 3.13 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
a83a345c3a6d193182b90ed08c4866aa2a645fc85c52fef2124926eb7fa835fa
BLAKE2b-256 checksum
How to use checksums
622dece9403cc984175c8960ccd6b60d9b3531d0ca7fb690f8e8b57d2055d1be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / flowcypy-1.6.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL flowcypy-1.6.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 4.6 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
87a0076a03e3d9edc0133264ce919dcb99bd03a1a029494165770f7439488dbb
BLAKE2b-256 checksum
How to use checksums
72e5c33b6f1f59db1c0b74708e6a579b405ab50a68986c849c753fe18c16fe38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / flowcypy-1.6.0-cp312-cp312-macosx_26_0_arm64.whl

Download URL flowcypy-1.6.0-cp312-cp312-macosx_26_0_arm64.whl
Size 5.3 MB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
d6283c2f11a7c3713a0308995850727f1989a443733c9226ecd735ea192b505a
BLAKE2b-256 checksum
How to use checksums
cd7d9c9a529eda6e482f34a44170b73a033a6bab8065c65d6aae482fe4b248d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / flowcypy-1.6.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL flowcypy-1.6.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 4.5 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
aff833073a8207dacfe6f70b75347fa4e094cbe5ea6a240f9ddfa940bc89b494
BLAKE2b-256 checksum
How to use checksums
7914e599744dcc30747373ee6315b28aaf3aebc887cfa2a45f50b380dedb37dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / flowcypy-1.6.0-cp311-cp311-macosx_26_0_arm64.whl

Download URL flowcypy-1.6.0-cp311-cp311-macosx_26_0_arm64.whl
Size 5.2 MB
Tags CPython 3.11 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
d90bfabfc2fd251650bf094a1f8692e1d21af3941ed941fd55f28d463812f30e
BLAKE2b-256 checksum
How to use checksums
ab6e7ac1ac8ec26f952816cce14b4d5cdabc726a40194fa0b4b101ebe1ee1201
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Security for FlowCyPy 1.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page