utils

cytominer_database.utils.collect_csvs(config, directory)[source]

Collect CSV files from a directory.

This function collects CSV files in a directory, excluding those that have been specified in the configuration file. This enables collecting only those CSV files that correspond to cellular compartments. e.g. Cells.csv, Cytoplasm.csv, Nuclei.csv. CSV files corresponding to experiment, image, or object will be excluded.

Parameters:
  • config – configuration file.
  • directory – directory containing the CSV files.
Returns:

a list of CSV files.

cytominer_database.utils.find_directories(directory)[source]

List subdirectories.

Parameters:directory – directory
Returns:list of subdirectories of directory
cytominer_database.utils.read_config(filename)[source]

Read a configuration file. A default config file is read first, and the values are overriden by those in the specified configuration file.

Parameters:filename – configuration filename
Returns:a configuration object
cytominer_database.utils.validate_csv(csvfile)[source]

Validate a CSV file.

The CSV file typically corresponds to either a measurement made on a compartment, e.g. Cells.csv, or on an image, e.g. Image.csv. The validation performed is generic - it simply checks for malformed CSV files.

This uses csvclean to check for validity of a CSV file.

Parameters:csvfile – CSV file to validate
Returns:True if valid, False otherwise.
cytominer_database.utils.validate_csv_set(config, directory)[source]

Validate a set of CSV files.

This function validates a set of CSV files in a directory. These CSV files correspond to measurements made on different cellular compartments, e.g. Cells.csv, Cytoplasm.csv, Nuclei.csv. An Image.csv file, corresponding to measurements made on the whole image, along with metadata, is also typically present.

Parameters:
  • config – configuration file - this contains the set of CSV files to validate.
  • directory – directory containing the CSV files.
Returns:

a tuple where the first element is the list of compartment CSV files, the second is the image CSV file.