{"id":21639,"library":"ome-types","title":"ome-types","description":"Python dataclasses for the OME (Open Microscopy Environment) data model. Provides type-annotated Python objects for OME-XML metadata, enabling type-safe construction and serialization of OME metadata. Current version 0.6.3, supports Python >=3.9. Maintained by tlambert03, regular releases.","status":"active","version":"0.6.3","language":"python","source_language":"en","source_url":"https://github.com/tlambert03/ome-types","tags":["ome","microscopy","dataclasses","pydantic","xml","metadata"],"install":[{"cmd":"pip install ome-types","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"ome-types uses pydantic BaseModel for its dataclasses, required for validation and serialization.","package":"pydantic","optional":false}],"imports":[{"note":"","wrong":"","symbol":"OME","correct":"from ome_types import OME"},{"note":"","wrong":"","symbol":"Image","correct":"from ome_types.model import Image"},{"note":"","wrong":"","symbol":"Pixels","correct":"from ome_types.model import Pixels"},{"note":"Both imports work for OME, but model submodule is explicit for internal model classes.","wrong":"from ome_types import OME (this is also correct for the top-level OME, but if you want the model specifically use the model submodule)","symbol":"OME as model","correct":"from ome_types.model import OME"}],"quickstart":{"code":"from ome_types import OME\nfrom ome_types.model import Image, Pixels\n\n# Create minimal OME object\nome = OME(images=[Image(id='Image:0', name='test', pixels=Pixels(id='Pixels:0', dimension_order='XYZCT', size_x=10, size_y=10, size_c=1, size_z=1, size_t=1, type='uint8'))])\nprint(ome.to_xml())","lang":"python","description":"Create an OME object programmatically with required fields and serialize to XML."},"warnings":[{"fix":"Refer to OME schema documentation for required attributes. Use pydantic's model_dump(mode='python') to debug.","message":"OME model fields are validated at construction; missing required fields raise pydantic ValidationError. Always check required fields (e.g., id, dimension_order, size_x, etc.) for Images and Pixels.","severity":"gotcha","affected_versions":"all"},{"fix":"Use 'from ome_types import OME' instead of 'from ome_types.model import OME'.","message":"In version 0.6.0, the OME class was moved from ome_types.model to ome_types directly. Importing from the old path still works but may be deprecated.","severity":"deprecated","affected_versions":">=0.6.0"},{"fix":"Read the source or use the underlying pydantic XML serialization if needed.","message":"Serializing to XML with to_xml() will produce a string with default namespaces. If you need custom namespaces or formatting, use to_xml(nsmap=...) but those are not fully documented.","severity":"gotcha","affected_versions":"all"},{"fix":"Use lxml.etree.parse() to validate XML before passing to from_xml().","message":"When parsing XML with from_xml(), ensure the XML is valid OME-XML. Invalid XML raises ParseError without clear message. Use lxml's parser for better error messages.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Check all required fields in the OME schema. For OME object, images is required (list of Image). For Image, id and name are required. For Pixels, id, dimension_order, size_x, size_y, size_c, size_z, size_t, type are required.","cause":"Missing required field when constructing OME or model objects.","error":"pydantic_core._pydantic_core.ValidationError: 1 validation error for OME"},{"fix":"Use 'from ome_types import OME' (top-level import) for current versions (>=0.6.0).","cause":"Trying to import OME from wrong submodule; in older versions OME was in ome_types.model, newer versions it is in ome_types directly.","error":"ModuleNotFoundError: No module named 'ome_types.model.OME'"},{"fix":"Ensure you have an OME object, not a dict. Use .model_dump(mode='python') to get dict representation, but to_xml() is only on the model object.","cause":"Calling to_xml() on a dict instead of an OME model instance, often happens when using .model_dump() incorrectly.","error":"AttributeError: 'dict' object has no attribute 'to_xml'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}