add_from_dat¶

add_from_dat(store, fp, scale_factor=(1, 1), typedict=None, origin=(0, 0))[source]¶

Add annotations from a .dat file to an existing store.

Make the best effort to create valid shapely geometries from provided contours.

Parameters:
  • store (AnnotationStore) – An AnnotationStore object.

  • fp (IO | PathLike) – The file path or handle to load from.

  • scale_factor (tuple[float, float]) – The scale factor to use when loading the annotations. All coordinates will be multiplied by this factor to allow import of annotations saved at non-baseline resolution. Should be model_mpp/slide_mpp, where model_mpp is the resolution at which the annotations were saved. If scale information is stored in the .dat file (as in cerberus output), that will be used and this arg will be ignored.

  • typedict (Dict[str, str]) – A dictionary mapping annotation types to annotation keys. Annotations with a type that is a key in the dictionary, will have their type replaced by the corresponding value. Useful for providing descriptive names to non-descriptive types, e.g., {1: ‘Epithelial Cell’, 2: ‘Lymphocyte’, 3: …}. For multi-head output, should be a dict of dicts, e.g.: {‘head1’: {1: ‘Epithelial Cell’, 2: ‘Lymphocyte’, 3: …}, ‘head2’: {1: ‘Gland’, 2: ‘Lumen’, 3: …}, …}.

  • origin (tuple(float, float)) – The x and y coordinates to use as the origin for the annotations.

Return type:

None