00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef RECOCONTROLLER_H
00019 #define RECOCONTROLLER_H
00020
00021 #include <tjutils/tjthread.h>
00022 #include <tjutils/tjfeedback.h>
00023
00024 #include <odinreco/odinreco.h>
00025 #include <odinreco/blackboard.h>
00026 #include <odinreco/step.h>
00027
00028
00029
00038 class RecoReaderInterface;
00039 class RecoStep;
00040
00041
00042
00044
00045
00049 class RecoController {
00050
00051 public:
00052
00056 RecoController(JcampDxBlock& parblock);
00057
00058 ~RecoController();
00059
00064 bool init(RecoReaderInterface* reader, JcampDxBlock& opts, int argc, char* argv[]);
00065
00071 bool start();
00072
00076 dvector dim_values(recoDim dim) const;
00077
00082 TinyVector<float,3> reloffset() const;
00083
00087 STD_string image_proc() const;
00088
00093 TinyVector<int,3> image_size() const;
00094
00098 TinyVector<float,3> kspace_extent() const;
00099
00103 Protocol protocol() const;
00104
00105
00109 void announce_data(const STD_string& label) {blackboard.announce(label);}
00110
00114 void post_data(const STD_string& label, const RecoData& data) {blackboard.post(label,data);}
00115
00119 bool data_announced(const STD_string& label) {return blackboard.announced(label);}
00120
00126 bool inquire_data(const STD_string& label, RecoData& data);
00127
00128
00134 const CoordCountMap* create_count_map(const RecoCoord& mask) const;
00135
00141 bool create_numof(const RecoCoord& mask, unsigned short numof[n_recoDims], STD_string& printed) const;
00142
00143
00149 RecoStep* create_pipeline(const STD_string& rec, const RecoCoord* initial_coord=0, int argc=0, char* argv[]=0) const;
00150
00151
00155 STD_string stepmanual() const;
00156
00157
00158 private:
00159 friend class RecoThread;
00160
00161
00162
00163 JDXint jobs;
00164 JDXstring recipe;
00165 JDXstring recipeFile;
00166 JDXstring select;
00167 JDXint timeout;
00168 JDXbool conjPhaseFT;
00169 JDXbool slidingWindow;
00170 JDXbool sepChannels;
00171 JDXbool dumpKspace;
00172 JDXbool disableHomodyne;
00173 JDXbool phaseCourse;
00174 JDXstring preproc3d;
00175 JDXstring postproc3d;
00176 JDXstring dumpRawPrefix;
00177 JDXstring fieldmapFile;
00178
00179 bool execute_pipeline();
00180 bool prepare_pipeline();
00181 bool finalize_pipeline();
00182
00183 bool feed_pipeline();
00184
00185 bool dump_raw() const;
00186
00187 static void tracefunction(const LogMessage& msg);
00188 static int controlthread;
00189
00190 template<recoDim Dim, recoDim OrthoDim>
00191 bool get_kspace_sampling_pattern(const RecoCoord& mask, unsigned int& reduction_factor, bool& partial_fourier) const;
00192
00193 bool autorecipe(const RecoCoord& mask, STD_string& result) const;
00194
00195 typedef STD_map<int, STD_string> WaitingMap;
00196 WaitingMap waiting;
00197 STD_string waiting_error;
00198 Mutex waiting_mutex;
00199
00200 void incr_waiting_threads(const STD_string& condition) {MutexLock lock(waiting_mutex); waiting[Thread::self()]=condition;}
00201 void decr_waiting_threads() {MutexLock lock(waiting_mutex); waiting.erase(waiting.find(Thread::self()));}
00202 unsigned int numof_waiting_threads() {MutexLock lock(waiting_mutex); return waiting.size();}
00203
00204 RecoReaderInterface* input;
00205 mutable Mutex inputmutex;
00206
00207 RecoStep* pipeline;
00208 RecoStepFactory* factory;
00209
00210 RecoBlackBoard blackboard;
00211
00212 ProgressDisplayConsole display;
00213 ProgressMeter pmeter;
00214
00215
00216 unsigned short numof_cache[n_recoDims];
00217 mutable bool has_readoutshape;
00218 mutable unsigned char has_flag_cache;
00219 mutable bool has_templcorr_cache[n_templateTypes];
00220 mutable bool has_navigator_cache[n_navigatorTypes];
00221 mutable bool has_traj;
00222 mutable float oversampling_cache;
00223
00224 Protocol dummyprot;
00225
00226 volatile bool status;
00227
00228 mutable STD_map<STD_string,const CoordCountMap*> countmap_cache;
00229 void delete_countmap_cache();
00230
00231 };
00232
00233
00234
00239 #endif
00240