peal.data.dataset_generators.StainingConfounderGenerator

class peal.data.dataset_generators.StainingConfounderGenerator[source]

Bases: object

Build a histology dataset whose confounder is the hematoxylin staining.

Converts the MUS and STR tissue classes of a raw NCT-CRC style folder to PNG, estimates the stain vectors of every image (Macenko-style OD/PCA estimation), measures the 99th-percentile intensity of hematoxylin-dominated pixels and splits at the median into weak/strong staining. Then 16000 samples are drawn so that class (Cancer: STR=1) and Confounder (strong staining) follow a fixed 2x2 pattern.

Parameters:
  • raw_data_dir (str) – Folder with MUS/ and STR/ image sub-folders.

  • dataset_origin_path – Stored but unused by generate_dataset.

  • delimiter – Stored but unused by generate_dataset.

  • num_samples – Stored but unused by generate_dataset.

  • dataset_name (str) – Output folder datasets/<dataset_name>.

Methods

generate_dataset

Convert the images, estimate staining and write data.csv.

__init__(raw_data_dir, dataset_origin_path='datasets', dataset_name='cancer_tissue_no_norm', delimiter=',', num_samples=40000)[source]

Store the paths; nothing is written until generate_dataset.

generate_dataset()[source]

Convert the images, estimate staining and write data.csv.

The csv columns are ImgPath,Cancer,Confounder,ConfounderStrength with ConfounderStrength the measured hematoxylin intensity. The output folder must not exist yet.