Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(api): liquid presence verification #15695

Merged
merged 60 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
799ee29
Test push
jwwojak Jul 9, 2024
827e28c
Removing test text, not important
jwwojak Jul 9, 2024
5116a9c
Edit LPD argument definition.
jwwojak Jul 10, 2024
e3fd8fd
H2 LLD section summary
jwwojak Jul 12, 2024
af41076
LLD intro and global method
jwwojak Jul 12, 2024
d429836
Adding link to drop_tip
jwwojak Jul 12, 2024
2fdc24e
Turning global LLD off
jwwojak Jul 12, 2024
2363e91
End of day save
jwwojak Jul 12, 2024
608a71e
Update loading.rst
jwwojak Jul 15, 2024
a491e76
Fix shortened API reference
jwwojak Jul 15, 2024
b96d9dd
Fixing code formatting
jwwojak Jul 15, 2024
3f797a7
End 'o day commit, will shorten code example
jwwojak Jul 15, 2024
48ae5d5
Main part decent draft
jwwojak Jul 16, 2024
7b1fe38
Small changes
jwwojak Jul 16, 2024
51d21fb
Removed text, added version macro
jwwojak Jul 17, 2024
5db9dd0
Saving because I haven't yet
jwwojak Jul 17, 2024
5677a16
Building block commands: detect & require
jwwojak Jul 17, 2024
ec25699
Misspellings in commented text
jwwojak Jul 17, 2024
1bfff50
More revisions
jwwojak Jul 17, 2024
8cb74dd
Updating LPV intro - stress Flex only
jwwojak Jul 17, 2024
f786e59
detect_ and require_ revisions
jwwojak Jul 18, 2024
bb661f1
Reviewer changes and feature name change
jwwojak Jul 24, 2024
5920bad
Small intro changes and to some how it works text
jwwojak Jul 24, 2024
a4f7577
Explain using LLD requires extra time to execute
jwwojak Jul 24, 2024
12f34e5
Not ready yet. More TK Monday.
jwwojak Jul 26, 2024
c6a6fde
Shorten code sample, revise explanation
jwwojak Jul 29, 2024
d8b5d7f
Test push
jwwojak Jul 9, 2024
dbb62f9
Removing test text, not important
jwwojak Jul 9, 2024
6aeb47d
Edit LPD argument definition.
jwwojak Jul 10, 2024
b6d3160
H2 LLD section summary
jwwojak Jul 12, 2024
b38a289
LLD intro and global method
jwwojak Jul 12, 2024
e40a07b
Adding link to drop_tip
jwwojak Jul 12, 2024
2fcc41c
Turning global LLD off
jwwojak Jul 12, 2024
07fddd3
End of day save
jwwojak Jul 12, 2024
00aaf91
Update loading.rst
jwwojak Jul 15, 2024
3292b61
Fix shortened API reference
jwwojak Jul 15, 2024
8560aa2
Fixing code formatting
jwwojak Jul 15, 2024
29b0dc7
End 'o day commit, will shorten code example
jwwojak Jul 15, 2024
bb36fa3
Main part decent draft
jwwojak Jul 16, 2024
883ed72
Small changes
jwwojak Jul 16, 2024
0710757
Removed text, added version macro
jwwojak Jul 17, 2024
8031d97
Saving because I haven't yet
jwwojak Jul 17, 2024
458d46a
Building block commands: detect & require
jwwojak Jul 17, 2024
16b50c5
Misspellings in commented text
jwwojak Jul 17, 2024
9e1b8b6
More revisions
jwwojak Jul 17, 2024
c4f0012
Updating LPV intro - stress Flex only
jwwojak Jul 17, 2024
ab42190
detect_ and require_ revisions
jwwojak Jul 18, 2024
a283b30
Reviewer changes and feature name change
jwwojak Jul 24, 2024
378c96b
Small intro changes and to some how it works text
jwwojak Jul 24, 2024
fd5b72e
Explain using LLD requires extra time to execute
jwwojak Jul 24, 2024
6a17891
Not ready yet. More TK Monday.
jwwojak Jul 26, 2024
36aea23
Shorten code sample, revise explanation
jwwojak Jul 29, 2024
b4352ae
Merge branch 'docs-liquid-presence-detection' of https://github.com/O…
jwwojak Jul 30, 2024
7f4ffbe
add behavior in simulation to API ref entries
ecormany Aug 2, 2024
28fb7ae
Apply suggestions from code review
jwwojak Aug 8, 2024
5cd4ae0
Revisions from reviewers
jwwojak Aug 8, 2024
0e7d19c
Another round of reviewer comments and changes
jwwojak Aug 12, 2024
7f993b2
Removed code sample, revise method text
jwwojak Aug 13, 2024
9ef431d
More reviewer changes
jwwojak Aug 15, 2024
c4106bf
review and edits
ecormany Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions api/docs/v2/basic_commands/liquids.rst
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,68 @@ This example aspirates enough air to fill the remaining volume in a pipette::

.. versionadded:: 2.0

.. _detect-liquid-presence:

Detect Liquids
==============

The :py:meth:`.InstrumentContext.detect_liquid_presence` method tells a Flex pipette to check for the presence of a liquid in a wellplate or reservoir. This method returns ``True`` if the pressure sensors in a pipette detect a liquid and ``False`` if the sensors do not. It will not raise an error or stop your protocol when the robot detects and empty well. Detection takes place during aspiration, but you don't need to aspirate to use ``detect_liquid_presence``. It's a standalone method that can be called when you just want to detect liquids only. See also :ref:`lpd`.
jwwojak marked this conversation as resolved.
Show resolved Hide resolved

.. code-block:: python

pipette.detect_liquid_presence()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a well argument.


In cases where you need records that are more informative than ``true`` or ``false``, you can write your own code to handle the output of this method. For example, by adding some indexing along with ``for`` and ``while`` loops, your protocol could count how many aspirations a robot performed before a source well ran out of liquid. Here's one way to do this in the ``run():`` function of our Flex :ref:`protocol template <protocol-template>`:

.. code-block:: python
ecormany marked this conversation as resolved.
Show resolved Hide resolved

tip_index = 0 # tracks how many tips are used.
plate_index = 0 # tracks the wells dispensed to. Increments after dispense.

for name, well in reservoir.items():
pipette.pick_up_tip(tiprack[tipIndex])
has_liquid = pipette.detect_liquid_presence(well)
pipette.drop_tip(trash)
tip_index+=1

cur_index = 0 # counts aspirate/dispense cycles from a reservoir well.
while has_liquid:
pipette.pick_up_tip(tiprack[tipIndex])
pipette.aspirate(250, well)
pipette.dispense(250, plate[plateIndex])
pipette.drop_tip(trash)
tip_index+=1
plate_index+=1

pipette.pick_up_tip(tiprack[tipIndex])
has_liquid = pipette.detect_liquid_presence(well)
pipette.drop_tip(trash)
tip_index+=1

cur_index+=1

# Add a helpful record to the run log when a well runs dry or is empty.
protocol.comment(
f"Found liquid and aspirated from well {name} {curIndex} times. Well is now empty."
)

# Add a helpful record to the run log when all source wells are empty.
protocol.comment("Exhausted all wells in reservoir.")

Now the Flex records an entry in the run log that includes the well's name (e.g. ``A1``, ``A2``, ``B1`` etc.) and how many times the pipette aspirated from that well before it ran dry. If a protocol uses all the liquid in its source wells, the robot records that too.

.. versionadded:: 2.20

.. _require-liquid-presence:

Require Liquids
===============

The :py:meth:`.InstrumentContext.require_liquid_presence` method tells a Flex pipette to check for and require a liquid in a well or reservoir. This method returns ``True`` if the pressure sensors in a pipette detect a liquid and ``False`` if liquid if the sensors do not. When the robot does not detect liquid, it raises an error, stops the protocol to let you resolve the problem, and writes a warning to the run log.
Detection takes place during aspiration, but you don't need to aspirate to use ``require_liquid_presence``. It's a standalone method that can be called when you want to detect liquids only. See also :ref:`lpd`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, you should call this with a fresh tip and before aspiration.

And the cross-reference can be strengthened to indicate that it links to instructions on how to perform this automatically for all aspirations on a given pipette.


.. code-block:: python

pipette.require_liquid_presence()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a well argument.


.. versionadded:: 2.20
71 changes: 71 additions & 0 deletions api/docs/v2/pipettes/loading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,74 @@ Another example is a Flex protocol that uses a waste chute. Say you want to only
.. versionadded:: 2.0
.. versionchanged:: 2.16
Added support for ``TrashBin`` and ``WasteChute`` objects.

.. _lpd:

Liquid Presence Detection
=========================

Liquid Presence Detection is a pressure-based feature that allows Opentrons Flex pipettes to detect the presence or absence of liquids in a well, reservoir, or other container. Liquid Presence Detection gives you the ability to identify, avoid, and recover from liquid-related protocol errors. You can enable this feature for an entire protocol run or toggle it on and off as required. Liquid Presence Detection works with Flex pipettes only and is disabled by default.
ecormany marked this conversation as resolved.
Show resolved Hide resolved

.. note::
If your protocol uses :ref:`partial tip pickup <partial-tip-pickup>`, the pressure sensors for the Flex 8-Channel pipette are on channels 1 and 8. For the Flex 96-Channel Pipette, the pressure sensors are on channels 1 and 96.
jwwojak marked this conversation as resolved.
Show resolved Hide resolved

.. versionadded:: 2.20
ecormany marked this conversation as resolved.
Show resolved Hide resolved

.. Ed: Enabling instead of Enable?

Enable Liquid Presence Detection
--------------------------------
ecormany marked this conversation as resolved.
Show resolved Hide resolved

The easiest, and recommended, way to use Liquid Presence Detection is by adding the optional Boolean argument, ``liquid_presence_detection=True`` to :py:meth:`.ProtocolContext.load_instrument` in your protocol. When ``True``, the robot will check for liquid on every aspiration. You can also turn this feature off and back on again later in a protocol. This example adds Liquid Presence Detection to the 8-Channel Pipette used in the sample protocol at the top of the page.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Not recommended, because of how time-consuming it is.
  • Remove comma after "argument" since the monospace formatting does the work (and this isn't an appositive).
  • Last sentence, probably better to say "enables…for" instead of "adds…to"


.. code-block:: python

right = protocol.load_instrument(
instrument_name="flex_8channel_1000",
mount="right",
tip_racks=[tiprack2],
liquid_presence_detection=True
)

.. note::
Accurate liquid detection requires fresh, dry pipette tips. Protocols using this feature must discard used tips after an aspirate/dispense cycle and pick up new tips before the next cycle. The API will raise an error if liquid detection is active and your protocol attempts to reuse a pipette tip or if the robot thinks the tip is wet.

Let's take a look at how all this works. First, tell the robot to pick up a new, clean tip::

pipette.pick_up_tip(tiprack2)

Next, tell the robot to aspirate and dispense some liquid from the reservoir::

pipette.aspirate(100, reservoir["A1"])
pipette.dispense(100, plate["A1"])
ecormany marked this conversation as resolved.
Show resolved Hide resolved

Liquid detection takes place immediately prior to aspiration. Upon detecting a liquid, the pipette stops, raises itself above the liquid's surface, and then aspirates according to your protocol. Checking for a liquid adds time to your protocol run, so be aware of that before you use it. When the robot doesn't detect liquid during an aspiration, it raises an error and stops the protocol until the problem is resolved.

.. versionadded:: 2.20

Turning Liquid Presence Detection Off and On
---------------------------------------------

You can turn Liquid Presence Detection off and on throughout a protocol. To turn it off, set ``pipette.liquid_presence_detection=False`` at the point in a protocol where it needs to be disabled, usually between picking up a new tip and aspirating a liquid. This overrides the global argument, ``liquid_presence_detection=True`` that we set on :py:meth:`~.ProtocolContext.load_instrument`. Let's try this starting after picking up a new tip.

.. code-block:: python

pipette.pick_up_tip(tiprack2)
pipette.liquid_presence_detection=False #Liquid Presence Detection off
pipette.aspirate(100, reservoir["A2"])
jwwojak marked this conversation as resolved.
Show resolved Hide resolved

Going forward, the pipette will not perform a liquid check until you turn this feature back on.

To reactivate, add ``pipette.liquid_presence_detection=True`` at the point later in a protocol where it needs to be enabled, usually between picking up a new tip and aspirating a liquid.
jwwojak marked this conversation as resolved.
Show resolved Hide resolved

.. code-block:: python

pipette.pick_up_tip(tiprack2)
pipette.liquid_presence_detection=True #Liquid Presence Detection on again
pipette.aspirate(100, reservoir["A3"])
jwwojak marked this conversation as resolved.
Show resolved Hide resolved

The robot will continue to check for a liquid until this feature is disabled again, or an empty well is detected (and the robot raises an error), or the protocol completes.

See also :ref:`detect-liquid-presence` and :ref:`require-liquid-presence`.
ecormany marked this conversation as resolved.
Show resolved Hide resolved

.. versionadded:: 2.20
8 changes: 4 additions & 4 deletions api/src/opentrons/protocol_api/instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,8 @@ def pick_up_tip( # noqa: C901
# in which self.starting_tip consumes tips. It would currently vary
# depending on the configuration layout of a pipette at a given
# time, which means that some combination of starting tip and partial
# configuraiton are incompatible under the current understanding of
# starting tip behavior. Replacing starting_tip with an undeprecated
# configuration are incompatible under the current understanding of
# starting tip behavior. Replacing starting_tip with an un-deprecated
# Labware.has_tip may solve this.
raise CommandPreconditionViolated(
"Automatic tip tracking is not available when using a partial pipette"
Expand Down Expand Up @@ -2120,7 +2120,7 @@ def configure_nozzle_layout( # noqa: C901

@requires_version(2, 20)
def detect_liquid_presence(self, well: labware.Well) -> bool:
"""Check if there is liquid in a well.
"""Checks if there is liquid in a well. Will not raise an error if it does not detect liquid. Flex pipettes only. See :ref:`lpd` and :ref:`detect-liquid-presence`.
jwwojak marked this conversation as resolved.
Show resolved Hide resolved

:returns: A boolean.
Copy link
Contributor

@ecormany ecormany Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove line 2125, or move the prose description of the values of true and false here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will move the longer, prose description to :returns: (line 2125).

"""
Expand All @@ -2130,7 +2130,7 @@ def detect_liquid_presence(self, well: labware.Well) -> bool:

@requires_version(2, 20)
def require_liquid_presence(self, well: labware.Well) -> None:
"""If there is no liquid in a well, raise an error.
"""Checks for liquid in a well. Raises an error if no liquid is detected. Flex pipettes only. See :ref:`lpd` and :ref:`require-liquid-presence`.
jwwojak marked this conversation as resolved.
Show resolved Hide resolved

:returns: None.
ecormany marked this conversation as resolved.
Show resolved Hide resolved
"""
Expand Down
4 changes: 3 additions & 1 deletion api/src/opentrons/protocol_api/protocol_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,9 @@ def load_instrument(
control <advanced-control>` applications. You cannot
replace an instrument in the middle of a protocol being run
from the Opentrons App or touchscreen.
:param bool liquid_presence_detection: If ``True``, enable liquid presence detection for instrument. Only available on Flex robots in API Version 2.20 and above.
:param bool liquid_presence_detection: If ``True``, enables liquid presence detection for Flex 1-, 8-, or 96-channel pipettes. See :ref:`lpd`.
jwwojak marked this conversation as resolved.
Show resolved Hide resolved

.. versionadded:: 2.20
"""
instrument_name = validation.ensure_lowercase_name(instrument_name)
checked_instrument_name = validation.ensure_pipette_name(instrument_name)
Expand Down
Loading