Skip to content

API Reference

omerocrate.OmeroUploader dataclass

Class that handles the conversion between RO-Crate metadata and OMERO objects. Users are encouraged to subclass this and override any of the public methods to customize the behavior. Refer to the method documentation for more information.

conn instance-attribute

OMERO connection object, typically obtained using from_env

crate instance-attribute

Path to the directory containing the crate

graph cached property

RO-Crate metadata as an RDF graph. Typically you don't need to override this method.

image_query = '\n SELECT ?file_path\n WHERE {\n ?file_path a schema:MediaObject ;\n FILTER (STRAFTER(STR(?file_path), ".") IN ("jpg", "jpeg", "png", "tiff", "tif", "bmp", "gif"))\n }\n ' class-attribute instance-attribute

Query for selecting images and their metadata from the crate. Override this to customize the selection. For example, to select only images whose MIME type starts with "image/", you can use: sparql WHERE { ?file_path a schema:MediaObject ; schema:encodingFormat ?img_format . FILTER STRSTARTS(?img_format, "image/") }

namespaces property

Namespaces/prefixes used in all SPARQL queries. Override this to add or adjust prefixes, e.g. if you are using additional vocabularies.

root_dataset_id cached property

Returns the ID of the root dataset in the crate. You shouldn't need to override this method as this function should work for any conformant RO-Crate.

transfer_type = 'upload' class-attribute instance-attribute

Transfer method, which determines how images are sent to OMERO. ln_s is "in-place" importing, but it requires that this process has acess to both the image and permissions to write to the OMERO server.

connect()

Connects to the OMERO server.

execute()

Runs the entire processing workflow. Typically you don't need to override this method.

make_dataset()

Creates the OMERO dataset that correspons to this crate. Override to customize the dataset creation.

path_from_image_result(result)

Converts a SPARQL result row to a Path object.

process_image(image, result, dataset)

Handles the processing of a single image extracted from the crate. By default, this does nothing. Override this to e.g. add additional metadata to the image using the image wrapper.

process_images(dataset)

Runs the image selection query and processes each result. Typically you don't need to override this method: either process_image or image_query should be enough.

select_many(query, namespaces={}, variables={})

Helper method for running a SPARQL query on the RO-Crate metadata that returns multiple results. Typically you don't need to override this method.

select_one(query, namespaces={}, variables={})

Helper method for running a SPARQL query on the RO-Crate metadata that should return exactly one result. Typically you don't need to override this method.

upload_images(image_paths, dataset)

Uploads a set of images to OMERO. You could override this to use a different method of importing images.

Parameters:

Name Type Description Default
image_paths Iterable[Path]

Paths to image files to upload

required
dataset DatasetWrapper

OMERO dataset to add the images to

required

Returns: Wrapped OMERO image object

omerocrate.from_env()

Authenticate to OMERO using environment variables. You will need to set the following environment variables:

  • OMERO_PASSWORD
  • OMERO_HOST
  • OMERO_USER (optional, defaults to the current username)
  • OMERO_PORT (optional, defaults to 4064)