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, MPSPlots, 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_algorithm=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.2.5

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.2.5
File
flowcypy-1.2.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
flowcypy-1.2.5-cp314-cp314-macosx_26_0_arm64.whl CPython 3.14 CPython 3.14 macOS 26.0+ ARM64 Details
flowcypy-1.2.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
flowcypy-1.2.5-cp313-cp313-macosx_26_0_arm64.whl CPython 3.13 CPython 3.13 macOS 26.0+ ARM64 Details
flowcypy-1.2.5-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
flowcypy-1.2.5-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details
flowcypy-1.2.5-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
flowcypy-1.2.5-cp311-cp311-macosx_26_0_arm64.whl CPython 3.11 CPython 3.11 macOS 26.0+ ARM64 Details

Total release size: 34.1 MB

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

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

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

Download URL flowcypy-1.2.5-cp314-cp314-macosx_26_0_arm64.whl
Size 4.6 MB
Tags CPython 3.14 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
3424b3292688d7158675424744fcd069a3c2a295ee4896bac53496c9681059cf
BLAKE2b-256 checksum
How to use checksums
a12b421f3a014332a60c69bf5f6557c0a0c800e84b3499d2dd3eefa8e90fc6b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL flowcypy-1.2.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 3.9 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3841661dfb15d9f5d4a9fce500c90e93849f49ee98ff8b0f155e1c30cbb2365c
BLAKE2b-256 checksum
How to use checksums
9245ea9d5028758988116c373333c08d01acb58a3b7a0491e1a0a169ed5362ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL flowcypy-1.2.5-cp313-cp313-macosx_26_0_arm64.whl
Size 4.6 MB
Tags CPython 3.13 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
6bba3fd3bad2f2770a32842ea1233764afedde97a032e150ec8b93007623abe9
BLAKE2b-256 checksum
How to use checksums
8a040231f3df918a28bc2ab43434e3f78112a91ed3da1339380296a926e696d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL flowcypy-1.2.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 3.9 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b7db5581afe11d67f61b673151a4eebd58f68befebe6b957ece9ec48d11c5d7b
BLAKE2b-256 checksum
How to use checksums
dbde7198557cea49d42833756d7a8dd8d5bf045d86f66efbdfe28af26f1b9287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL flowcypy-1.2.5-cp312-cp312-macosx_26_0_arm64.whl
Size 4.6 MB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
cd32acc61eb389f6b3089ea208e069610341064cd7b4d546d920fcd6a89432dd
BLAKE2b-256 checksum
How to use checksums
97977108f1272a5bd42bbd53ff8dac37677d06a84eda1d8783e987f84abf1f48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL flowcypy-1.2.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 3.9 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e89f230dab9b39de2b4b7957c24533673087c088b81ca52a5efb52c6adb60434
BLAKE2b-256 checksum
How to use checksums
0a33c437d2897d67ffd3979c6e779f5f3418dffb626ea8c8e9e1168f565874e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL flowcypy-1.2.5-cp311-cp311-macosx_26_0_arm64.whl
Size 4.6 MB
Tags CPython 3.11 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
9a56b894719f75e209cb6427459bbc280078c040d9aa156f09b291fd117d635c
BLAKE2b-256 checksum
How to use checksums
7433a5f8abc48ad6cb06f440edcdbcc6410cf1ea952178d67b700f4d0ccf626b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

1.2.6

8 release files

This release

1.2.5 This release

8 release files

1.2.4

8 release files

1.2.3

8 release files

1.2.2

8 release files

1.2.1

8 release files

1.2.0

8 release files

1.1.1

6 release files

1.0.4

6 release files

1.0.3

6 release files

1.0.2

6 release files

1.0.1

6 release files

1.0.0

6 release files

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