]> Creatis software - creaBruker.git/blob - lib/src1/brukerdataset.h
Initial revision
[creaBruker.git] / lib / src1 / brukerdataset.h
1 //
2 // C++ Interface: brukerdataset
3 //
4 // Description: 
5 //
6 //
7 // Author:  <Denis Grenier>, (C) 2008
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 #ifndef BRUKERDATASET_H
13 #define BRUKERDATASET_H
14
15 /*! \file brukerdataset.h
16 */
17 #include <cstdlib>
18 #include <stdlib.h>
19 #include <string>
20 #include <iostream>
21 #include <sstream>
22 #include <stdio.h>
23 #include <fstream>
24 #include <map>
25 #include <algorithm>
26 #include "boost/regex.hpp"
27
28 #include "brukerSystem.h"
29 #include "brukerFieldData.h"
30 #include "brukerobjectvaryingproperties.h"
31
32     const boost::regex KeyWord("^##\\$?([^[:cntrl:]]+)=.*");
33     const boost::regex UnsignedInteger("([0-9]+)");
34     const boost::regex SignedInteger("(\\-?[0-9]+)");
35     const boost::regex Float("([\\-\\+eE0-9\\.]+)");
36     const boost::regex IntOrFloat("([\\-\\+eE0-9\\.]+)");
37     const boost::regex Dimensionnality("=\\( ([^[:cntrl:]]+) \\)");
38     const boost::regex BufferNValues("^##\\$?[^[:cntrl:]]+=\\( [^[:cntrl:]]+ \\)[[:space:]]*[[:cntrl:]]*([^[.dollar-sign.]]+).*");
39     const boost::regex Buffer1Value("^##\\$?[^[:cntrl:]]+=(.*)");
40     const boost::regex IntSeries("([\\-0-9]*[[:space:]]*[[:cntrl:]]*)+");
41     const boost::regex FloatSeries("([\\-\\+eE0-9\\.]+[[:space:]]*[[:cntrl:]]*)+");
42
43
44 /*! \class  BrukerDataSet
45 \brief This class purpose is to extract information from a bruker experiment and setup the extracted information for an easy use
46 */
47
48 class creaBruker_EXPORT BrukerDataSet{
49 friend class BrukerKspaceObject;
50     typedef std::map<std::string, BrukerFieldData> BrukMapType;
51     //typedef BrukMapType::iterator iterator;
52     //typedef BrukMapType::const_iterator const_iterator;
53 public:
54         BrukerDataSet();
55         ~BrukerDataSet();
56         bool LoadFile(std::string& FileToRead);
57         bool FillMap();
58         void PrintKey(std::string &);
59         void PrintSelf();
60         bool                   Getkspace (std::string &);
61         const BrukerFieldData& GetFieldData(std::string &);
62         const BrukerFieldData& GetFieldData(const char *);
63         bool                   SetLoopStructure ( );
64         bool                   SetLoopStructureOld ( );
65         bool                   SetLoopStructure (const std::vector<int >& theValue);
66         std::vector<int >      GetLoopStructure ( ) const;
67         bool                   SetBrukerObjectsLineList( );
68         bool                   SetBrukerImageList ( );
69         
70         std::vector<std::vector <int > >        GetBrukerObjectsLineList() const;
71         std::vector<std::vector <int > >        GetBrukerImageList() const;
72         std::map<std::string, BrukerFieldData > GetBrukerHeaderMap() const;
73
74         bool              SetInnerObjectLoopStructure ();
75         std::vector<int > GetInnerObjectLoopStructure() const;
76         bool              SetOuterObjectLoopStructure ();
77         std::vector<int > GetOuterObjectLoopStructure() const;
78         bool              SetImageLoopStructure ();
79         std::vector<int > GetImageLoopStructure() const;
80                 
81         BrukerObjectVaryingProperties ObjectVaryingProperties;
82 private:
83
84     std::string GetKeyword                (std::string &kw);
85     std::string SearchBufferForText       (std::string &kw, const boost::regex& RegExp);
86     bool        BoolMatchBufferForText    (std::string &kw, const boost::regex& RegExp);
87     std::string MatchBufferForText        (std::string &kw, const boost::regex& RegExp);
88     int         GetDimensionnality        (std::string &kw);
89     int         GetIntValueOfDimN         (std::string &kw, int n);
90     int         GetIntValueN              (std::string &kw, int n);
91     std::string GetContentType            (std::string &kw);
92     std::string GetValuesPart             (std::string &kw);
93     double      GetDoubleValueN           (std::string &kw, int n);
94     int         GetKeywordNumberOfElements(std::string &kw);
95     std::string GetTextValueN             (std::string &kw, int n);
96     bool        CheckExistKeyword         (std::string &kw);
97     bool        CheckExistKeyword         (const char *kw);
98     
99     //BrukMapType 
100
101     std::map<std::string, BrukerFieldData> BrukerHeaderMap;
102     std::string                     WholeHeader;
103     std::vector<double>             WholeKspace;    
104     std::vector<int>                LoopStructure;
105     std::vector<int>                InnerObjectLoopStructure;
106     std::vector<int>                OuterObjectLoopStructure;
107     std::vector<int>                ImageLoopStructure;
108     std::vector <std::vector<int> > BrukerObjectsLineList;
109     std::vector <std::vector<int> > BrukerImageList;
110
111 protected:
112 };
113
114 #endif