Skip to content

Slide

rationai.resources.slide.Slide

Bases: APIResource

Source code in rationai/resources/slide.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class Slide(APIResource):
    def heatmap(
        self,
        model: str,
        slide_path: str,
        tissue_mask_path: str,
        output_path: str,
        stride_fraction: float = 0.5,
        output_bigtiff_tile_height: int = 512,
        output_bigtiff_tile_width: int = 512,
        timeout: TimeoutTypes | UseClientDefault = 1000,
    ) -> str:
        """Creates a heatmap for a given slide using the specified model.

        Args:
            model: The model identifier to use for heatmap generation.
            slide_path: The path to the slide image.
            tissue_mask_path: The path to the tissue mask image.
            output_path: The path where the output heatmap will be saved. This includes the filename.
            stride_fraction: The fraction of the tile size to use as stride.
            output_bigtiff_tile_height: The tile height of the generated big-tiff heatmap.
            output_bigtiff_tile_width: The tile width of the generated big-tiff heatmap.
            timeout: Optional timeout for the request.

        Returns:
            str: The path to the generated heatmap. Should match the output_path provided.
        """
        response = self._post(
            "heatmap-builder",
            params={
                "model_id": model,
                "slide_path": slide_path,
                "tissue_mask_path": tissue_mask_path,
                "output_path": output_path,
                "stride_fraction": stride_fraction,
                "output_bigtiff_tile_height": output_bigtiff_tile_height,
                "output_bigtiff_tile_width": output_bigtiff_tile_width,
            },
            timeout=timeout,
        )
        response.raise_for_status()
        return response.text

heatmap(model, slide_path, tissue_mask_path, output_path, stride_fraction=0.5, output_bigtiff_tile_height=512, output_bigtiff_tile_width=512, timeout=1000)

Creates a heatmap for a given slide using the specified model.

Parameters:

Name Type Description Default
model str

The model identifier to use for heatmap generation.

required
slide_path str

The path to the slide image.

required
tissue_mask_path str

The path to the tissue mask image.

required
output_path str

The path where the output heatmap will be saved. This includes the filename.

required
stride_fraction float

The fraction of the tile size to use as stride.

0.5
output_bigtiff_tile_height int

The tile height of the generated big-tiff heatmap.

512
output_bigtiff_tile_width int

The tile width of the generated big-tiff heatmap.

512
timeout TimeoutTypes | UseClientDefault

Optional timeout for the request.

1000

Returns:

Name Type Description
str str

The path to the generated heatmap. Should match the output_path provided.

Source code in rationai/resources/slide.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def heatmap(
    self,
    model: str,
    slide_path: str,
    tissue_mask_path: str,
    output_path: str,
    stride_fraction: float = 0.5,
    output_bigtiff_tile_height: int = 512,
    output_bigtiff_tile_width: int = 512,
    timeout: TimeoutTypes | UseClientDefault = 1000,
) -> str:
    """Creates a heatmap for a given slide using the specified model.

    Args:
        model: The model identifier to use for heatmap generation.
        slide_path: The path to the slide image.
        tissue_mask_path: The path to the tissue mask image.
        output_path: The path where the output heatmap will be saved. This includes the filename.
        stride_fraction: The fraction of the tile size to use as stride.
        output_bigtiff_tile_height: The tile height of the generated big-tiff heatmap.
        output_bigtiff_tile_width: The tile width of the generated big-tiff heatmap.
        timeout: Optional timeout for the request.

    Returns:
        str: The path to the generated heatmap. Should match the output_path provided.
    """
    response = self._post(
        "heatmap-builder",
        params={
            "model_id": model,
            "slide_path": slide_path,
            "tissue_mask_path": tissue_mask_path,
            "output_path": output_path,
            "stride_fraction": stride_fraction,
            "output_bigtiff_tile_height": output_bigtiff_tile_height,
            "output_bigtiff_tile_width": output_bigtiff_tile_width,
        },
        timeout=timeout,
    )
    response.raise_for_status()
    return response.text

rationai.resources.slide.AsyncSlide

Bases: AsyncAPIResource

Source code in rationai/resources/slide.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class AsyncSlide(AsyncAPIResource):
    async def heatmap(
        self,
        model: str,
        slide_path: str,
        tissue_mask_path: str,
        output_path: str,
        stride_fraction: float = 0.5,
        output_bigtiff_tile_height: int = 512,
        output_bigtiff_tile_width: int = 512,
        timeout: TimeoutTypes | UseClientDefault = 1000,
    ) -> str:
        """Creates a heatmap for a given slide using the specified model.

        Args:
            model: The model identifier to use for heatmap generation.
            slide_path: The path to the slide image.
            tissue_mask_path: The path to the tissue mask image.
            output_path: The path where the output heatmap will be saved. This includes the filename.
            stride_fraction: The fraction of the tile size to use as stride.
            output_bigtiff_tile_height: The tile height of the generated big-tiff heatmap.
            output_bigtiff_tile_width: The tile width of the generated big-tiff heatmap.
            timeout: Optional timeout for the request.

        Returns:
            str: The path to the generated heatmap. Should match the output_path provided.
        """
        response = await self._post(
            "heatmap-builder",
            params={
                "model_id": model,
                "slide_path": slide_path,
                "tissue_mask_path": tissue_mask_path,
                "output_path": output_path,
                "stride_fraction": stride_fraction,
                "output_bigtiff_tile_height": output_bigtiff_tile_height,
                "output_bigtiff_tile_width": output_bigtiff_tile_width,
            },
            timeout=timeout,
        )
        response.raise_for_status()
        return response.text

heatmap(model, slide_path, tissue_mask_path, output_path, stride_fraction=0.5, output_bigtiff_tile_height=512, output_bigtiff_tile_width=512, timeout=1000) async

Creates a heatmap for a given slide using the specified model.

Parameters:

Name Type Description Default
model str

The model identifier to use for heatmap generation.

required
slide_path str

The path to the slide image.

required
tissue_mask_path str

The path to the tissue mask image.

required
output_path str

The path where the output heatmap will be saved. This includes the filename.

required
stride_fraction float

The fraction of the tile size to use as stride.

0.5
output_bigtiff_tile_height int

The tile height of the generated big-tiff heatmap.

512
output_bigtiff_tile_width int

The tile width of the generated big-tiff heatmap.

512
timeout TimeoutTypes | UseClientDefault

Optional timeout for the request.

1000

Returns:

Name Type Description
str str

The path to the generated heatmap. Should match the output_path provided.

Source code in rationai/resources/slide.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
async def heatmap(
    self,
    model: str,
    slide_path: str,
    tissue_mask_path: str,
    output_path: str,
    stride_fraction: float = 0.5,
    output_bigtiff_tile_height: int = 512,
    output_bigtiff_tile_width: int = 512,
    timeout: TimeoutTypes | UseClientDefault = 1000,
) -> str:
    """Creates a heatmap for a given slide using the specified model.

    Args:
        model: The model identifier to use for heatmap generation.
        slide_path: The path to the slide image.
        tissue_mask_path: The path to the tissue mask image.
        output_path: The path where the output heatmap will be saved. This includes the filename.
        stride_fraction: The fraction of the tile size to use as stride.
        output_bigtiff_tile_height: The tile height of the generated big-tiff heatmap.
        output_bigtiff_tile_width: The tile width of the generated big-tiff heatmap.
        timeout: Optional timeout for the request.

    Returns:
        str: The path to the generated heatmap. Should match the output_path provided.
    """
    response = await self._post(
        "heatmap-builder",
        params={
            "model_id": model,
            "slide_path": slide_path,
            "tissue_mask_path": tissue_mask_path,
            "output_path": output_path,
            "stride_fraction": stride_fraction,
            "output_bigtiff_tile_height": output_bigtiff_tile_height,
            "output_bigtiff_tile_width": output_bigtiff_tile_width,
        },
        timeout=timeout,
    )
    response.raise_for_status()
    return response.text