.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/extras/continuous_acquisition.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_extras_continuous_acquisition.py: WorkFlow ======== This script simulates flow cytometer signals using the `FlowCytometer` class and analyzes the results using the `PulseAnalyzer` class from the FlowCyPy library. The signals generated (forward scatter and side scatter) provide insights into the physical properties of particles passing through the laser beam. Workflow: --------- 1. Define a particle diameter distribution using `ScattererCollection`. 2. Simulate flow cytometer signals using `FlowCytometer`. 3. Analyze the forward scatter signal with `PulseAnalyzer` to extract features like peak height, width, and area. 4. Visualize the generated signals and display the extracted pulse features. .. GENERATED FROM PYTHON SOURCE LINES 18-19 Step 1: Import necessary modules from FlowCyPy .. GENERATED FROM PYTHON SOURCE LINES 19-26 .. code-block:: Python from FlowCyPy import FlowCytometer, ScattererCollection, Detector, GaussianBeam, TransimpedanceAmplifier from FlowCyPy.flow_cell import FlowCell from FlowCyPy import distribution from FlowCyPy.population import Sphere from FlowCyPy.signal_digitizer import SignalDigitizer from FlowCyPy import units .. GENERATED FROM PYTHON SOURCE LINES 27-30 Step 2: Define the laser source ------------------------------- Set up a laser source with a wavelength of 1550 nm, optical power of 200 mW, and a numerical aperture of 0.3. .. GENERATED FROM PYTHON SOURCE LINES 30-36 .. code-block:: Python source = GaussianBeam( numerical_aperture=0.3 * units.AU, # Numerical aperture: 0.3 wavelength=800 * units.nanometer, # Laser wavelength: 800 nm optical_power=20 * units.milliwatt # Optical power: 20 milliwatts ) .. GENERATED FROM PYTHON SOURCE LINES 37-40 Step 3: Define flow parameters ------------------------------ Set the flow speed to 80 micrometers per second and a flow area of 1 square micrometer, with a total simulation time of 1 second. .. GENERATED FROM PYTHON SOURCE LINES 40-47 .. code-block:: Python flow_cell = FlowCell( sample_volume_flow=0.02 * units.microliter / units.second, # Flow speed: 10 microliter per second sheath_volume_flow=0.1 * units.microliter / units.second, # Flow speed: 10 microliter per second width=20 * units.micrometer, # Flow area: 10 x 10 micrometers height=10 * units.micrometer, # Flow area: 10 x 10 micrometers ) .. GENERATED FROM PYTHON SOURCE LINES 48-52 Step 4: Define the particle diameter distribution ------------------------------------------------- Use a normal diameter distribution with a mean diameter of 200 nanometers and a standard deviation of 10 nanometers. This represents the population of scatterers (particles) that will interact with the laser source. .. GENERATED FROM PYTHON SOURCE LINES 52-133 .. code-block:: Python ev_diameter = distribution.Normal( mean=200 * units.nanometer, # Mean particle diameter: 200 nanometers std_dev=10 * units.nanometer # Standard deviation: 10 nanometers ) ev_ri = distribution.Normal( mean=1.39 * units.RIU, # Mean refractive index: 1.39 std_dev=0.01 * units.RIU # Standard deviation: 0.01 ) ev = Sphere( particle_count=10 * units.particle, diameter=ev_diameter, # Particle diameter distribution refractive_index=ev_ri, # Refractive index distribution name='EV' # Name of the particle population: Extracellular Vesicles (EV) ) scatterer_collection = ScattererCollection() scatterer_collection.add_population(ev) # Step 5: Define the detector # --------------------------- # The detector captures the scattered light. It is positioned at 90 degrees relative to the incident light beam # and configured with a numerical aperture of 0.4 and responsivity of 1. digitizer = SignalDigitizer( bit_depth=1024, saturation_levels='auto', sampling_rate=1 * units.megahertz, # Sampling frequency: 1 MHz ) detector_0 = Detector( phi_angle=90 * units.degree, # Detector angle: 90 degrees (Side Scatter) numerical_aperture=0.4 * units.AU, # Numerical aperture of the detector name='first detector', # Detector name responsivity=1 * units.ampere / units.watt, # Responsitivity of the detector (light to signal conversion efficiency) ) detector_1 = Detector( phi_angle=0 * units.degree, # Detector angle: 90 degrees (Sid e Scatter) numerical_aperture=0.4 * units.AU, # Numerical aperture of the detector name='second detector', # Detector name responsivity=1 * units.ampere / units.watt, # Responsitivity of the detector (light to signal conversion efficiency) ) transimpedance_amplifier = TransimpedanceAmplifier( gain=100 * units.volt / units.ampere, bandwidth = 10 * units.megahertz ) # Step 6: Simulate Flow Cytometer Signals # --------------------------------------- # Create a FlowCytometer instance to simulate the signals generated as particles pass through the laser beam. cytometer = FlowCytometer( source=source, transimpedance_amplifier=transimpedance_amplifier, digitizer=digitizer, scatterer_collection=scatterer_collection, flow_cell=flow_cell, # Particle diameter distribution detectors=[detector_0, detector_1] # List of detectors used in the simulation ) # Run the flow cytometry simulation cytometer.prepare_acquisition(run_time=0.2 * units.millisecond) acquisition = cytometer.get_acquisition() # Visualize the scatter signals from both detectors acquisition.plot() digital_signals = acquisition.digitalize(digitizer=digitizer) digital_signals.plot() """ Summary: -------- This script simulates flow cytometer signals, processes them to detect peaks in the forward scatter channel, and extracts important features. The process is visualized through signal plots, and key properties are displayed. """ .. rst-class:: sphx-glr-horizontal * .. image-sg:: /gallery/extras/images/sphx_glr_continuous_acquisition_001.png :alt: continuous acquisition :srcset: /gallery/extras/images/sphx_glr_continuous_acquisition_001.png :class: sphx-glr-multi-img * .. image-sg:: /gallery/extras/images/sphx_glr_continuous_acquisition_002.png :alt: continuous acquisition :srcset: /gallery/extras/images/sphx_glr_continuous_acquisition_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none /opt/hostedtoolcache/Python/3.11.12/x64/lib/python3.11/site-packages/FlowCyPy/source.py:269: 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.12/x64/lib/python3.11/site-packages/FlowCyPy/source.py:269: 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') '\nSummary:\n--------\nThis script simulates flow cytometer signals, processes them to detect peaks in the forward scatter channel,\nand extracts important features. The process is visualized through signal plots, and key properties are displayed.\n' .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.046 seconds) .. _sphx_glr_download_gallery_extras_continuous_acquisition.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: continuous_acquisition.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: continuous_acquisition.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: continuous_acquisition.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_