A modal dialog that allows the user to set up their experiment, mapping FCS files to experimental conditions.

There are a few main classes:

  • Tube – represents one tube (well, an FCS file) in an experiment – the filename and its metadata.

  • TubeTrait – represents one trait (the trait type and name)

  • ExperimentDialogModel – the tabular model of tubes, traits, and trait values

  • ExperimentDialogHandler – the controller which contains the view and the logic for connecting it to the model.

Additionally, there are several utility functions and classes:


replaces all non-Python-safe characters in a tube’s metadata with ‘_’

class cytoflowgui.import_dialog.Tube[source]

Bases: traits.has_traits.HasStrictTraits

The model for a tube in an experiment.

I originally wanted to make the Tube in the ImportDialog and the Tube in the ImportOp the same, but that fell apart when I tried to implement serialization (dynamic traits don’t survive pickling when sending tubes to the remote process) (well, their values do, but neither the trait type nor the metadata do.)

Oh well.

This model depends on duck-typing (“if it walks like a duck, and quacks like a duck…”). Because we want to use all of the TableEditor’s nice features, each row needs to be an instance, and each column a Trait. So, each Tube instance represents a single tube, and each experimental condition (as well as the tube name, its file, and optional plate row and col) are traits. These traits are dynamically added to Tube INSTANCES (NOT THE TUBE CLASS.) Then, we add appropriate columns to the table editor to access these traits.

We also derive traits from tubes’ FCS metadata. One can make a new column from metadata, then convert it into a condition to use in the analysis.

We also use the “transient” flag to specify traits that shouldn’t be displayed in the editor. This matches well with the traits that every HasTraits-derived class has by default (all of which are transient.)


The tube index


The FCS filename


Which model are we part of?


A Dict of the conditions (for hashing)


The FCS metadata


Do all of the conditions have a value?


Return a hash of this tube’s conditions (for equality testing)

class cytoflowgui.import_dialog.ExperimentColumn(*args: Any, **kwargs: Any)[source]

Bases: traitsui.table_column.ObjectColumn

A traitsui.table_column.ObjectColumn with setable color


Evaluate “f”, “false”, “n” or “no” as False; and “t”, “true”, “y” or “yes” as True

class cytoflowgui.import_dialog.ConvertingBool(default_value=<traits.trait_type._NoDefaultSpecifiedType object>, **metadata)[source]

Bases: traits.trait_types.BaseCBool

A trait that converts “f”, “false”, “n”, or “no” to False and “t”, “true”, “y” or “yes” to True


Evaluate “f”, “false”, “n” or “no” as False; and “t”, “true”, “y” or “yes” as True

validate(_, name, value)[source]

Validates that a specified value is valid for this trait.

Note: The ‘fast validator’ version performs this check in C.

class cytoflowgui.import_dialog.TubeTrait[source]

Bases: traits.has_traits.HasStrictTraits

A class representing a trait on a tube. A trait has an underlying traits.trait_type.TraitType, a name, a type (“metadata”, “category”, “float” or “bool”), and a default view.


Which model are we a part of?


The name of the trait


What type of trait is it?

class cytoflowgui.import_dialog.ExperimentDialogModel[source]

Bases: traits.has_traits.HasStrictTraits

The model for the Experiment setup dialog.


T he list of Tubes (rows in the table)


A list of the traits that have been added to Tube instances (columns in the table)


A dictionary of trait name –> TubeTrait instances


A dictionary of tube hash –> # of tubes with that hash; keeps track of whether a tube is unique or not


Are all the tubes unique and filled?


A dummy Experiment, with the first Tube and no events, so we can check subsequent tubes for voltage etc. and fail early.


Initializes the model from a pre-existing ImportOp


Update an ImportOp with the information in this dialog


Is a tube unique?

class cytoflowgui.import_dialog.ExperimentDialogHandler(*args: Any, **kwargs: Any)[source]

Bases: traitsui.api.Controller

A controller that contains the import dialog’s view and the logic that connects it to the ExperimentDialogModel

import_op = <traits.trait_types.Instance object>

alias of traits.trait_types.Event


alias of traits.trait_types.Event


alias of traits.trait_types.Event


alias of traits.trait_types.Event


alias of traits.trait_types.List

table_editor = <traits.trait_types.Instance object>
updating = <traits.trait_types.Bool object>
close(info, is_ok)[source]

Handles the user attempting to close a dialog-based user interface.

This method is called when the user attempts to close a window, by clicking an OK or Cancel button, or clicking a Close control on the window). It is called before the window is actually destroyed. Override this method to perform any checks before closing a window.

While Traits UI handles “OK” and “Cancel” events automatically, you can use the value of the is_ok parameter to implement additional behavior.

  • info (UIInfo object) – The UIInfo object associated with the view

  • is_ok (Boolean) – Indicates whether the user confirmed the changes (such as by clicking OK.)


allow_close – A Boolean, indicating whether the window should be allowed to close.

Return type


closed(info, is_ok)[source]