dvpio.write.shapes.write_lmd#
- dvpio.write.shapes.write_lmd(path, annotation, calibration_points, affine_transformation=None, annotation_name_column=None, annotation_well_column=None, custom_attribute_columns=None, overwrite=True)#
Write cell annotations to Leica-compatible .xml file
- Parameters:
path (
str) – Export path for .xmlannotation (
ShapesModel) – Shapes to export with pyLMDcalibration_points (
PointsModel) – Calibration points in image coordinatesaffine_transformation (
ndarray|None(default:None)) – Optional. Affine transformation to apply to the data to recover Leica coordinate system. IfNone, tries to recover theto_lmdcoordinate transformation from theannotationspatialdata.models.ShapesModelobjectannotation_name_column (
str|None(default:None)) – Optional. Provide column that specifies a (unique) cell name inannotationspatialdata.models.ShapesModelobject. Will be stored as the tag of the Shape.annotation_well_column (
str|None(default:None)) – Optional. Provide column that specifies a well in theannotationspatialdata.models.ShapesModelobject. Will be stored in as theCapIDattribute of the Shape.custom_attribute_columns (
str|list[str] |None(default:None)) – Columns inannotationthat should be exported as custom tags in thexmlfile. The column name will become the tag name in the respective shape element. Users must assure themselves that they pass valid arguments.overwrite (
bool(default:True)) – DefaultTrue. Whether to overwrite existing data.
- Return type:
- Returns:
Saves to path
Example
from spatialdata.models import ShapesModel, PointsModel from tempfile import mkdtemp from dvpio.write import write_lmd annotation = ShapesModel.parse( gpd.GeoDataFrame( data={"name": ["001"], "well": ["A1"], "area": [0.8], "cell_type": ["T cell"]}, geometry=[shapely.Polygon([[0, 0], [0, 1], [1, 0], [0, 0]])], ) ) calibration_points = PointsModel.parse(np.array([[0, 0], [1, 1], [0, 1]])) path = os.path.join(mkdtemp(), "test.xml") write_lmd( path=path, annotation=annotation, calibration_points=calibration_points, annotation_name_column=annotation_name_column, annotation_well_column=annotation_well_column, custom_attribute_columns=["area", "cell_type"], overwrite=True, )