CFEL - ASG Software Suite  2.5.0
CASS
hitrate.h
Go to the documentation of this file.
1 // Copyright (C) 2010 Stephan Kassemeyer
2 
3 /**
4  * @file hitrate.h processors for single particle hitfinding
5  *
6  * @author Stephan Kassemeyer
7  */
8 
9 #ifndef _HITRATE_H_
10 #define _HITRATE_H_
11 
12 #include <math.h>
13 #include <vigra/linear_algebra.hxx>
14 #include <vigra/inspectimage.hxx>
15 #include <vigra/multi_pointoperators.hxx>
16 #include <vigra/separableconvolution.hxx>
17 
18 #include "processor.h"
19 
20 namespace cass
21 {
22 /** Single particle hit.
23  *
24  * @PPList "300": detect Single Particle hits.
25  *
26  *
27  * @see Processor for a list of all commonly available cass.ini
28  * settings.
29  *
30  * @cassttng Processor/\%name\%/{ImageName}\n
31  * processor name containing the histogram in which hits should be detected.
32  * @cassttng Processor/\%name\%/{xstart}\n
33  * ROI for calculations. First pixel = 0 (default).
34  * @cassttng Processor/\%name\%/{ystart}\n
35  * ROI for calculations. First pixel = 0 (default).
36  * @cassttng Processor/\%name\%/{xend}\n
37  * ROI for calculations. Last pixel = -1 (default).
38  * @cassttng Processor/\%name\%/{yend}\n
39  * ROI for calculations. Last pixel = -1 (default).
40  * @cassttng Processor/\%name\%/{TrainingSetSize}\n
41  * How many images should be included in training phase. default = 200.
42  * @cassttng Processor/\%name\%/{saveTraining}\n
43  * optional. If true (default), save Training matrices to
44  * files with automaic names in currend directory.
45  * @cassttng Processor/\%name\%/{readTrainingFile}\n
46  * optional filename to read training matrices from.
47  * If setting doesn't exist, training is not read but
48  * calculated on "loadSettings".
49  *
50  * (good ROI for single particle in pnCCD images: xstart=402;xend=485; ystart=402;yend=485;
51  *
52  * @author Stephan Kassemeyer
53  */
54 
55 class pp300 : public Processor
56 {
57 public:
58  /** constructor */
59  pp300(const name_t&);
60 
61  /** virtual destructor */
62  virtual ~pp300();
63 
64  /** check if image specified in settings contains a single particle hit*/
65  virtual void process(const CASSEvent&, result_t&);
66 
67  /** load the settings for this pp */
68  virtual void loadSettings(size_t);
69 
70 protected:
71 
72  /** */
73  void trainingFinished();
74 
75  /** */
76  void startNewTraining();
77 
78  /** */
79  void readTrainingMatrices();
80 
81  /** */
82  void saveTrainingMatrices();
83 
84  /** */
85  void printTrainingMatrices();
86 
87  /** */
88  virtual void clearHistogramEvent();
89 
90  /** */
91  virtual void processCommand(std::string command);
92 
93  /** xstart - ROI for calculations*/
94  int _xstart;
95 
96  /** ystart - ROI for calculations*/
97  int _ystart;
98 
99  /** xend - ROI for calculations*/
100  int _xend;
101 
102  /** yend - ROI for calculations*/
103  int _yend;
104 
105  /** the histogram to work on */
107 
108  // outlier detection processor:
109  typedef vigra::Matrix<double> matrixType;
110 
113 
114  /** user setting: do (default) or don't save training matrices to file */
116 
117  /** if filename is given in settings, load instead of calculate */
119 
120  /** optional user-setting: filename to read training from*/
121  std::string _trainingFile;
122 
123  matrixType _variationFeatures;
124  matrixType _mean; // mean (one scalar per column or feature)
125  // vigra::MultiArray<1,double> _mean; // mean (one scalar per column or feature)
126  matrixType _cov;
127  matrixType _covI;
128  int _trainingSetsInserted; // counts how many training data items are already included in training set.
129  int _reTrain; // manages retraining of mean and covariance matrix used to determine outliers.
130 
131  /** mutex to lock the processing part since only one can be processed at a time */
133 };
134 
135 
136 
137 
138 
139 /** convolute histogram with kernel
140  *
141  * @PPList "313": convolute histogram with kernel
142  *
143  * @see Processor for a list of all commonly available cass.ini
144  * settings.
145  *
146  * @cassttng Processor/\%name\%/{InputName} \n
147  * histogram name, that should be convoluted
148  * @cassttng Processor/\%name\%/{Kernel} \n
149  * Comma separated list of values for the Kernel that should be
150  * convoluted to the histogram
151  *
152  * @author Lutz Foucar
153  */
154 class pp313 : public Processor
155 {
156 public:
157  /** constructor */
158  pp313(const name_t &name);
159 
160  /** process event */
161  virtual void process(const CASSEvent&, result_t&);
162 
163  /** load the settings of the pp */
164  virtual void loadSettings(size_t);
165 
166 protected:
167  /** pp containing input histogram */
169 
170  /** array containing the kernel */
171  std::vector<float> _kernel;
172 
173  /** iterator to the center of the kernel */
174  std::vector<float>::iterator _kernelCenter;
175 
176  /** element to the left of the kernel center */
177  int _kleft;
178 
179  /** elements to the right of the kernel center */
180  int _kright;
181 };
182 
183 
184 
185 
186 }
187 #endif
void readTrainingMatrices()
Definition: hitrate.cpp:48
int _xend
xend - ROI for calculations
Definition: hitrate.h:100
std::vector< float >::iterator _kernelCenter
iterator to the center of the kernel
Definition: hitrate.h:174
pp300(const name_t &)
constructor
Definition: hitrate.cpp:26
Event to store all LCLS Data.
Definition: cass_event.h:32
matrixType _mean
Definition: hitrate.h:124
int _ystart
ystart - ROI for calculations
Definition: hitrate.h:97
std::vector< float > _kernel
array containing the kernel
Definition: hitrate.h:171
virtual void loadSettings(size_t)
load the settings for this pp
Definition: hitrate.cpp:100
const name_t name() const
retrieve the name of this processor
Definition: processor.h:167
matrixType _cov
Definition: hitrate.h:126
shared_pointer _pHist
the histogram to work on
Definition: hitrate.h:106
matrixType _covI
Definition: hitrate.h:127
pp313(const name_t &name)
constructor
Definition: hitrate.cpp:412
void printTrainingMatrices()
Definition: hitrate.cpp:77
Single particle hit.
Definition: hitrate.h:55
int _nTrainingSetSize
Definition: hitrate.h:111
QMutex _mutex
mutex to lock the processing part since only one can be processed at a time
Definition: hitrate.h:132
virtual ~pp300()
virtual destructor
Definition: hitrate.cpp:32
int _nFeatures
Definition: hitrate.h:112
int _yend
yend - ROI for calculations
Definition: hitrate.h:103
void startNewTraining()
Definition: hitrate.cpp:42
virtual void clearHistogramEvent()
Definition: hitrate.cpp:153
shared_pointer _pHist
pp containing input histogram
Definition: hitrate.h:168
convolute histogram with kernel
Definition: hitrate.h:154
virtual void process(const CASSEvent &, result_t &)
check if image specified in settings contains a single particle hit
Definition: hitrate.cpp:173
base class for processors.
Definition: processor.h:39
int _trainingSetsInserted
Definition: hitrate.h:128
int _readTraining
if filename is given in settings, load instead of calculate
Definition: hitrate.h:118
int _kleft
element to the left of the kernel center
Definition: hitrate.h:177
vigra::Matrix< double > matrixType
Definition: hitrate.h:109
matrixType _variationFeatures
Definition: hitrate.h:123
virtual void processCommand(std::string command)
process command in pp
Definition: hitrate.cpp:159
int _kright
elements to the right of the kernel center
Definition: hitrate.h:180
virtual void loadSettings(size_t)
load the settings of the pp
Definition: hitrate.cpp:418
int _saveTraining
user setting: do (default) or don't save training matrices to file
Definition: hitrate.h:115
void saveTrainingMatrices()
Definition: hitrate.cpp:56
file contains processors baseclass declaration
virtual void process(const CASSEvent &, result_t &)
process event
Definition: hitrate.cpp:453
int _reTrain
Definition: hitrate.h:129
void trainingFinished()
Definition: hitrate.cpp:36
std::string name_t
define the name type
Definition: processor.h:46
std::tr1::shared_ptr< Processor > shared_pointer
a shared pointer of this
Definition: processor.h:43
int _xstart
xstart - ROI for calculations
Definition: hitrate.h:94
std::string _trainingFile
optional user-setting: filename to read training from
Definition: hitrate.h:121