metadata4Ing

metadata4Ing#

Metadata4Ing is an ontology developed within the NFDI Consortium NFDI4Ing “with the aim of providing a thorough framework for the semantic description of research data, with a particular focus on engineering sciences and neighbouring disciplines.”

The h5RDMtoolbox allows translating JSON-LD data into the HDF5 structure and wise versa (see here). This way, engineering process metadata can be added easily to the HDF5 file.

Consider the following example file taken from the m4i ontology “first steps guide”, which describes an experimental investigation. You can find the full content of the JSON-LD file here, the following shows an excerpt:

import h5rdmtoolbox as h5tbx
_ = h5tbx.set_config(auto_create_h5tbx_version=False)

With a single call (h5tbx.jsonld.to_hdf) it is possible to read in the JSON-LD data and parse it into the HDF5 structure:

with h5tbx.File() as h5:
    h5.create_group('metadata')
    h5tbx.jsonld.to_hdf(h5.metadata, source='min_m4i_ex.jsonld')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 3
      1 with h5tbx.File() as h5:
      2     h5.create_group('metadata')
----> 3     h5tbx.jsonld.to_hdf(h5.metadata, source='min_m4i_ex.jsonld')

File ~/checkouts/readthedocs.org/user_builds/h5rdmtoolbox/envs/v2.7.3/lib/python3.10/site-packages/h5rdmtoolbox/wrapper/jsonld.py:345, in to_hdf(grp, data, source, predicate, context, resolve_keys)
    343     if label is None:  # still None...
    344         _type = graph_entry.get('@type', None)
--> 345         ns, label = split_uri(_type)
    347 i = 1
    348 while label in grp:

File ~/checkouts/readthedocs.org/user_builds/h5rdmtoolbox/envs/v2.7.3/lib/python3.10/site-packages/ontolutils/classes/utils.py:49, in split_uri(uri)
     47 def split_uri(uri: rdflib.URIRef) -> Tuple[str, str]:
     48     """Split a URIRef into namespace and key."""
---> 49     return rdflib.namespace.split_uri(uri)

File ~/checkouts/readthedocs.org/user_builds/h5rdmtoolbox/envs/v2.7.3/lib/python3.10/site-packages/rdflib/namespace/__init__.py:922, in split_uri(uri, split_start)
    920                 return (ns, ln)
    921         break
--> 922 raise ValueError("Can't split '{}'".format(uri))

ValueError: Can't split 'person'
print(h5tbx.serialize(h5.hdf_filename, format="ttl", structural=False, file_uri="https://local-domain.org/"))
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix m4i: <http://w3id.org/nfdi4ing/metadata4ing#> .
@prefix ns1: <http://purl.obolibrary.org/obo/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://local-domain.org/#tmp0.hdf/metadata/FineTec%20FORE%20180.01C%20TT> schema:about <https://local-domain.org/xray_source_finetec_180.01ctt_0001> .

<https://local-domain.org/#tmp0.hdf/metadata/Image%20Processing%20and%20Reconstruction> schema:about <https://local-domain.org/reconstruction_0001> .

<https://local-domain.org/#tmp0.hdf/metadata/Post%20Processing> schema:about <https://local-domain.org/postprocessing_0001> .

<https://local-domain.org/#tmp0.hdf/metadata/Sample%20preparation%20and%20parameter%20definition> schema:about <https://local-domain.org/preparation_0001> .

<https://local-domain.org/#tmp0.hdf/metadata/Standard%20cone%20beam%20scanning> schema:about <https://local-domain.org/cone_beam_scanning> .

<https://local-domain.org/#tmp0.hdf/metadata/Standard%20cone%20beam%20scanning/has%20parameter> m4i:hasParameter <https://local-domain.org/xray_tube_voltage> ;
    schema:about <https://local-domain.org/xray_tube_voltage> .

<https://local-domain.org/#tmp0.hdf/metadata/XRCT-Scan> schema:about <https://local-domain.org/xrctscan_0001> .

<https://local-domain.org/#tmp0.hdf/metadata/file%20set> schema:about <https://local-domain.org/output/xrct-data> .

<https://local-domain.org/#tmp0.hdf/metadata/person> schema:about <https://local-domain.org/alex> .

<https://local-domain.org/postprocessing_0001> a m4i:ProcessingStep ;
    rdfs:label "Post Processing" .

<https://local-domain.org/preparation_0001> a m4i:ProcessingStep ;
    rdfs:label "Sample preparation and parameter definition" ;
    prov:wasAssociatedWith <https://local-domain.org/alex> ;
    schema:startTime "2025-10-22T00:00:00"^^xsd:dateTime .

<https://local-domain.org/reconstruction_0001> a m4i:ProcessingStep ;
    rdfs:label "Image Processing and Reconstruction" ;
    ns1:RO_0002233 <https://local-domain.org/xrct_data_0001> .

<https://local-domain.org/xrctscan_0001> a m4i:ProcessingStep ;
    rdfs:label "XRCT-Scan" ;
    ns1:RO_0002234 <https://local-domain.org/output/xrct-data> ;
    m4i:hasEmployedTool <https://local-domain.org/xray_source_finetec_180.01ctt_0001> ;
    m4i:investigates <https://www.wikidata.org/wiki/Q189259> ;
    m4i:investigatesProperty <https://www.wikidata.org/wiki/Q256699> ;
    m4i:realizesMethod <https://local-domain.org/cone_beam_scanning> .

<https://local-domain.org/alex> a prov:Person ;
    m4i:orcidId "0000-0000-0123-4567" ;
    foaf:firstName "Alexandra" ;
    foaf:lastName "Test" .

<https://local-domain.org/cone_beam_scanning> a m4i:Method ;
    rdfs:label "Standard cone beam scanning" ;
    dcterms:description "Standard cone beam scanning of the centered sample" .

<https://local-domain.org/output/xrct-data> a <http://mlcommons.org/croissant/FileSet> ;
    dcterms:description "TIFF files in folder output/image-files" ;
    m4i:includes "*.tiff" .

<https://local-domain.org/xray_source_finetec_180.01ctt_0001> a m4i:Tool ;
    rdfs:label "FineTec FORE 180.01C TT" .

<https://local-domain.org/xray_tube_voltage> a m4i:NumericalVariable ;
    rdfs:label "X-Ray Tube Voltage" ;
    m4i:hasKindOfQuantity <http://qudt.org/vocab/quantitykind/ElectricPotential> ;
    m4i:hasNumericalValue "0140-10-12T00:00:00"^^xsd:dateTime ;
    m4i:hasUnit <http://qudt.org/vocab/unit/KiloV> .
print(
    h5tbx.serialize(
        h5.hdf_filename,
        format="ttl",
        structural=False,
        file_uri="https://local-domain.org/",
        context={"@import": "https://w3id.org/nfdi4ing/metadata4ing/m4i_context.jsonld"})
)
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix m4i: <http://w3id.org/nfdi4ing/metadata4ing#> .
@prefix ns1: <http://purl.obolibrary.org/obo/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://local-domain.org/#tmp0.hdf/metadata/FineTec%20FORE%20180.01C%20TT> schema:about <https://local-domain.org/xray_source_finetec_180.01ctt_0001> .

<https://local-domain.org/#tmp0.hdf/metadata/Image%20Processing%20and%20Reconstruction> schema:about <https://local-domain.org/reconstruction_0001> .

<https://local-domain.org/#tmp0.hdf/metadata/Post%20Processing> schema:about <https://local-domain.org/postprocessing_0001> .

<https://local-domain.org/#tmp0.hdf/metadata/Sample%20preparation%20and%20parameter%20definition> schema:about <https://local-domain.org/preparation_0001> .

<https://local-domain.org/#tmp0.hdf/metadata/Standard%20cone%20beam%20scanning> schema:about <https://local-domain.org/cone_beam_scanning> .

<https://local-domain.org/#tmp0.hdf/metadata/Standard%20cone%20beam%20scanning/has%20parameter> m4i:hasParameter <https://local-domain.org/xray_tube_voltage> ;
    schema:about <https://local-domain.org/xray_tube_voltage> .

<https://local-domain.org/#tmp0.hdf/metadata/XRCT-Scan> schema:about <https://local-domain.org/xrctscan_0001> .

<https://local-domain.org/#tmp0.hdf/metadata/file%20set> schema:about <https://local-domain.org/output/xrct-data> .

<https://local-domain.org/#tmp0.hdf/metadata/person> schema:about <https://local-domain.org/alex> .

<https://local-domain.org/postprocessing_0001> a m4i:ProcessingStep ;
    rdfs:label "Post Processing" .

<https://local-domain.org/preparation_0001> a m4i:ProcessingStep ;
    rdfs:label "Sample preparation and parameter definition" ;
    prov:wasAssociatedWith <https://local-domain.org/alex> ;
    schema:startTime "2025-10-22T00:00:00"^^xsd:dateTime .

<https://local-domain.org/reconstruction_0001> a m4i:ProcessingStep ;
    rdfs:label "Image Processing and Reconstruction" ;
    ns1:RO_0002233 <https://local-domain.org/xrct_data_0001> .

<https://local-domain.org/xrctscan_0001> a m4i:ProcessingStep ;
    rdfs:label "XRCT-Scan" ;
    ns1:RO_0002234 <https://local-domain.org/output/xrct-data> ;
    m4i:hasEmployedTool <https://local-domain.org/xray_source_finetec_180.01ctt_0001> ;
    m4i:investigates <https://www.wikidata.org/wiki/Q189259> ;
    m4i:investigatesProperty <https://www.wikidata.org/wiki/Q256699> ;
    m4i:realizesMethod <https://local-domain.org/cone_beam_scanning> .

<https://local-domain.org/alex> a prov:Person ;
    m4i:orcidId "0000-0000-0123-4567" ;
    foaf:firstName "Alexandra" ;
    foaf:lastName "Test" .

<https://local-domain.org/cone_beam_scanning> a m4i:Method ;
    rdfs:label "Standard cone beam scanning" ;
    dcterms:description "Standard cone beam scanning of the centered sample" .

<https://local-domain.org/output/xrct-data> a <http://mlcommons.org/croissant/FileSet> ;
    dcterms:description "TIFF files in folder output/image-files" ;
    m4i:includes "*.tiff" .

<https://local-domain.org/xray_source_finetec_180.01ctt_0001> a m4i:Tool ;
    rdfs:label "FineTec FORE 180.01C TT" .

<https://local-domain.org/xray_tube_voltage> a m4i:NumericalVariable ;
    rdfs:label "X-Ray Tube Voltage" ;
    m4i:hasKindOfQuantity <http://qudt.org/vocab/quantitykind/ElectricPotential> ;
    m4i:hasNumericalValue "0140-10-12T00:00:00"^^xsd:dateTime ;
    m4i:hasUnit <http://qudt.org/vocab/unit/KiloV> .