bioformats  5.1.3
MetadataTools.h
1 /*
2  * #%L
3  * OME-BIOFORMATS C++ library for image IO.
4  * Copyright © 2006 - 2015 Open Microscopy Environment:
5  * - Massachusetts Institute of Technology
6  * - National Institutes of Health
7  * - University of Dundee
8  * - Board of Regents of the University of Wisconsin-Madison
9  * - Glencoe Software, Inc.
10  * %%
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  * The views and conclusions contained in the software and documentation are
33  * those of the authors and should not be interpreted as representing official
34  * policies, either expressed or implied, of any organization.
35  * #L%
36  */
37 
38 #include <string>
39 
40 #include <ome/bioformats/FormatReader.h>
41 #include <ome/bioformats/Types.h>
42 
43 #include <ome/common/filesystem.h>
44 
45 #include <ome/xml/meta/Metadata.h>
46 #include <ome/xml/meta/MetadataRoot.h>
47 #include <ome/xml/meta/OMEXMLMetadata.h>
48 
49 #include <ome/xml/model/enums/DimensionOrder.h>
50 
51 #ifndef OME_BIOFORMATS_METADATATOOLS_H
52 #define OME_BIOFORMATS_METADATATOOLS_H
53 
54 namespace ome
55 {
56  namespace bioformats
57  {
58 
59  // Use overloaded functions for creating identifiers since
60  // pre-C++11 compilers don't support the C99 stdarg interface.
61 
69  std::string
70  createID(std::string const& type,
72 
81  std::string
82  createID(std::string const& type,
84  dimension_size_type idx2);
85 
95  std::string
96  createID(std::string const& type,
99  dimension_size_type idx3);
100 
111  std::string
112  createID(std::string const& type,
113  dimension_size_type idx1,
114  dimension_size_type idx2,
115  dimension_size_type idx3,
116  dimension_size_type idx4);
117 
124  ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
126 
133  ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
134  createOMEXMLMetadata(const boost::filesystem::path& file);
135 
142  ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
143  createOMEXMLMetadata(const std::string& text);
144 
151  ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
152  createOMEXMLMetadata(std::istream& stream);
153 
162  ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
163  createOMEXMLMetadata(const FormatReader& reader,
164  bool doPlane = false,
165  bool doImageName = true);
166 
167 
174  ome::compat::shared_ptr< ::ome::xml::meta::MetadataRoot>
175  createOMEXMLRoot(const std::string& document);
176 
185  ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
186  getOMEXMLMetadata(ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve>& retrieve);
187 
199  std::string
201  bool validate = true);
202 
209  bool
210  validateOMEXML(const std::string& document);
211 
226  bool
228  bool correct);
229 
240  void
242  const FormatReader& reader,
243  bool doPlane = false,
244  bool doImageName = true);
245 
255  void
257  const std::vector<ome::compat::shared_ptr<CoreMetadata> > seriesList,
258  bool doPlane = false);
259 
268  void
270  const FormatReader& reader);
271 
280  void
282  const FormatReader& reader);
283 
293  void
295  const CoreMetadata& seriesMetadata,
296  dimension_size_type series);
297 
307  void
309  dimension_size_type series,
310  bool resolve = true);
311 
319  Modulo
320  getModuloAlongZ(const ::ome::xml::meta::OMEXMLMetadata& omexml,
321  dimension_size_type image);
322 
330  Modulo
331  getModuloAlongT(const ::ome::xml::meta::OMEXMLMetadata& omexml,
332  dimension_size_type image);
333 
341  Modulo
342  getModuloAlongC(const ::ome::xml::meta::OMEXMLMetadata& omexml,
343  dimension_size_type image);
344 
353  Modulo
354  getModulo(const ::ome::xml::meta::OMEXMLMetadata& omexml,
355  const std::string& tag,
356  dimension_size_type image);
357 
365  void
367  dimension_size_type series = 0U);
368 
374  void
376 
385  void
387  dimension_size_type image,
388  dimension_size_type sizeC);
389 
396  MetadataMap
398 
405  void
407  const MetadataMap& metadata);
408 
414  bool
416 
422  std::string
423  getModelVersion();
424 
431  std::string
433 
440  std::string
441  getModelVersion(const std::string& document);
442 
449  std::string
450  transformToLatestModelVersion(const std::string& document);
451 
462  void
463  defaultCreationDateEnabled(bool enabled);
464 
479  void
481  dimension_size_type series,
482  const boost::filesystem::path& id);
483 
498  createDimensionOrder(const std::string& order);
499 
511  pixelSize(const ::ome::xml::meta::MetadataRetrieve& meta,
512  dimension_size_type series);
513 
524  pixelSize(const ::ome::xml::meta::MetadataRetrieve& meta);
525 
526 
538  significantPixelSize(const ::ome::xml::meta::MetadataRetrieve& meta,
539  dimension_size_type series);
540 
551  significantPixelSize(const ::ome::xml::meta::MetadataRetrieve& meta);
552 
553  }
554 }
555 
556 #endif // OME_BIOFORMATS_METADATATOOLS_H
557 
558 /*
559  * Local Variables:
560  * mode:C++
561  * End:
562  */
Modulo getModuloAlongC(const ::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type image)
Get ModuloAlongC annotation from OME-XML metadata.
Definition: MetadataTools.cpp:700
bool validateModel(::ome::xml::meta::Metadata &meta, bool correct)
Validate a metadata store.
Definition: MetadataTools.cpp:354
void removeChannels(::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type image, dimension_size_type sizeC)
Remove all but the specified number of valid Channel elements from OME-XML metadata.
Definition: MetadataTools.cpp:861
std::string createID(std::string const &type, dimension_size_type idx)
Create an object identifier for a given object type and index.
Definition: MetadataTools.cpp:173
void removeBinData(::ome::xml::meta::OMEXMLMetadata &omexml)
Remove all BinData elements from OME-XML metadata.
Definition: MetadataTools.cpp:830
DOM Document wrapper.
Definition: Document.h:82
ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata > getOMEXMLMetadata(ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve > &retrieve)
Get OME-XML metadata from metadata.
Definition: MetadataTools.cpp:314
ome::xml::model::enums::DimensionOrder createDimensionOrder(const std::string &order)
Create a valid DimensionOrder from string.
Definition: MetadataTools.cpp:1132
Metadata storage interface.
Definition: MetadataStore.h:140
DimensionOrder enumeration.
Definition: DimensionOrder.h:70
Boost.Filesystem compatibility.
storage_size_type pixelSize(const ::ome::xml::meta::MetadataRetrieve &meta, dimension_size_type series)
Get the total size of pixel data in a series.
Definition: MetadataTools.cpp:1162
MetadataMap getOriginalMetadata(::ome::xml::meta::OMEXMLMetadata &omexml)
Get original metadata from OME-XML metadata StructuredAnnotations.
Definition: MetadataTools.cpp:888
Modulo getModuloAlongZ(const ::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type image)
Get ModuloAlongZ annotation from OME-XML metadata.
Definition: MetadataTools.cpp:686
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
std::string getModelVersion()
Get the currently-supported OME Data Model version.
Definition: MetadataTools.cpp:1025
void verifyMinimum(::ome::xml::meta::MetadataRetrieve &retrieve, dimension_size_type series)
Verify correctness of minimal amount of metadata in a series.
Definition: MetadataTools.cpp:782
void addMetadataOnly(::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type series, bool resolve)
Add a MetadataOnly element to Pixels for the specified series.
Definition: MetadataTools.cpp:662
void setDefaultCreationDate(::ome::xml::meta::MetadataStore &store, dimension_size_type series, const boost::filesystem::path &id)
Set the creation data for a series.
Definition: MetadataTools.cpp:1118
A metadata store implementation for constructing and manipulating OME-XML DOMs for the current versio...
Definition: OMEXMLMetadata.h:67
Modulo getModuloAlongT(const ::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type image)
Get ModuloAlongT annotation from OME-XML metadata.
Definition: MetadataTools.cpp:693
void fillPixels(::ome::xml::meta::MetadataStore &store, const FormatReader &reader)
Fill an OME-XML metadata store Pixels element from reader core metadata.
Definition: MetadataTools.cpp:598
std::string transformToLatestModelVersion(const std::string &document)
Transform an OME-XML document to the latest model version.
Definition: MetadataTools.cpp:1099
void fillMetadata(::ome::xml::meta::MetadataStore &store, const FormatReader &reader, bool doPlane, bool doImageName)
Fill OME-XML metadata store from reader core metadata.
Definition: MetadataTools.cpp:475
std::string getOMEXML(::ome::xml::meta::OMEXMLMetadata &omexml, bool validate)
Get OME-XML document from OME-XML metadata.
Definition: MetadataTools.cpp:336
bool validateOMEXML(const std::string &document)
Validate an OME-XML document.
Definition: MetadataTools.cpp:348
ome::compat::shared_ptr< ::ome::xml::meta::MetadataRoot > createOMEXMLRoot(const std::string &document)
Create OME-XML metadata root from XML document.
Definition: MetadataTools.cpp:305
uint64_t storage_size_type
Size type for storage size.
Definition: Types.h:65
Metadata retrieval interface.
Definition: MetadataRetrieve.h:126
bool defaultCreationDateEnabled()
Check if default creation date is enabled.
Definition: MetadataTools.cpp:1106
ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata > createOMEXMLMetadata(ome::common::xml::dom::Document &document)
Create OME-XML metadata from DOM Document.
Definition: MetadataTools.cpp:219
storage_size_type significantPixelSize(const ::ome::xml::meta::MetadataRetrieve &meta, dimension_size_type series)
Get the total significant size of pixel data in a series.
Definition: MetadataTools.cpp:1197
Abstract class for metadata storage and retrieval.
Definition: Metadata.h:61
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
void fillOriginalMetadata(::ome::xml::meta::OMEXMLMetadata &omexml, const MetadataMap &metadata)
Create OriginalMetadataAnnotations from MetadataMap.
Definition: MetadataTools.cpp:970
void fillAllPixels(::ome::xml::meta::MetadataStore &store, const FormatReader &reader)
Fill all OME-XML metadata store Pixels elements from reader core metadata.
Definition: MetadataTools.cpp:585
Modulo getModulo(const ::ome::xml::meta::OMEXMLMetadata &omexml, const std::string &tag, dimension_size_type image)
Get Modulo annotation from OME-XML metadata.
Definition: MetadataTools.cpp:707