.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/tutorials/coupling_model.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_tutorials_coupling_model.py: Flow Cytometry Workflow: Single Population Example ================================================== This tutorial demonstrates a basic flow cytometry simulation using the FlowCyPy library. The example covers the configuration of: - A fluidic channel with hydrodynamic focusing - A synthetic particle population (Exosome + HDL) - A laser source and dual-detector optical system - Scattering intensity calculation per detector The resulting data are visualized using event-based plots. Workflow Steps: --------------- 1. Define laser source and flow cell geometry 2. Add synthetic particle populations 3. Model optical scattering with two detectors 4. Visualize population and scattering response .. GENERATED FROM PYTHON SOURCE LINES 24-26 Step 0: Imports and Setup -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 26-34 .. code-block:: Python import numpy as np from FlowCyPy import units from FlowCyPy.opto_electronics import source, TransimpedanceAmplifier from FlowCyPy.fluidics import Fluidics, FlowCell, ScattererCollection, population from FlowCyPy.detector import PMT from FlowCyPy.signal_processing import Digitizer from FlowCyPy import OptoElectronics .. GENERATED FROM PYTHON SOURCE LINES 35-37 Step 1: Define Optical Source ----------------------------- .. GENERATED FROM PYTHON SOURCE LINES 37-43 .. code-block:: Python laser = source.GaussianBeam( numerical_aperture=0.3 * units.AU, wavelength=750 * units.nanometer, optical_power=20 * units.milliwatt ) .. GENERATED FROM PYTHON SOURCE LINES 44-46 Step 2: Configure Flow Cell and Fluidics ---------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 46-65 .. code-block:: Python flow_cell = FlowCell( sample_volume_flow=0.02 * units.microliter / units.second, sheath_volume_flow=0.1 * units.microliter / units.second, width=20 * units.micrometer, height=10 * units.micrometer ) scatterer_collection = ScattererCollection(medium_refractive_index=1.33 * units.RIU) # Add Exosome and HDL populations scatterer_collection.add_population( population.Exosome(particle_count=5e10 * units.particle / units.milliliter), ) fluidics = Fluidics( scatterer_collection=scatterer_collection, flow_cell=flow_cell ) .. GENERATED FROM PYTHON SOURCE LINES 66-68 Step 3: Generate Particle Event DataFrame ----------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 68-73 .. code-block:: Python event_dataframe = fluidics.generate_event_dataframe(run_time=3.5 * units.millisecond) # Plot the diameter distribution of the particles event_dataframe.plot(x='Diameter', bins='auto') .. image-sg:: /gallery/tutorials/images/sphx_glr_coupling_model_001.png :alt: Distribution of Diameter :srcset: /gallery/tutorials/images/sphx_glr_coupling_model_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 74-76 Step 4: Define Detectors and Amplifier -------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 76-93 .. code-block:: Python detector_forward = PMT( name='forward', phi_angle=0 * units.degree, numerical_aperture=0.3 * units.AU ) detector_side = PMT( name='side', phi_angle=90 * units.degree, numerical_aperture=0.3 * units.AU ) amplifier = TransimpedanceAmplifier( gain=100 * units.volt / units.ampere, bandwidth=10 * units.megahertz ) .. GENERATED FROM PYTHON SOURCE LINES 94-96 Step 5: Configure Digitizer and Opto-Electronics ------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 96-108 .. code-block:: Python digitizer = Digitizer( bit_depth='14bit', saturation_levels='auto', sampling_rate=60 * units.megahertz ) opto_electronics = OptoElectronics( detectors=[detector_forward, detector_side], source=laser, amplifier=amplifier ) .. GENERATED FROM PYTHON SOURCE LINES 109-111 Step 6: Model Scattering Signals -------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 111-116 .. code-block:: Python event_dataframe = opto_electronics.model_event( event_dataframe=event_dataframe, compute_cross_section=True ) .. rst-class:: sphx-glr-script-out .. code-block:: none /opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/site-packages/FlowCyPy/source.py:266: UserWarning: Transverse distribution of particle flow exceed the waist of the source warnings.warn('Transverse distribution of particle flow exceed the waist of the source') /opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/site-packages/FlowCyPy/source.py:266: UserWarning: Transverse distribution of particle flow exceed the waist of the source warnings.warn('Transverse distribution of particle flow exceed the waist of the source') .. GENERATED FROM PYTHON SOURCE LINES 117-119 Step 7: Visualize Scattering Intensity -------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 119-123 .. code-block:: Python event_dataframe.plot( x='side', y='Csca' # Color-coded by scattering cross-section ) .. image-sg:: /gallery/tutorials/images/sphx_glr_coupling_model_002.png :alt: Scatterer Sampling Distribution :srcset: /gallery/tutorials/images/sphx_glr_coupling_model_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.671 seconds) .. _sphx_glr_download_gallery_tutorials_coupling_model.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: coupling_model.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: coupling_model.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: coupling_model.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_