ome-files  0.3.2
MetadataTools.h
1 /*
2  * #%L
3  * OME-FILES 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 <boost/filesystem/path.hpp>
41 
42 #include <ome/compat/memory.h>
43 
44 #include <ome/files/FormatReader.h>
45 #include <ome/files/MetadataMap.h>
46 #include <ome/files/Types.h>
47 
48 #include <ome/xml/meta/Metadata.h>
49 #include <ome/xml/meta/MetadataRoot.h>
50 #include <ome/xml/meta/OMEXMLMetadata.h>
51 
52 #include <ome/xml/model/enums/DimensionOrder.h>
53 
54 #ifndef OME_FILES_METADATATOOLS_H
55 #define OME_FILES_METADATATOOLS_H
56 
57 namespace ome
58 {
59  namespace files
60  {
61 
62  // Use overloaded functions for creating identifiers since
63  // pre-C++11 compilers don't support the C99 stdarg interface.
64 
72  std::string
73  createID(std::string const& type,
75 
84  std::string
85  createID(std::string const& type,
87  dimension_size_type idx2);
88 
98  std::string
99  createID(std::string const& type,
100  dimension_size_type idx1,
101  dimension_size_type idx2,
102  dimension_size_type idx3);
103 
114  std::string
115  createID(std::string const& type,
116  dimension_size_type idx1,
117  dimension_size_type idx2,
118  dimension_size_type idx3,
119  dimension_size_type idx4);
120 
127  std::shared_ptr<::ome::xml::meta::OMEXMLMetadata>
129 
136  std::shared_ptr<::ome::xml::meta::OMEXMLMetadata>
137  createOMEXMLMetadata(const boost::filesystem::path& file);
138 
145  std::shared_ptr<::ome::xml::meta::OMEXMLMetadata>
146  createOMEXMLMetadata(const std::string& text);
147 
154  std::shared_ptr<::ome::xml::meta::OMEXMLMetadata>
155  createOMEXMLMetadata(std::istream& stream);
156 
165  std::shared_ptr<::ome::xml::meta::OMEXMLMetadata>
166  createOMEXMLMetadata(const FormatReader& reader,
167  bool doPlane = false,
168  bool doImageName = true);
169 
170 
177  std::shared_ptr<::ome::xml::meta::MetadataRoot>
178  createOMEXMLRoot(const std::string& document);
179 
188  std::shared_ptr<::ome::xml::meta::OMEXMLMetadata>
189  getOMEXMLMetadata(std::shared_ptr<::ome::xml::meta::MetadataRetrieve>& retrieve);
190 
202  std::string
204  bool validate = true);
205 
212  bool
213  validateOMEXML(const std::string& document);
214 
229  bool
231  bool correct);
232 
243  void
245  const FormatReader& reader,
246  bool doPlane = false,
247  bool doImageName = true);
248 
258  void
260  const std::vector<std::shared_ptr<CoreMetadata>> seriesList,
261  bool doPlane = false);
262 
271  void
273  const FormatReader& reader);
274 
283  void
285  const FormatReader& reader);
286 
296  void
298  const CoreMetadata& seriesMetadata,
299  dimension_size_type series);
300 
310  void
312  dimension_size_type series,
313  bool resolve = true);
314 
322  Modulo
323  getModuloAlongZ(const ::ome::xml::meta::OMEXMLMetadata& omexml,
324  dimension_size_type image);
325 
333  Modulo
334  getModuloAlongT(const ::ome::xml::meta::OMEXMLMetadata& omexml,
335  dimension_size_type image);
336 
344  Modulo
345  getModuloAlongC(const ::ome::xml::meta::OMEXMLMetadata& omexml,
346  dimension_size_type image);
347 
356  Modulo
357  getModulo(const ::ome::xml::meta::OMEXMLMetadata& omexml,
358  const std::string& tag,
359  dimension_size_type image);
360 
368  void
370  dimension_size_type series = 0U);
371 
377  void
379 
385  void
387 
396  void
398  dimension_size_type image,
399  dimension_size_type sizeC);
400 
407  MetadataMap
409 
416  void
418  const MetadataMap& metadata);
419 
425  bool
427 
433  std::string
434  getModelVersion();
435 
442  std::string
444 
451  std::string
452  getModelVersion(const std::string& document);
453 
460  std::string
461  transformToLatestModelVersion(const std::string& document);
462 
473  void
474  defaultCreationDateEnabled(bool enabled);
475 
490  void
492  dimension_size_type series,
493  const boost::filesystem::path& id);
494 
509  createDimensionOrder(const std::string& order);
510 
522  pixelSize(const ::ome::xml::meta::MetadataRetrieve& meta,
523  dimension_size_type series);
524 
535  pixelSize(const ::ome::xml::meta::MetadataRetrieve& meta);
536 
537 
549  significantPixelSize(const ::ome::xml::meta::MetadataRetrieve& meta,
550  dimension_size_type series);
551 
562  significantPixelSize(const ::ome::xml::meta::MetadataRetrieve& meta);
563 
564  }
565 }
566 
567 #endif // OME_FILES_METADATATOOLS_H
568 
569 /*
570  * Local Variables:
571  * mode:C++
572  * End:
573  */
bool defaultCreationDateEnabled()
Check if default creation date is enabled.
Definition: MetadataTools.cpp:1189
bool validateModel(::ome::xml::meta::Metadata &meta, bool correct)
Validate a metadata store.
Definition: MetadataTools.cpp:397
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:58
uint64_t storage_size_type
Size type for storage size.
Definition: Types.h:64
std::string getOMEXML(::ome::xml::meta::OMEXMLMetadata &omexml, bool validate)
Get OME-XML document from OME-XML metadata.
Definition: MetadataTools.cpp:379
void fillOriginalMetadata(::ome::xml::meta::OMEXMLMetadata &omexml, const MetadataMap &metadata)
Create OriginalMetadataAnnotations from MetadataMap.
Definition: MetadataTools.cpp:1042
void removeBinData(::ome::xml::meta::OMEXMLMetadata &omexml)
Remove all BinData elements from OME-XML metadata.
Definition: MetadataTools.cpp:873
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:933
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:643
Modulo getModuloAlongT(const ::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type image)
Get ModuloAlongT annotation from OME-XML metadata.
Definition: MetadataTools.cpp:738
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:178
std::shared_ptr<::ome::xml::meta::OMEXMLMetadata > createOMEXMLMetadata(ome::common::xml::dom::Document &document)
Create OME-XML metadata from DOM Document.
Definition: MetadataTools.cpp:224
std::shared_ptr<::ome::xml::meta::MetadataRoot > createOMEXMLRoot(const std::string &document)
Create OME-XML metadata root from XML document.
Definition: MetadataTools.cpp:348
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:707
Modulo getModuloAlongC(const ::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type image)
Get ModuloAlongC annotation from OME-XML metadata.
Definition: MetadataTools.cpp:745
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:1276
Open Microscopy Environment C++.
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:1201
std::shared_ptr<::ome::xml::meta::OMEXMLMetadata > getOMEXMLMetadata(std::shared_ptr<::ome::xml::meta::MetadataRetrieve > &retrieve)
Get OME-XML metadata from metadata.
Definition: MetadataTools.cpp:357
std::string transformToLatestModelVersion(const std::string &document)
Transform an OME-XML document to the latest model version.
Definition: MetadataTools.cpp:1176
bool validateOMEXML(const std::string &document)
Validate an OME-XML document.
Definition: MetadataTools.cpp:391
MetadataMap getOriginalMetadata(::ome::xml::meta::OMEXMLMetadata &omexml)
Get original metadata from OME-XML metadata StructuredAnnotations.
Definition: MetadataTools.cpp:960
void verifyMinimum(::ome::xml::meta::MetadataRetrieve &retrieve, dimension_size_type series)
Verify correctness of minimal amount of metadata in a series.
Definition: MetadataTools.cpp:825
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:752
Modulo getModuloAlongZ(const ::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type image)
Get ModuloAlongZ annotation from OME-XML metadata.
Definition: MetadataTools.cpp:731
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:516
ome::xml::model::enums::DimensionOrder createDimensionOrder(const std::string &order)
Create a valid DimensionOrder from string.
Definition: MetadataTools.cpp:1215
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:1241
void removeTiffData(::ome::xml::meta::OMEXMLMetadata &omexml)
Remove all TiffData elements from OME-XML metadata.
Definition: MetadataTools.cpp:902
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:630
std::string getModelVersion()
Get the currently-supported OME Data Model version.
Definition: MetadataTools.cpp:1097