CiftiLib
A C++ library for CIFTI-2 and CIFTI-1 files
CiftiParcelsMap.h
1#ifndef __CIFTI_PARCELS_MAP_H__
2#define __CIFTI_PARCELS_MAP_H__
3
4/*LICENSE_START*/
5/*
6 * Copyright (c) 2014, Washington University School of Medicine
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without modification,
10 * are permitted provided that the following conditions are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include "CiftiMappingType.h"
32
33#include "Common/Compact3DLookup.h"
34#include "StructureEnum.h"
35#include "VolumeSpace.h"
36#include "Common/VoxelIJK.h"
37
38#include <map>
39#include <set>
40#include <vector>
41
42namespace cifti
43{
45 {
46 public:
47 struct Parcel
48 {
49 std::map<StructureEnum::Enum, std::set<int64_t> > m_surfaceNodes;
50 std::set<VoxelIJK> m_voxelIndices;
51 AString m_name;
52 bool operator==(const Parcel& rhs) const;
53 bool operator!=(const Parcel& rhs) const { return !((*this) == rhs); }
54 bool approximateMatch(const Parcel& rhs, AString* explanation = NULL) const;
55 };
56 bool hasVolumeData() const;
57 bool hasSurface(const StructureEnum::Enum& structure) const;//only checks whether surface has been added/read
58 bool hasSurfaceData(const StructureEnum::Enum& structure) const;
59 const VolumeSpace& getVolumeSpace() const;
60 int64_t getSurfaceNumberOfNodes(const StructureEnum::Enum& structure) const;
61 int64_t getIndexForNode(const int64_t& node, const StructureEnum::Enum& structure) const;
62 int64_t getIndexForVoxel(const int64_t* ijk) const;
63 int64_t getIndexForVoxel(const int64_t& i, const int64_t& j, const int64_t& k) const;
64 std::vector<StructureEnum::Enum> getParcelSurfaceStructures() const;
65 const std::vector<Parcel>& getParcels() const { return m_parcels; }
66
67 CiftiParcelsMap() { m_haveVolumeSpace = false; m_ignoreVolSpace = false; }
68 void addSurface(const int64_t& numberOfNodes, const StructureEnum::Enum& structure);
69 void setVolumeSpace(const VolumeSpace& space);
70 void addParcel(const Parcel& parcel);
71 void clear();
72
73 CiftiMappingType* clone() const { return new CiftiParcelsMap(*this); }
74 MappingType getType() const { return PARCELS; }
75 int64_t getLength() const { return m_parcels.size(); }
76 bool operator==(const CiftiMappingType& rhs) const;
77 bool approximateMatch(const CiftiMappingType& rhs, AString* explanation = NULL) const;
78 void readXML1(XmlReader& xml);
79 void readXML2(XmlReader& xml);
80 void writeXML1(XmlWriter& xml) const;
81 void writeXML2(XmlWriter& xml) const;
82 private:
83 std::vector<Parcel> m_parcels;
84 VolumeSpace m_volSpace;
85 bool m_haveVolumeSpace, m_ignoreVolSpace;//second is needed for parsing cifti-1;
86 struct SurfaceInfo
87 {
88 int64_t m_numNodes;
89 std::vector<int64_t> m_lookup;
90 };
91 Compact3DLookup<int64_t> m_volLookup;
92 std::map<StructureEnum::Enum, SurfaceInfo> m_surfInfo;
93 static Parcel readParcel1(XmlReader& xml);
94 static Parcel readParcel2(XmlReader& xml);
95 static std::vector<int64_t> readIndexArray(XmlReader& xml);
96 };
97}
98
99#endif //__CIFTI_PARCELS_MAP_H__
Definition CiftiMappingType.h:39
Definition CiftiParcelsMap.h:45
Enum
Definition StructureEnum.h:49
Definition VolumeSpace.h:42
namespace for all CiftiLib functionality
Definition CiftiBrainModelsMap.h:42
Definition CiftiParcelsMap.h:48