merquaco.data_loss.FOVDropout.find_on_tissue_fovs

static FOVDropout.find_on_tissue_fovs(transcripts: DataFrame, fovs: DataFrame, transcripts_mask_path: str | Path = None, transcripts_image_path: str | Path = None, ilastik_program_path: str | Path = None, pixel_model_path: str | Path = None, object_model_path: str | Path = None, force_mask: bool = False) DataFrame

Use ilastik transcripts mask to detemine on- and off-tissue FOVs FOV is considered on-tissue if at least 50% of its area is on-tissue

Parameters:
  • transcripts (pd.DataFrame) – Transcripts table dataframe

  • fovs (pd.DataFrame) – FOVs dataframe

  • transcripts_mask_path (np.ndarray or str or Path) – String or Path of path to transcripts mask. Optional, required if force_mask is False

  • transcripts_image_path (str or Path) – Path to transcripts image to save image for transcripts mask generation. Required if force_mask is True

  • ilastik_program_path (str or Path) – Path to ilastik program for transcripts mask generation. Required if force_mask is True

  • pixel_model_path (str or Path) – Path to pixel classification model for transcripts mask generation. Required if force_mask is True

  • object_model_path (str or Path) – Path to object classification model for transcripts mask generation. Required if force_mask is True

  • force_mask (bool, optional) – Whether to force the creation of a new transcripts mask

Returns:

fovs – Updated FOVs dataframe with on-tissue column

Return type:

pd.DataFrame

Raises:
  • ValueError – If image path is not provided

  • RuntimeError – If no on-tissue FOVs are found

Notes

pixel_classification.create_transcripts_image() returns the original dimensions of the transcripts image, but saves a transposed version of that image to match the remaining (i.e., DAPI, ventricles) masks. For this reason, the mask is transposed after being read in, to match the original transcripts dimensions.