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 const Protocol& protocol() const {return prot_cache;}
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 JDXint maxrecursion;
00169 JDXbool conjPhaseFT;
00170 JDXbool slidingWindow;
00171 JDXbool keyhole;
00172 JDXbool sepChannels;
00173 JDXbool dumpKspace;
00174 JDXbool disableHomodyne;
00175 JDXbool disableMultiFreq;
00176 JDXbool disableSliceTime;
00177 JDXbool phaseCourse;
00178 JDXstring preproc3d;
00179 JDXstring postproc3d;
00180 JDXstring dumpRawPrefix;
00181 JDXstring fieldmapFile;
00182
00183 bool execute_pipeline();
00184 bool prepare_pipeline();
00185 bool finalize_pipeline();
00186
00187 bool feed_pipeline();
00188
00189 bool dump_raw() const;
00190
00191 static void tracefunction(const LogMessage& msg);
00192 static int controlthread;
00193
00194 template<recoDim Dim, recoDim OrthoDim>
00195 bool get_kspace_sampling_pattern(const RecoCoord& mask, unsigned int& reduction_factor, bool& partial_fourier) const;
00196
00197 bool autorecipe(const RecoCoord& mask, STD_string& result) const;
00198
00199 typedef STD_map<int, STD_string> WaitingMap;
00200 WaitingMap waiting;
00201 STD_string waiting_error;
00202 Mutex waiting_mutex;
00203
00204 void incr_waiting_threads(const STD_string& condition) {MutexLock lock(waiting_mutex); waiting[Thread::self()]=condition;}
00205 void decr_waiting_threads() {MutexLock lock(waiting_mutex); waiting.erase(waiting.find(Thread::self()));}
00206 unsigned int numof_waiting_threads() {MutexLock lock(waiting_mutex); return waiting.size();}
00207
00208 STD_map<int, UInt> thread_depth;
00209
00210 RecoReaderInterface* input;
00211 mutable Mutex inputmutex;
00212
00213 RecoStep* pipeline;
00214 RecoStepFactory* factory;
00215
00216 RecoBlackBoard blackboard;
00217
00218 ProgressDisplayConsole display;
00219 ProgressMeter pmeter;
00220
00221
00222 unsigned short numof_cache[n_recoDims];
00223 mutable bool has_readoutshape;
00224 mutable unsigned char has_flag_cache;
00225 mutable bool has_templcorr_cache[n_templateTypes];
00226 mutable bool has_navigator_cache[n_navigatorTypes];
00227 mutable bool has_traj;
00228 mutable bool has_oversampling_cache;
00229 mutable bool has_relcenter_cache;
00230
00231 Protocol prot_cache;
00232
00233 volatile bool status;
00234
00235 mutable STD_map<STD_string,const CoordCountMap*> countmap_cache;
00236 void delete_countmap_cache();
00237
00238 };
00239
00240
00241
00246 #endif
00247