ome-files 0.2.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/files/FormatReader.h>
43 #include <ome/files/MetadataMap.h>
44 #include <ome/files/Types.h>
45
46 #include <ome/xml/meta/Metadata.h>
47 #include <ome/xml/meta/MetadataRoot.h>
48 #include <ome/xml/meta/OMEXMLMetadata.h>
49
50 #include <ome/xml/model/enums/DimensionOrder.h>
51
52 #ifndef OME_FILES_METADATATOOLS_H
53 #define OME_FILES_METADATATOOLS_H
54
55 namespace ome
56 {
57 namespace files
58 {
59
60 // Use overloaded functions for creating identifiers since
61 // pre-C++11 compilers don't support the C99 stdarg interface.
62
70 std::string
71 createID(std::string const& type,
72 dimension_size_type idx);
73
82 std::string
83 createID(std::string const& type,
84 dimension_size_type idx1,
85 dimension_size_type idx2);
86
96 std::string
97 createID(std::string const& type,
98 dimension_size_type idx1,
99 dimension_size_type idx2,
100 dimension_size_type idx3);
101
112 std::string
113 createID(std::string const& type,
114 dimension_size_type idx1,
115 dimension_size_type idx2,
116 dimension_size_type idx3,
117 dimension_size_type idx4);
118
125 ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
126 createOMEXMLMetadata(ome::common::xml::dom::Document& document);
127
134 ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
135 createOMEXMLMetadata(const boost::filesystem::path& file);
136
143 ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
144 createOMEXMLMetadata(const std::string& text);
145
152 ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
153 createOMEXMLMetadata(std::istream& stream);
154
163 ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
164 createOMEXMLMetadata(const FormatReader& reader,
165 bool doPlane = false,
166 bool doImageName = true);
167
168
175 ome::compat::shared_ptr< ::ome::xml::meta::MetadataRoot>
176 createOMEXMLRoot(const std::string& document);
177
186 ome::compat::shared_ptr< ::ome::xml::meta::OMEXMLMetadata>
187 getOMEXMLMetadata(ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve>& retrieve);
188
200 std::string
201 getOMEXML(::ome::xml::meta::OMEXMLMetadata& omexml,
202 bool validate = true);
203
210 bool
211 validateOMEXML(const std::string& document);
212
227 bool
228 validateModel(::ome::xml::meta::Metadata& meta,
229 bool correct);
230
241 void
242 fillMetadata(::ome::xml::meta::MetadataStore& store,
243 const FormatReader& reader,
244 bool doPlane = false,
245 bool doImageName = true);
246
256 void
257 fillMetadata(::ome::xml::meta::MetadataStore& store,
258 const std::vector<ome::compat::shared_ptr<CoreMetadata> > seriesList,
259 bool doPlane = false);
260
269 void
270 fillAllPixels(::ome::xml::meta::MetadataStore& store,
271 const FormatReader& reader);
272
281 void
282 fillPixels(::ome::xml::meta::MetadataStore& store,
283 const FormatReader& reader);
284
294 void
295 fillPixels(::ome::xml::meta::MetadataStore& store,
296 const CoreMetadata& seriesMetadata,
297 dimension_size_type series);
298
308 void
309 addMetadataOnly(::ome::xml::meta::OMEXMLMetadata& omexml,
310 dimension_size_type series,
311 bool resolve = true);
312
320 Modulo
321 getModuloAlongZ(const ::ome::xml::meta::OMEXMLMetadata& omexml,
322 dimension_size_type image);
323
331 Modulo
332 getModuloAlongT(const ::ome::xml::meta::OMEXMLMetadata& omexml,
333 dimension_size_type image);
334
342 Modulo
343 getModuloAlongC(const ::ome::xml::meta::OMEXMLMetadata& omexml,
344 dimension_size_type image);
345
354 Modulo
355 getModulo(const ::ome::xml::meta::OMEXMLMetadata& omexml,
356 const std::string& tag,
357 dimension_size_type image);
358
366 void
367 verifyMinimum(::ome::xml::meta::MetadataRetrieve& retrieve,
368 dimension_size_type series = 0U);
369
375 void
376 removeBinData(::ome::xml::meta::OMEXMLMetadata& omexml);
377
383 void
384 removeTiffData(::ome::xml::meta::OMEXMLMetadata& omexml);
385
394 void
395 removeChannels(::ome::xml::meta::OMEXMLMetadata& omexml,
396 dimension_size_type image,
397 dimension_size_type sizeC);
398
405 MetadataMap
406 getOriginalMetadata(::ome::xml::meta::OMEXMLMetadata& omexml);
407
414 void
415 fillOriginalMetadata(::ome::xml::meta::OMEXMLMetadata& omexml,
416 const MetadataMap& metadata);
417
423 bool
424 defaultCreationDateEnabled();
425
431 std::string
432 getModelVersion();
433
440 std::string
441 getModelVersion(ome::common::xml::dom::Document& document);
442
449 std::string
450 getModelVersion(const std::string& document);
451
458 std::string
459 transformToLatestModelVersion(const std::string& document);
460
471 void
472 defaultCreationDateEnabled(bool enabled);
473
488 void
489 setDefaultCreationDate(::ome::xml::meta::MetadataStore& store,
490 dimension_size_type series,
491 const boost::filesystem::path& id);
492
506 ome::xml::model::enums::DimensionOrder
507 createDimensionOrder(const std::string& order);
508
519 storage_size_type
520 pixelSize(const ::ome::xml::meta::MetadataRetrieve& meta,
521 dimension_size_type series);
522
532 storage_size_type
533 pixelSize(const ::ome::xml::meta::MetadataRetrieve& meta);
534
535
546 storage_size_type
547 significantPixelSize(const ::ome::xml::meta::MetadataRetrieve& meta,
548 dimension_size_type series);
549
559 storage_size_type
560 significantPixelSize(const ::ome::xml::meta::MetadataRetrieve& meta);
561
562 }
563 }
564
565 #endif // OME_FILES_METADATATOOLS_H
566
567 /*
568 * Local Variables:
569 * mode:C++
570 * End:
571 */
ome::files::defaultCreationDateEnabled
bool defaultCreationDateEnabled()
Check if default creation date is enabled.
Definition: MetadataTools.cpp:1194
ome::files::validateModel
bool validateModel(::ome::xml::meta::Metadata &meta, bool correct)
Validate a metadata store.
Definition: MetadataTools.cpp:396
ome::files::dimension_size_type
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
ome::files::storage_size_type
uint64_t storage_size_type
Size type for storage size.
Definition: Types.h:65
ome::files::getOMEXML
std::string getOMEXML(::ome::xml::meta::OMEXMLMetadata &omexml, bool validate)
Get OME-XML document from OME-XML metadata.
Definition: MetadataTools.cpp:378
ome::files::fillOriginalMetadata
void fillOriginalMetadata(::ome::xml::meta::OMEXMLMetadata &omexml, const MetadataMap &metadata)
Create OriginalMetadataAnnotations from MetadataMap.
Definition: MetadataTools.cpp:1047
ome::files::removeBinData
void removeBinData(::ome::xml::meta::OMEXMLMetadata &omexml)
Remove all BinData elements from OME-XML metadata.
Definition: MetadataTools.cpp:876
ome::files::removeChannels
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:938
ome::common::xml::dom::Document
ome::files::fillPixels
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:644
ome::files::getModuloAlongT
Modulo getModuloAlongT(const ::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type image)
Get ModuloAlongT annotation from OME-XML metadata.
Definition: MetadataTools.cpp:739
ome::files::createOMEXMLRoot
ome::compat::shared_ptr< ::ome::xml::meta::MetadataRoot > createOMEXMLRoot(const std::string &document)
Create OME-XML metadata root from XML document.
Definition: MetadataTools.cpp:347
ome::files::createID
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
ome::xml::meta::MetadataStore
ome::xml::model::enums::DimensionOrder
ome::files::addMetadataOnly
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:708
ome::files::getModuloAlongC
Modulo getModuloAlongC(const ::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type image)
Get ModuloAlongC annotation from OME-XML metadata.
Definition: MetadataTools.cpp:746
ome::files::significantPixelSize
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:1285
ome::files::createOMEXMLMetadata
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:224
ome
Open Microscopy Environment C++.
ome::files::setDefaultCreationDate
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:1206
ome::files::transformToLatestModelVersion
std::string transformToLatestModelVersion(const std::string &document)
Transform an OME-XML document to the latest model version.
Definition: MetadataTools.cpp:1181
ome::xml::meta::OMEXMLMetadata
ome::files::validateOMEXML
bool validateOMEXML(const std::string &document)
Validate an OME-XML document.
Definition: MetadataTools.cpp:390
ome::files::getOMEXMLMetadata
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:356
ome::files::getOriginalMetadata
MetadataMap getOriginalMetadata(::ome::xml::meta::OMEXMLMetadata &omexml)
Get original metadata from OME-XML metadata StructuredAnnotations.
Definition: MetadataTools.cpp:965
ome::xml::meta::MetadataRetrieve
ome::files::verifyMinimum
void verifyMinimum(::ome::xml::meta::MetadataRetrieve &retrieve, dimension_size_type series)
Verify correctness of minimal amount of metadata in a series.
Definition: MetadataTools.cpp:828
ome::files::getModulo
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:753
ome::files::getModuloAlongZ
Modulo getModuloAlongZ(const ::ome::xml::meta::OMEXMLMetadata &omexml, dimension_size_type image)
Get ModuloAlongZ annotation from OME-XML metadata.
Definition: MetadataTools.cpp:732
ome::xml::meta::Metadata
ome::files::fillMetadata
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:517
ome::files::createDimensionOrder
ome::xml::model::enums::DimensionOrder createDimensionOrder(const std::string &order)
Create a valid DimensionOrder from string.
Definition: MetadataTools.cpp:1220
ome::files::pixelSize
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:1250
ome::files::removeTiffData
void removeTiffData(::ome::xml::meta::OMEXMLMetadata &omexml)
Remove all TiffData elements from OME-XML metadata.
Definition: MetadataTools.cpp:907
ome::files::fillAllPixels
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:631
ome::files::getModelVersion
std::string getModelVersion()
Get the currently-supported OME Data Model version.
Definition: MetadataTools.cpp:1102