]> Creatis software - creaBruker.git/blob - lib/src1/brukerdataset.h
aeb75e4fc6bcaaa1c09c5d26c0be471e94737cf9
[creaBruker.git] / lib / src1 / brukerdataset.h
1 /*
2         # ---------------------------------------------------------------------
3         #
4         # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5         #                        pour la Santé)
6         # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7         # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8         # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9         #
10         #  This software is governed by the CeCILL-B license under French law and 
11         #  abiding by the rules of distribution of free software. You can  use, 
12         #  modify and/ or redistribute the software under the terms of the CeCILL-B 
13         #  license as circulated by CEA, CNRS and INRIA at the following URL 
14         #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
15         #  or in the file LICENSE.txt.
16         #
17         #  As a counterpart to the access to the source code and  rights to copy,
18         #  modify and redistribute granted by the license, users are provided only
19         #  with a limited warranty  and the software's author,  the holder of the
20         #  economic rights,  and the successive licensors  have only  limited
21         #  liability. 
22         #
23         #  The fact that you are presently reading this means that you have had
24         #  knowledge of the CeCILL-B license and that you accept its terms.
25         # ------------------------------------------------------------------------
26 */
27 //
28 // C++ Interface: brukerdataset
29 //
30 // Description: 
31 //
32 //
33 // Author:  <Denis Grenier>, (C) 2008
34 //
35 // Copyright: See COPYING file that comes with this distribution
36 //
37 //
38 #ifndef BRUKERDATASET_H
39 #define BRUKERDATASET_H
40
41 /*! \file brukerdataset.h
42 */
43 #include <cstdlib>
44 #include <stdlib.h>
45 #include <string>
46 #include <iostream>
47 #include <sstream>
48 #include <stdio.h>
49 #include <fstream>
50 #include <map>
51 #include <algorithm>
52 #include "boost/regex.hpp"
53
54 #include "brukerSystem.h"
55 #include "brukerFieldData.h"
56 #include "brukerobjectvaryingproperties.h"
57
58     const boost::regex KeyWord("^##\\$?([^[:cntrl:]]+)=.*");
59     const boost::regex UnsignedInteger("([0-9]+)");
60     const boost::regex SignedInteger("(\\-?[0-9]+)");
61     const boost::regex Float("([\\-\\+eE0-9\\.]+)");
62     const boost::regex IntOrFloat("([\\-\\+eE0-9\\.]+)");
63     const boost::regex Dimensionnality("=\\( ([^[:cntrl:]]+) \\)");
64     const boost::regex BufferNValues("^##\\$?[^[:cntrl:]]+=\\( [^[:cntrl:]]+ \\)[[:space:]]*[[:cntrl:]]*([^[.dollar-sign.]]+).*");
65     const boost::regex Buffer1Value("^##\\$?[^[:cntrl:]]+=(.*)");
66     const boost::regex IntSeries("([\\-0-9]*[[:space:]]*[[:cntrl:]]*)+");
67     const boost::regex FloatSeries("([\\-\\+eE0-9\\.]+[[:space:]]*[[:cntrl:]]*)+");
68
69
70 /*! \class  BrukerDataSet
71 \brief This class purpose is to extract information from a bruker experiment and setup the extracted information for an easy use
72 */
73
74 class creaBruker_EXPORT BrukerDataSet{
75 friend class BrukerKspaceObject;
76     typedef std::map<std::string, BrukerFieldData> BrukMapType;
77     //typedef BrukMapType::iterator iterator;
78     //typedef BrukMapType::const_iterator const_iterator;
79 public:
80         BrukerDataSet();
81         ~BrukerDataSet();
82         bool LoadFile(std::string FileToRead);
83         bool FillMap();
84         void PrintKey(std::string &);
85         void PrintSelf();
86         bool                   Getkspace (std::string &);
87         const BrukerFieldData& GetFieldData(std::string &);
88         const BrukerFieldData& GetFieldData(const char *);
89         bool                   SetLoopStructure ( int dimension);
90         bool                   SetLoopStructureOld ( );
91         bool                   SetLoopStructure (const std::vector<int >& theValue);
92         std::vector<int >      GetLoopStructure ( ) const;
93         bool                   SetBrukerObjectsLineList( );
94         bool                   SetBrukerImageList ( );
95         
96         std::vector<std::vector <int > >        GetBrukerObjectsLineList() const;
97         std::vector<std::vector <int > >        GetBrukerImageList() const;
98         std::map<std::string, BrukerFieldData > GetBrukerHeaderMap() const;
99
100         bool              SetInnerObjectLoopStructure (int dimension);
101         std::vector<int > GetInnerObjectLoopStructure() const;
102         bool              SetOuterObjectLoopStructure (int dimension);
103         std::vector<int > GetOuterObjectLoopStructure() const;
104         bool              SetImageLoopStructure ();
105         std::vector<int > GetImageLoopStructure() const;
106                 
107         BrukerObjectVaryingProperties ObjectVaryingProperties;
108 private:
109
110     std::string GetKeyword                (std::string &kw);
111     std::string SearchBufferForText       (std::string &kw, const boost::regex& RegExp);
112     bool        BoolMatchBufferForText    (std::string &kw, const boost::regex& RegExp);
113     std::string MatchBufferForText        (std::string &kw, const boost::regex& RegExp);
114     int         GetDimensionnality        (std::string &kw);
115     int         GetIntValueOfDimN         (std::string &kw, int n);
116     int         GetIntValueN              (std::string &kw, int n);
117     std::string GetContentType            (std::string &kw);
118     std::string GetValuesPart             (std::string &kw);
119     double      GetDoubleValueN           (std::string &kw, int n);
120     int         GetKeywordNumberOfElements(std::string &kw);
121     std::string GetTextValueN             (std::string &kw, int n);
122     bool        CheckExistKeyword         (std::string &kw);
123     bool        CheckExistKeyword         (const char *kw);
124     std::string RemoveNewlines(std::string);
125     std::string RemoveSpaces(std::string);
126     
127     //BrukMapType 
128
129     std::map<std::string, BrukerFieldData> BrukerHeaderMap;
130     std::string                     WholeHeader;
131     std::vector<double>             WholeKspace;    
132     std::vector<int>                LoopStructure;
133     std::vector<int>                InnerObjectLoopStructure;
134     std::vector<int>                OuterObjectLoopStructure;
135     std::vector<int>                ImageLoopStructure;
136     std::vector <std::vector<int> > BrukerObjectsLineList;
137     std::vector <std::vector<int> > BrukerImageList;
138
139 protected:
140 };
141
142 #endif