GUI External Control - HenriquesLab/NanoJ-Fluidics GitHub Wiki

Micro-Manager

The GUI has been designed to be controlled through scripts as well as through the GUI. Several of the internal classes are marked as public, allowing developers easy access to most relevant functions. However, the simplest way to control is through a few convenience functions present in the GUI class. This section will show you how to send a few basic commands through BeanShell to the GUI.

Importing the GUI

To get access to the GUI in a BeanShell script, you have to import the package and get a reference to the instance:

import nanoj.pumpControl.java.sequentialProtocol.GUI;

seqProt = GUI.INSTANCE;

Once this is done, you can access several functions. Most of these return some form of String value that can be used for debugging.

Available functions

seqProt.startSequence()

Starts the entire sequence

seqProt.startSequence(int startingStep, int endingStep)

Starts just a portion of the sequence, e.g. from steps 2 to 4.

seqProt.stopSequence()

Stops the sequence.

seqProt.sequenceRunning()

Get whether the sequence is running or not as a boolean.

seqProt.getCurrentStep()

Get what is the current step (-1 if not running)

seqProt.stopAllPumps()

Stops all currently connected pump.

seqProt.stopPump(int pumpIndex)

Stops a specific pump (value from 1 to N connected pump). The index matches the dropdown menus in the GUI.

Simple example script

You can find the example script NanoJ-Fluidics.bsh in this folder. This is a basic example of BeanShell script for interfacing with NanoJ-Fluidics using the functions above.

Full example script used for unsupervised live-to-fixed acquisition

The example cellRoundingLive2Fix.bsh which was used to perform the experiments described in Fig. 2 / Supplementary Movie 2 of our paper, can be found here.

The code is currently capable of:

  • pre-pumps acquisition: time-course multi-channel multi-position imaging, with focus lock using PFS of the Nikon body on which it was developed. The multi-position can be set in the multi-dimension acquisition of micro-manager. The code will use these positions automatically.
  • detect cell rounding: in each field-of-view, cell rounding is detected by Otsu thresholding and calculation of the average circularity of all objects detected in the field-of-view.
  • trigger pump sequence: as pre-defined in the NanoJ-Fluidics GUI of micro-manager.
  • post-pumps acquisition: time-course multi-channel multi-position z-stack imaging, with focus lock using PFS of the Nikon body on which it was developed.
  • send email to the user: this allows the user to receive emails warning about the key steps of the acquisition: when only one field-of-view remains to detect cell rounding before triggering the pumps, when all the required fields-of-view have detected cell rounding, when the pumps are activating and when the complete experiment is completed.

The user-defined parameters are set between line 185 and line 227 of the code, as follows:

  • prePumpChannels: defines the channels acquired in the and the pre-pumps acquisition as well as order in which they are acquired in.
  • allExposuresPrePump: defines their respective exposure times.
  • timeIntervals: defines the number of seconds to wait between two consecutive time points. If the time necessary to acquire all the defined fields-of-view is longer than timeIntervals, then the acquisition will loop through the fields-of-view as quickly as possible.
  • nFramesMax: defines the maximum number of frames to acquire before triggering the pumps. This ensures that the experiment moves to the next stage even if sufficient cell rounding does not occur.
  • minFraction: define the minimum fraction of fields-of-view to detect cell rounding before triggering the pumps. For instance, if minFraction = 0.25, and 50 fields-of-view were defined, then a minimum of 13 fields-of-view need to detect cell rounding before triggering the pumps.
  • thresholdCircularity: defines the minimum average circularity in a specific field-of-view necessary for it to detect cell rounding. Exceeding this value once is sufficient for this field-of-view to be declared as having detected cell rounding.
  • channelNumberForAnalysis: defines which channel in the acquisition to use for event triggering detection (NB: this is 0-based, therefore the first channel is channel 0);
  • waitingPostImageTrigger: defines the amount of time to wait before activating the pumps once the event has triggered for a sufficient number of fields-of-view. During that waiting time, the pre-pumps acquisition carries on.
  • postPumpChannels and allExposuresPostPump: define channels and exposure times for the post-pumps acquisition.
  • timeIntervalsPostPump and nFramesPostPump: define the duration between time points and the number of time frames to acquire in the post-pumps acquisition.
  • dZ, nZposNegative and nZposPositive: defines the axial steps for the z-stack (in um), and the number of steps to take above and below the focus position defined for the field-of-view. The total number of slices acquired is then = nZposNegative + nZposPositive + 1.
  • acqName: defines the acquisition name, this is also used as the name of the folder in which the data will be saved.
  • rootDirName: defines the root directory where the data will be saved. This path must exist.
  • myEmailAddress: defines the email address to send the warning emails to during the acquisition.

The email capability is enabled if a file called pumpyEmailCredentials.txt is present the root directory of micro-manager, containing the email address and the password of the Gmail account used to send the email. An example of how a credential file may look like is provided here. Users wishing to use this functionality need to modify these to use their own Gmail account. For more information about how this is enabled here using JavaMail API, please find the info in this page.