SporaResNetWrapper

class models.resnet.resnet.SporaResNetWrapper(model_name='resnet50', pca_dim_channel=9, tile_size=224)[source]

Bases: SporaModelWrapper

Parameters:
  • model_name (str)

  • pca_dim_channel (int)

  • tile_size (int)

embed_tile(tissue)[source]

Embed a tile from the input image. :param tissue: The input tissue containing the image and protein IDs. :type tissue: Tissue

Returns:

The embedded tile tensor. Shape: (D,)

Return type:

Tensor

Parameters:

tissue (spora_io.datasets._types.Tissue)

embed_tissue(dataset, tissue_id, tissue_threshold=0.3)[source]

Embed the tissue from the input image. :param dataset: The input dataset containing the multiplexed images and segmentation masks. :type dataset: MultiplexImagingDataset :param tissue_id: The ID of the tissue to embed. :type tissue_id: str :param tissue_threshold: The threshold for considering a tile as containing tissue. :type tissue_threshold: float

Returns:

A sequence-shaped embedding of the tissue. Shape: (N,D)

Return type:

Tensor

Parameters:
  • dataset (spora_io.MultiplexImagingDataset)

  • tissue_id (str)

  • tissue_threshold (float)

postprocess_tile_embeddings(tissue_embeddings)[source]

Postprocess the tissue embedding if necessary (e.g., for dimensionality reduction for kronos patient level tasks). :param tissue_embedding: The raw tissue embedding tensor. Shape: (N, D) :type tissue_embedding: torch.Tensor

Returns:

The postprocessed tissue token tensor. Shape: (N, D’)

Return type:

torch.Tensor

Parameters:

tissue_embeddings (Tensor)

ResNet module

class models.resnet.resnet.SporaResNetWrapper(model_name='resnet50', pca_dim_channel=9, tile_size=224)[source]
Parameters:
  • model_name (str)

  • pca_dim_channel (int)

  • tile_size (int)

embed_tile(tissue)[source]

Embed a tile from the input image. :param tissue: The input tissue containing the image and protein IDs. :type tissue: Tissue

Returns:

The embedded tile tensor. Shape: (D,)

Return type:

Tensor

Parameters:

tissue (spora_io.datasets._types.Tissue)

embed_tissue(dataset, tissue_id, tissue_threshold=0.3)[source]

Embed the tissue from the input image. :param dataset: The input dataset containing the multiplexed images and segmentation masks. :type dataset: MultiplexImagingDataset :param tissue_id: The ID of the tissue to embed. :type tissue_id: str :param tissue_threshold: The threshold for considering a tile as containing tissue. :type tissue_threshold: float

Returns:

A sequence-shaped embedding of the tissue. Shape: (N,D)

Return type:

Tensor

Parameters:
  • dataset (spora_io.MultiplexImagingDataset)

  • tissue_id (str)

  • tissue_threshold (float)

postprocess_tile_embeddings(tissue_embeddings)[source]

Postprocess the tissue embedding if necessary (e.g., for dimensionality reduction for kronos patient level tasks). :param tissue_embedding: The raw tissue embedding tensor. Shape: (N, D) :type tissue_embedding: torch.Tensor

Returns:

The postprocessed tissue token tensor. Shape: (N, D’)

Return type:

torch.Tensor

Parameters:

tissue_embeddings (Tensor)