Welcome to pythologist-reader’s documentation!

Modules

class pythologist_reader.CellProjectGeneric(h5path, mode='r')[source]
append_sample(sample)[source]

Append sample to the project

Parameters

sample (CellSampleGeneric) – sample object

property cdf

Return the pythologist.CellDataFrame of the project

property channel_image_dataframe

dataframe within info about channels and images

frame_iter()[source]

An interator of CellFrameGeneric

get_image(sample_id, frame_id, image_id)[source]

Get an image by sample frame and image id

Parameters
  • sample_id (str) – unique sample id

  • frame_id (str) – unique frame id

  • image_id (str) – unique image id

Returns

2d image array

Return type

numpy.array

get_sample(sample_id)[source]

Get the sample_id

Parameters

sample_id (str) – set the sample id

property id

Returns the (str) UUID4 string

property key

Get info about the project

property microns_per_pixel

Return or set the (float) microns_per_pixel

property project_name

Return or set the (str) project_name

qc(*args, **kwargs)[source]
Returns

QC class to do quality checks

Return type

QC

property sample_ids

Return the list of sample_ids

sample_iter()[source]

An interator of CellSampleGeneric

set_id(name)[source]

Set the project ID

Parameters

name (str) – project_id

class pythologist_reader.formats.inform.sets.CellProjectInForm(h5path, mode='r')[source]
property gates

Get all the gates from the frames / samples in the project

qc(*args, **kwargs)[source]

Returns: QC: QC class to do quality checks

read_path(path, project_name=None, sample_name_index=None, channel_abbreviations=None, verbose=False, require=True, require_score=True, skip_segmentation_processing=False, microns_per_pixel=None, **kwargs)[source]

Read in the project folder

Parameters
  • path (str) – location of the project directory

  • project_name (str) – name of the project

  • sample_name_index (int) – where in the directory chain is the foldername that is the sample name if not set use full path. -1 is last directory

  • channel_abbreviations (dict) – dictionary of shortcuts to translate to simpler channel names

  • verbose (bool) – if true print extra details

  • require (bool) – if true (default), require that channel componenet image be present

  • require_score (bool) – if true (default), require there be a score file in the data

  • skip_segmentation_processing (bool) – if false (default), it will store the cellmap and edgemap images, if true, it will skip these steps to save time but downstream applications will not be able to generate the cell-cell contact measurements or segmentation images.

  • microns_per_pixel (float) – conversion factor

class pythologist_reader.formats.inform.custom.CellProjectInFormCustomMask(h5path, mode='r')[source]

Read in a project that has a region set by a custon hand drawn area

Accessed via read_path with the additonal parameters

read_path(*args, **kwargs)[source]

Read in the project folder

Parameters
  • path (str) – location of the project directory

  • project_name (str) – name of the project

  • sample_name_index (int) – where in the directory chain is the foldername that is the sample name if not set use full path. -1 is last directory

  • channel_abbreviations (dict) – dictionary of shortcuts to translate to simpler channel names

  • verbose (bool) – if true print extra details

  • require (bool) – if true (default), require that channel componenet image be present

  • skip_segmentation_processing (bool) – if false (default), it will store the cellmap and edgemap images, if true, it will skip these steps to save time but downstream applications will not be able to generate the cell-cell contact measurements or segmentation images.

  • microns_per_pixel (float) – conversion factor

  • custom_mask_name (str) – the mask name that will end in <maskname>.tif

  • other_mask_name (str) – what you want to call areas not contained in your custom mask

class pythologist_reader.formats.inform.custom.CellProjectInFormLineArea(h5path, mode='r')[source]

Read in a project that has a region set by a custon hand drawn area, and a margin set by a line

Accessed via read_path with the additonal parameters

read_path(*args, **kwargs)[source]

Read in the project folder

Parameters
  • path (str) – location of the project directory

  • project_name (str) – name of the project

  • sample_name_index (int) – where in the directory chain is the foldername that is the sample name if not set use full path. -1 is last directory

  • channel_abbreviations (dict) – dictionary of shortcuts to translate to simpler channel names

  • verbose (bool) – if true print extra details

  • require (bool) – if true (default), require that channel componenet image be present

  • require_score (bool) – if true (default), require that score be present

  • skip_segmentation_processing (bool) – if false (default), it will store the cellmap and edgemap images, if true, it will skip these steps to save time but downstream applications will not be able to generate the cell-cell contact measurements or segmentation images.

  • microns_per_pixel (float) – conversion factor

  • steps (int) – how many pixels out from the hand drawn line to consider the margin

class pythologist_reader.formats.inform.immunoprofile.CellProjectInFormImmunoProfile(*argv, **kwargs)[source]

Read an ImmunoProfile sample

add_sample_path(path, sample_name=None, export_names=['FOXP3', 'PD1_PDL1'], channel_abbreviations={'Foxp3 (Opal 570)': 'FOXP3', 'PD-1 (Opal 620)': 'PD1', 'PD-L1 (Opal 520)': 'PDL1'}, verbose=False, microns_per_pixel=0.496, invasive_margin_width_microns=40, invasive_margin_drawn_line_width_pixels=10, skip_margin=False, skip_segmentation_processing=False, skip_all_regions=False, deidentify=False, **kwargs)[source]

Read add a sample in as single project folder and add it to the CellProjectInFormImmunoProfile

such as IP-99-A00001:

IP-99-A00001/
└── INFORM_ANALYSIS
├── FOXP3
├── GIMP
└── PD1_PDL1
Parameters
  • path (str) – location of the project directory

  • sample_name (str) – name of the immunoprofile sample (default: rightmost directory in path), can be overridden by ‘deidenitfy’ set to True .. results in the uuid4 for the sample being used

  • export_names (list) – specify the names of the exports to read

  • channel_abbreviations (dict) – dictionary of shortcuts to translate to simpler channel names

  • verbose (bool) – if true print extra details

  • microns_per_pixel (float) – conversion factor

  • invasive_margin_width_microns (int) – size of invasive margin in microns

  • invasive_margin_drawn_line_width_pixels (int) – size of the line drawn for invasive margins in pixels

  • skip_margin (bool) – if false (default) read in margin line and define a margin acording to steps. if true, only read a tumor and stroma.

  • skip_segmentation_processing (bool) – if false (default) read segementations, else skip to run faster

  • deidentify (bool) – if false (default) use sample names and frame names derived from the folders. If true use the uuid4s.

Returns

sample_id, sample_name (tuple) returns the uuid4 assigned as the sample_id, and the sample_name that were given to this sample that was added

class pythologist_reader.formats.inform.immunoprofile.CellSampleInFormImmunoProfile[source]
read_path(path, sample_name=None, channel_abbreviations=None, verbose=False, require=True, require_score=True, steps=76, skip_margin=False, skip_segmentation_processing=False, skip_all_regions=False, export_names=[], deidentify=False)[source]

Read in the project folder

Parameters
  • path (str) – location of the project directory

  • project_name (str) – name of the project

  • sample_name_index (int) – where in the directory chain is the foldername that is the sample name if not set use full path. -1 is last directory

  • channel_abbreviations (dict) – dictionary of shortcuts to translate to simpler channel names

  • verbose (bool) – if true print extra details

  • require (bool) – if true (default), require that channel componenet image be present

  • require_score (bool) – if true (default), require that score file be present

  • skip_segmentation_processing (bool) – if false (default), it will store the cellmap and edgemap images, if true, it will skip these steps to save time but downstream applications will not be able to generate the cell-cell contact measurements or segmentation images.

  • microns_per_pixel (float) – conversion factor

class pythologist_reader.CellSampleGeneric[source]
property cdf

Return the pythologist.CellDataFrame of the sample

property frame_ids

Return the list of frame IDs

frame_iter()[source]

An iterator of frames

Returns

CellFrameGeneric

get_frame(frame_id)[source]
Parameters

frame_id (str) – the ID of the frame you want to access

Returns

the cell frame

Return type

CellFrameGeneric

property id

Return the UUID4 str

property key

Return a pandas.DataFrame of info about the sample

class pythologist_reader.CellFrameGeneric[source]

A generic CellFrameData object

binary_calls()[source]

Return all the binary feature calls (alias)

property cdf

Return the pythologist.CellDataFrame of the frame

cell_map()[source]

Return a dataframe of cell ID’s and locations

cell_map_image()[source]

Return a the image of cells by ID’s

edge_map()[source]

Return a dataframe of cells by ID’s of coordinates only on the edge of the cells

edge_map_image()[source]

Return an image of edges of integers by ID

get_channels(all=False)[source]

Return a dataframe of the Channels

Parameters

all (bool) – default False if all is set to true will also include excluded channels (like autofluoresence)

Returns

channel information

Return type

pandas.DataFrame

get_data(table_name)[source]

Get the data table

Parameters

table_name (pandas.DataFrame) – the table you access by name

get_image(image_id)[source]
Parameters

image_id (str) – get the image by this id

Returns

an image representing a 2d array

Return type

numpy.array

get_raw(feature_label, statistic_label, all=False, channel_abbreviation=True)[source]

Get the raw data

Parameters
  • feature_label (str) – name of the feature

  • statistic_label (str) – name of the statistic to extract

  • all (bool) – default False if True put out everything including excluded channels

  • channel_abbreviation (bool) – default True means use the abbreivations if available

Returns

the dataframe

Return type

pandas.DataFrame

property id

Returns the project UUID4

interaction_map()[source]
Returns

return a dataframe of which cells are in contact with one another

Return type

pandas.DataFrame

phenotype_calls()[source]

Return all the binary feature calls

property processed_image

Returns (numpy.array) of the processed_image

property processed_image_id

Returns (str) id of the frame object

segmentation_info()[source]

Return a dataframe with info about segmentation like cell areas and circumferences

set_data(table_name, table)[source]

Set the data table

Parameters
  • table_name (str) – the table name

  • table (pd.DataFrame) – the input table

set_interaction_map(touch_distance=1)[source]

Measure the cell-cell contact interactions

Parameters

touch_distance (int) – optional default is 1 distance to look away from a cell for another cell

set_processed_image_id(image_id)[source]
Parameters

image_id (str) – set the id of the frame object

set_regions(regions, use_processed_region=True, unset_label='undefined', verbose=False)[source]

Alter the regions in the frame

Parameters
  • regions (dict) – a dictionary of mutually exclusive region labels and binary masks if a region does not cover all the workable areas then it will be the only label and the unused area will get the ‘unset_label’ as a different region

  • use_processed_region (bool) – default True keep the processed region subtracted

  • unset_label (str) – name of unset regions default (undefined)

property shape

Returns the (tuple) shape of the image (rows,columns)

property table_names

Return a list of data table names

Indices and tables