cytoflowgui.import_dialog

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:

cytoflowgui.import_dialog.not_true(value)[source]
cytoflowgui.import_dialog.not_false(value)[source]
cytoflowgui.import_dialog.sanitize_metadata(meta)[source]

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.)

index

The tube index

file

The FCS filename

parent

Which model are we part of?

conditions

A Dict of the conditions (for hashing)

metadata

The FCS metadata

all_conditions_set

Do all of the conditions have a value?

conditions_hash()[source]

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

get_cell_color(obj)[source]
cytoflowgui.import_dialog.eval_bool(x)[source]

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()

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.

model

Which model are we a part of?

name

The name of the trait

type

What type of trait is it?

class cytoflowgui.import_dialog.ExperimentDialogModel[source]

Bases: traits.has_traits.HasStrictTraits

The model for the Experiment setup dialog.

tubes

T he list of Tubes (rows in the table)

tube_traits

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

tube_traits_dict

A dictionary of trait name –> TubeTrait instances

counter

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

valid

Are all the tubes unique and filled?

dummy_experiment

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

init(import_op)[source]

Initializes the model from a pre-existing ImportOp

update_import_op(import_op)[source]

Update an ImportOp with the information in this dialog

is_tube_unique(tube)[source]

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>
add_tubes

alias of traits.trait_types.Event

remove_tubes

alias of traits.trait_types.Event

add_variable

alias of traits.trait_types.Event

import_csv

alias of traits.trait_types.Event

selected_tubes

alias of traits.trait_types.List

table_editor = <traits.trait_types.Instance object>
updating = <traits.trait_types.Bool object>
init(info)[source]
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.

Parameters
  • 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.)

Returns

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

Return type

bool

closed(info, is_ok)[source]