tumourkit.preprocessing.geojson2pngcsv.geojson2pngcsv

tumourkit.preprocessing.geojson2pngcsv.geojson2pngcsv(gson: List[Dict[str, Any]], num_classes: int | None = 2) Tuple[ndarray, DataFrame]

Computes PNG and CSV labels from GeoJSON.

Parameters:
  • gson (List[Dict[str, Any]]) – A list of GeoJSON features.

  • num_classes (Optional[int]) – The number of classes to use in the output CSV. If not provided, it defaults to 2 (tumour and non-tumour).

Returns:

A tuple containing the PNG image array and the Pandas DataFrame of the CSV file.

Return type:

Tuple[np.ndarray, pd.DataFrame]

This function takes a list of GeoJSON features and generates PNG and CSV labels from them. The width and height of the PNG image are assumed to be 1024. The function expects the GeoJSON to have specific format, with the geometry stored as a list of coordinates. If a feature has a label that is not “tumour” or “non-tumour”, the label will be replaced with “ClassN”, where N is the class number.