QXRD  0.11.16
qxrddataprocessorbase.cpp
Go to the documentation of this file.
1 #define _CRT_SECURE_NO_WARNINGS
2 
3 #include "qxrddebug.h"
6 #include <QtConcurrentRun>
7 #include "qxrdwindow.h"
8 #include "qxrdacquisition.h"
9 #include "qcepimagedata.h"
10 #include "qxrdcenterfinder.h"
11 #include "qxrdintegrator.h"
12 #include "qcepintegrateddata.h"
13 #include "qcepmutexlocker.h"
14 #include "qcepallocator.h"
15 #include "qxrdfilesaverthread.h"
16 #include "qxrdfilesaver.h"
17 #include "qxrdgeneratetestimage.h"
18 #include "qxrdapplication.h"
19 #include "qxrdexperiment.h"
20 
21 #include <QTime>
22 #include <QPainter>
23 #include <qmath.h>
24 #include <QDir>
25 
30  QxrdFileSaverWPtr filesaver) :
31 
32  QcepObject("processor", NULL),
33 // m_OutputDirectory(saver, this,"outputDirectory", ""),
34  m_FileName(QcepSettingsSaverPtr(), this, "fileName","", "Current File Name"),
35  m_DataPath(saver, this,"dataPath", "", "Data Path"),
36  m_DarkImagePath(saver, this, "darkImagePath", "", "Dark Images Path"),
37  m_BadPixelsPath(saver, this, "badPixelsPath", "", "Bad Pixels Path"),
38  m_GainMapPath(saver, this, "gainMapPath", "", "Gain Map Path"),
39  m_MaskPath(saver, this, "maskPath", "", "Mask Path"),
40  m_ScriptPath(saver, this, "scriptPath", "", "Script Path"),
41  m_PerformDarkSubtraction(saver, this, "performDarkSubtraction", true, "Perform Dark Subtraction?"),
42  m_SaveRawImages(saver, this, "saveRawImages", true, "Save Raw Images?"),
43  m_SaveDarkImages(saver, this, "saveDarkImages", true, "Save Dark Images?"),
44  m_PerformBadPixels(saver, this, "performBadPixels", true, "Perform Bad Pixel Correction?"),
45  m_PerformGainCorrection(saver, this, "performGainCorrection", true, "Perform Gain Correction?"),
46  m_SaveSubtracted(saver, this, "saveSubtracted", true, "Save Dark Subtracted Data?"),
47  m_SaveAsText(saver, this, "saveAsText", false, "Save as Text Files (warning - Large and Slow!)"),
48  m_SaveAsTextSeparator(saver, this, "saveAsTextSeparator", " ", "Separator for Images Saved as Text"),
49  m_SaveAsTextPerLine(saver, this,"saveAsTextPerLine",16, "Pixels per line in Images Saved as Text"),
50  m_SaveOverflowFiles(saver, this,"saveOverflowFiles",0, "Save Overflow Pixel Files?"),
51  m_PerformIntegration(saver, this, "performIntegration", true, "Perform Circular Integration?"),
52  m_DisplayIntegratedData(saver, this, "displayIntegratedData", true, "Display Integrated Data?"),
53  m_SaveIntegratedData(saver, this, "saveIntegratedData", true, "Save Integrated Data?"),
54  m_SaveIntegratedPath(saver, this, "saveIntegratedPath", "", "Integrated Data Path"),
55  m_SaveDarkInSubdirectory(saver, this,"saveDarkInSubdirectory",0, "Save Dark In Subdirectory?"),
56  m_SaveDarkSubdirectory(saver, this,"saveDarkSubdirectory","", "Dark Subdirectory"),
57  m_SaveRawInSubdirectory(saver, this,"saveRawInSubdirectory",0, "Save Raw in Subdirectory?"),
58  m_SaveRawSubdirectory(saver, this,"saveRawSubdirectory","", "Raw Subdirectory"),
59  m_SaveSubtractedInSubdirectory(saver, this,"saveSubtractedInSubdirectory",0, "Save Subtracted in Subdirectory?"),
60  m_SaveSubtractedSubdirectory(saver, this,"saveSubtractedSubdirectory","", "Subtracted Subdirectory"),
61  m_SaveIntegratedInSeparateFiles(saver, this,"saveIntegratedInSeparateFiles",0, "Save Integrated in Separate Files?"),
62  m_SaveIntegratedInSubdirectory(saver, this,"saveIntegratedInSubdirectory",0, "Save Integrated in Subdirectory?"),
63  m_SaveIntegratedSubdirectory(saver, this,"saveIntegratedSubdirectory","", "Integrated Subdirectory"),
64  m_AccumulateIntegrated2D(saver, this, "accumulateIntegrated2D", 0, "Accumulate integrated data in 2-d dataset"),
65  m_AccumulateIntegratedName(saver, this, "accumulateIntegratedName", "/accumulated/2d-data", "Dataset to accumulate to"),
66  m_AccumulateIntegratedDirectory(saver, this, "accumulateIntegratedDirectory", "", "Accumulator save directory"),
67  m_AccumulateIntegratedFileName(saver, this, "accumulateIntegratedFileName", "", "Accumulator save file"),
68  m_AccumulateIntegratedFormat(saver, this, "accumulateIntegratedFormat", "", "Accumulator save format"),
69  m_PerformDarkSubtractionTime(saver, this, "performDarkSubtractionTime", 0.01, "Avg Time to Perform Dark Subtraction (in sec)"),
70  m_PerformBadPixelsTime(saver, this, "performBadPixelsTime", 0.01, "Avg Time to Perform Bad Pixel Correction (in sec)"),
71  m_PerformGainCorrectionTime(saver, this, "performGainCorrectionTime", 0.01, "Avg Time to Perform Gain Correction (in sec)"),
72  m_SaveSubtractedTime(saver, this, "saveSubtractedTime", 0.1, "Avg Time to Save Subtracted Data (in sec)"),
73  m_SaveAsTextTime(saver, this, "saveAsTextTime", 0.1, "Avg Time to Save Images as Text (in sec)"),
74  m_PerformIntegrationTime(saver, this, "performIntegrationTime", 0.05, "Avg Time to Perform Integration (in sec/core)"),
75  m_DisplayIntegratedDataTime(saver, this, "displayIntegratedDataTime", 0.2, "Avg Time to Display Integrated Data (in sec)"),
76  m_SaveIntegratedDataTime(saver, this, "saveIntegratedDataTime", 0.01, "Avg Time to Save Integrated Data (in sec)"),
77  m_EstimatedProcessingTime(saver, this, "estimatedProcessingTime", 0.1, "Overall Estimated Processing Time (in sec/image)"),
78  m_AveragingRatio(saver, this, "averagingRatio", 0.1, "Averaging Ratio for Estimated Timing"),
79  m_MaskMinimumValue(saver, this, "maskMinimumValue", 0, "Mask Minimum Value"),
80  m_MaskMaximumValue(saver, this, "maskMaximumValue", 20000, "Mask Maximum Value"),
81  m_MaskCircleRadius(saver, this, "maskCircleRadius", 10, "Mask Circle Radius"),
82  m_MaskSetPixels(saver, this, "maskSetPixels", true, "Mask Set Pixels"),
83 // m_CompressImages(saver, this, "compressImages", false, "Compress Images"),
84  m_Average(QcepSettingsSaverPtr(), this,"average",0.0, "Average Value of Acquired Image (per exposure)"),
85  m_AverageDark(QcepSettingsSaverPtr(), this,"averageDark",0.0, "Average Value of Dark Image"),
86  m_AverageRaw(QcepSettingsSaverPtr(), this,"averageRaw",0.0, "Average Value of Raw Image"),
87  m_CorrectionQueueLength(QcepSettingsSaverPtr(), this, "correctionQueueLength", 0, "Image correction backlog"),
88  m_IntegrationQueueLength(QcepSettingsSaverPtr(), this, "integrationQueueLength", 0, "Image integration backlog"),
89  m_SaverQueueLength(QcepSettingsSaverPtr(), this, "saverQueueLength", 0, "Data saving backlog"),
90  m_ZingerAlgorithm(saver, this, "zingerAlgorithm", 0, "Zinger Detection Algorithm"),
91  m_ZingerMask(saver, this, "zingerMask", 0, "Zinger Mask Source"),
92  m_ZingerDestination(saver, this, "zingerDestination", -1, "Zinger Destination"),
93  m_ZingerSize1(saver, this, "zingerSize1", 1, "Inner Zinger Search Box Size"),
94  m_ZingerSize2(saver, this, "zingerSize2", 5, "Outer Zinger Search Box Size"),
95  m_ZingerThreshold(saver, this, "zingerThreshold", 2.5, "Zinger Detection Threshold"),
96  m_Mutex(QMutex::Recursive),
97  m_Experiment(doc),
98  m_Saver(saver),
99  m_Window(),
100  m_FileSaver(filesaver),
101  m_Acquisition(acq),
102  m_AcquiredInt16Images("acquiredInt16Images"),
103  m_AcquiredInt32Images("acquiredInt32Images"),
104  m_Data(QcepAllocator::newDoubleImage(QcepAllocator::WaitTillAvailable, 2048, 2048, this)),
105  m_DarkFrame(NULL),
106  m_BadPixels(NULL),
107  m_GainMap(NULL),
108  // m_Mask(allocator -> newMask()),
109  m_AcquiredCount(0),
110  m_CenterFinder(NULL),
111  m_Integrator(NULL),
112  m_PolarTransform(NULL),
113  m_PolarNormalization(NULL),
114  m_GenerateTestImage(NULL)
115 {
116 // m_SaverQueueLength.setDebug(1);
117 // m_IntegrationQueueLength.setDebug(1);
118 // m_CorrectionQueueLength.setDebug(1);
119 
121  printf("QxrdDataProcessorBase::QxrdDataProcessorBase(%p)\n", this);
122  }
123 
124  if (qcepDebug(DEBUG_APP)) {
125  printMessage("QxrdDataProcessorBase::QxrdDataProcessorBase");
126  }
127 
132 
133 // m_Integrator->initialize(m_Integrator);
134 
136 
138 
139 }
140 
142 {
143 #ifndef QT_NO_DEBUG
144  printf("Deleting processor\n");
145 #endif
146 
148  printf("QxrdDataProcessorBase::~QxrdDataProcessorBase(%p)\n", this);
149  }
150 }
151 
153 {
154  thread()->exit();
155 }
156 
158 {
159  m_Acquisition = acq;
160 
162  connect(prop_PerformDarkSubtraction(), &QcepBoolProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
164  connect(prop_PerformGainCorrection(), &QcepBoolProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
168  connect(prop_DisplayIntegratedData(), &QcepBoolProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
170  connect(prop_PerformDarkSubtractionTime(), &QcepDoubleProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
171  connect(prop_PerformBadPixelsTime(), &QcepDoubleProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
172  connect(prop_PerformGainCorrectionTime(), &QcepDoubleProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
175  connect(prop_PerformIntegrationTime(), &QcepDoubleProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
176  connect(prop_DisplayIntegratedDataTime(), &QcepDoubleProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
177  connect(prop_SaveIntegratedDataTime(), &QcepDoubleProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
178 
180 
181  if (acqp) {
182  connect(acqp -> prop_SummedExposures(), &QcepIntProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
183  connect(acqp -> prop_Raw16SaveTime(), &QcepDoubleProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
184  connect(acqp -> prop_Raw32SaveTime(), &QcepDoubleProperty::valueChanged, this, &QxrdDataProcessorBase::updateEstimatedProcessingTime);
185  }
186 }
187 
189 {
190  m_Window = win;
192  newMask();
193 }
194 
195 //QcepSettingsSaver *QxrdDataProcessorBase::saver()
196 //{
197 // return m_Saver;
198 //}
199 
200 void QxrdDataProcessorBase::writeSettings(QSettings *settings, QString section)
201 {
202  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
203 
204  QcepObject::writeSettings(settings, section);
205 
206  m_CenterFinder -> writeSettings(settings, section+"/centerfinder");
207  m_Integrator -> writeSettings(settings, section+"/integrator");
208  m_PolarTransform -> writeSettings(settings, section+"/polarTransform");
209  m_PolarNormalization -> writeSettings(settings, section+"/polarNormalization");
210  m_DistortionCorrection -> writeSettings(settings, section+"/distortion");
211 }
212 
213 void QxrdDataProcessorBase::readSettings(QSettings *settings, QString section)
214 {
215  QcepMutexLocker lock(__FILE__, __LINE__, &m_Mutex);
216 
217  QcepObject::readSettings(settings, section);
218 
219  m_CenterFinder -> readSettings(settings, section+"/centerfinder");
220  m_Integrator -> readSettings(settings, section+"/integrator");
221  m_PolarTransform -> readSettings(settings, section+"/polarTransform");
222  m_PolarNormalization -> readSettings(settings, section+"/polarNormalization");
223  m_DistortionCorrection -> readSettings(settings, section+"/distortion");
224 }
225 
226 void QxrdDataProcessorBase::printMessage(QString msg, QDateTime ts) const
227 {
229 
230  if (exp) {
231  exp->printMessage(msg, ts);
232  }
233 }
234 
235 void QxrdDataProcessorBase::criticalMessage(QString msg, QDateTime ts) const
236 {
238 
239  if (exp) {
240  exp->criticalMessage(msg, ts);
241  }
242 }
243 
244 void QxrdDataProcessorBase::statusMessage(QString msg, QDateTime ts) const
245 {
247 
248  if (exp) {
249  exp->statusMessage(msg, ts);
250  }
251 }
252 
253 QString QxrdDataProcessorBase::existingOutputDirectory(QString dir, QString subdir) const
254 {
255  return QDir(dir).filePath(subdir);
256 }
257 
259 {
260  return QDir(experimentDirectory()).filePath(name);
261 }
262 
264 {
266 
267  if (exp) {
268  return exp->get_ExperimentDirectory();
269  } else {
270  return QString();
271  }
272 }
273 
275 {
276  return QDir(dataDirectory()).filePath(name);
277 }
278 
280 {
282 
283  if (exp) {
284  return QDir(exp->get_ExperimentDirectory()).filePath(exp->get_DataDirectory());
285  } else {
286  return QString();
287  }
288 }
289 
291 {
292  return QDir(darkOutputDirectory()).filePath(name);
293 }
294 
296 {
297  if (get_SaveDarkInSubdirectory()) {
298  return existingOutputDirectory(dataDirectory(), get_SaveDarkSubdirectory());
299  } else {
300  return dataDirectory();
301  }
302 }
303 
305 {
306  return QDir(rawOutputDirectory()).filePath(name);
307 }
308 
310 {
311  if (get_SaveRawInSubdirectory()) {
312  return existingOutputDirectory(dataDirectory(), get_SaveRawSubdirectory());
313  } else {
314  return dataDirectory();
315  }
316 }
317 
319 {
320  return QDir(subtractedOutputDirectory()).filePath(name);
321 }
322 
324 {
325  if (get_SaveSubtractedInSubdirectory()) {
326  return existingOutputDirectory(dataDirectory(), get_SaveSubtractedSubdirectory());
327  } else {
328  return dataDirectory();
329  }
330 }
331 
333 {
334  return QDir(integratedOutputDirectory()).filePath(name);
335 }
336 
338 {
339  if (get_SaveIntegratedInSubdirectory()) {
340  return existingOutputDirectory(dataDirectory(), get_SaveIntegratedSubdirectory());
341  } else {
342  return dataDirectory();
343  }
344 }
345 
347 {
349  width, height, this);
350 
351  return res;
352 }
353 
355 {
356  m_Data = image;
358 
360 
361  if (w) {
362  w -> newDataAvailable(m_Data, overflow);
363  }
364 
365  if (m_CenterFinder) {
366  m_CenterFinder->setData(m_Data);
367  }
368 }
369 
371 {
372  m_DarkFrame = image;
373 
374  if (image) {
375  set_DarkImagePath(image->get_FileName());
376 
377  int height = image->get_Height();
378  int width = image->get_Width();
379  int ndrk = image -> get_SummedExposures();
380  int npixels = width*height;
381  if (ndrk <= 0) ndrk = 1;
382 
383  double *dk = image->data();
384  double avgdark = 0;
385 
386  for (int i=0; i<npixels; i++) {
387  avgdark += dk[i];
388  }
389  set_AverageDark(avgdark/npixels/ndrk);
390  } else {
391  set_DarkImagePath("");
392  set_AverageDark(0);
393  }
394 }
395 
397 {
398  if (image) {
399  if (m_DarkFrame == NULL) {
400  m_DarkFrame = takeNextFreeImage(image->get_Width(), image->get_Height());
401  }
402 
403  m_DarkFrame -> copyFrom(image);
405 
406  // set_DarkImagePath(m_DarkFrame -> get_FileName());
407  } else {
409  }
410 }
411 
413 {
414  if (image) {
415  if (m_DarkFrame == NULL) {
416  m_DarkFrame = takeNextFreeImage(image->get_Width(), image->get_Height());
417  }
418 
419  m_DarkFrame -> copyFrom(image);
421 
422  // set_DarkImagePath(m_DarkFrame -> get_FileName());
423  } else {
425  }
426 }
427 
429 {
430  m_BadPixels = image;
431 
432  if (image) {
433  set_BadPixelsPath(image->get_FileName());
434  } else {
435  set_BadPixelsPath("");
436  }
437 }
438 
440 {
441  m_GainMap = image;
442 
443  if (image) {
444  set_GainMapPath(image->get_FileName());
445  } else {
446  set_GainMapPath("");
447  }
448 }
449 
451 {
453 
454  if (w) {
455  w -> newMaskAvailable(mask());
456  }
457 }
458 
460 {
461  QString fileName = get_MaskPath();
462  QFileInfo fileInfo(fileName);
463 
464  if (fileInfo.exists() && fileInfo.isFile()) {
465  loadMask(fileName);
466  }
467 
468  fileName = get_DarkImagePath();
469  fileInfo.setFile(fileName);
470 
471  if (fileInfo.exists() && fileInfo.isFile()) {
472  loadDark(fileName);
473  }
474 
475  fileName = get_BadPixelsPath();
476  fileInfo.setFile(fileName);
477 
478  if (fileInfo.exists() && fileInfo.isFile()) {
479  loadBadPixels(fileName);
480  }
481 
482  fileName = get_GainMapPath();
483  fileInfo.setFile(fileName);
484 
485  if (fileInfo.exists() && fileInfo.isFile()) {
486  loadGainMap(fileName);
487  }
488 }
489 
491 {
492  return dataDirectory();
493 }
494 
495 //void QxrdDataProcessorBase::cd(QString path)
496 //{
497 // QDir dir(currentDirectory());
498 
499 // if (dir.cd(path)) {
500 // set_OutputDirectory(dir.path());
501 // }
502 //}
503 
504 QStringList QxrdDataProcessorBase::ls() const
505 {
506  QStringList res;
507  QDir dir(dataDirectory());
508 
509  res = dir.entryList(QStringList());
510 
511  return res;
512 }
513 
514 QStringList QxrdDataProcessorBase::ls(QString pattern) const
515 {
516  QStringList res;
517  QDir dir(dataDirectory());
518 
519  res = dir.entryList(QStringList(pattern));
520 
521  return res;
522 }
523 
525 {
526  if (QThread::currentThread() != thread()) {
527  INVOKE_CHECK(QMetaObject::invokeMethod(this, "loadData", Qt::BlockingQueuedConnection, Q_ARG(QString, name)))
528  } else {
529  if (qcepDebug(DEBUG_FILES)) {
530  printMessage(
531  tr("QxrdDataProcessorBase::loadData(%1)").arg(name));
532  }
533 
535 
536  QString path = filePathInDataDirectory(name);
537 
538  if (res && res -> readImage(path)) {
539 
540  // printf("Read %d x %d image\n", res->get_Width(), res->get_Height());
541 
542  res -> loadMetaData();
543 
544  int typ = res->get_DataType();
545 
546  if ((typ == QcepDoubleImageData::Raw16Data) ||
548  {
550  }
551 
552  newData(res, QcepMaskDataPtr());
553 
554  set_DataPath(res -> get_FileName());
555 
556  printMessage(tr("Loaded data from %1").arg(path));
557  }
558  }
559 }
560 
561 void QxrdDataProcessorBase::saveData(QString name, int canOverwrite)
562 {
563  if (QThread::currentThread() != thread()) {
564  INVOKE_CHECK(QMetaObject::invokeMethod(this, "saveData", Qt::BlockingQueuedConnection, Q_ARG(QString, name), Q_ARG(int, canOverwrite)))
565  } else {
566  QString path = filePathInDataDirectory(name);
567 
568  saveNamedImageData(path, m_Data, QcepMaskDataPtr(), canOverwrite);
569 
570  set_DataPath(m_Data -> get_FileName());
571  }
572 }
573 
574 void QxrdDataProcessorBase::saveData(QcepDataObjectPtr object, QString name, int canOverwrite)
575 {
576  if (QThread::currentThread() != thread()) {
577  INVOKE_CHECK(QMetaObject::invokeMethod(this, "saveData",
578  Qt::BlockingQueuedConnection,
579  Q_ARG(QcepDataObjectPtr, object),
580  Q_ARG(QString, name), Q_ARG(int, canOverwrite)))
581  } else {
582  QString path = filePathInDataDirectory(name);
583 
584  QcepDoubleImageDataPtr image = qSharedPointerDynamicCast<QcepDoubleImageData>(object);
585 
586  if (image) {
587  saveNamedImageData(path, image, QcepMaskDataPtr(), canOverwrite);
588  } else {
589  printMessage(tr("Don't know how to save %1").arg(object->pathName()));
590  }
591  }
592 }
593 
594 //void QxrdDataProcessorBase::saveData(QcepDoubleImageDataPtr data, QString name, int canOverwrite)
595 //{
596 // if (QThread::currentThread() != thread()) {
597 // INVOKE_CHECK(QMetaObject::invokeMethod(this, "saveData",
598 // Qt::BlockingQueuedConnection,
599 // Q_ARG(QcepDoubleImageDataPtr, data),
600 // Q_ARG(QString, name), Q_ARG(int, canOverwrite)))
601 // } else {
602 // QString path = filePathInDataDirectory(name);
603 
604 // saveNamedImageData(path, data, QcepMaskDataPtr(), canOverwrite);
605 // }
606 //}
607 
609 {
610  if (QThread::currentThread() != thread()) {
611  INVOKE_CHECK(QMetaObject::invokeMethod(this, "loadDark", Qt::BlockingQueuedConnection, Q_ARG(QString, name)))
612  } else {
613  if (qcepDebug(DEBUG_FILES)) {
614  printMessage(
615  tr("QxrdDataProcessorBase::loadDark(%1)").arg(name));
616  }
617 
619 
620  QString path = filePathInDataDirectory(name);
621 
622  if (res && res -> readImage(path)) {
623 
624  // printf("Read %d x %d image\n", res->get_Width(), res->get_Height());
625 
626  res -> loadMetaData();
627  res -> set_DataType(QcepDoubleImageData::DarkData);
628 
629  newDarkImage(res);
630 
631  set_DarkImagePath(res -> get_FileName());
632 
633  printMessage(tr("Loaded Dark Image from %1").arg(path));
634  } else {
635  printMessage(tr("loadDark(%1) failed").arg(name));
636  }
637  }
638 }
639 
640 void QxrdDataProcessorBase::saveDark(QString name, int canOverwrite)
641 {
642  if (QThread::currentThread() != thread()) {
643  INVOKE_CHECK(QMetaObject::invokeMethod(this, "saveDark", Qt::BlockingQueuedConnection, Q_ARG(QString, name), Q_ARG(int, canOverwrite)))
644  } else {
645  QString path = filePathInDataDirectory(name);
646 
647  if (m_DarkFrame) {
648  saveNamedImageData(path, m_DarkFrame, QcepMaskDataPtr(), canOverwrite);
649 
650  set_DarkImagePath(m_DarkFrame -> get_FileName());
651  }
652  }
653 }
654 
656 {
657  if (qcepDebug(DEBUG_FILES)) {
658  printMessage(tr("QxrdDataProcessorBase::loadBadPixels(%1)").arg(name));
659  }
660 
662 
663  QString path = filePathInDataDirectory(name);
664 
665  if (res && res -> readImage(path)) {
666 
667  // printf("Read %d x %d image\n", res->get_Width(), res->get_Height());
668 
669  res -> loadMetaData();
670  res -> set_DataType(QcepDoubleImageData::BadPixelsData);
671 
672  newBadPixelsImage(res);
673 
674  set_BadPixelsPath(res -> get_FileName());
675  }
676 }
677 
678 void QxrdDataProcessorBase::saveBadPixels(QString name, int canOverwrite)
679 {
680  QString path = filePathInDataDirectory(name);
681 
682  if (m_BadPixels) {
683  saveNamedImageData(path, m_BadPixels, QcepMaskDataPtr(), canOverwrite);
684 
685  set_BadPixelsPath(m_BadPixels -> get_FileName());
686  }
687 }
688 
690 {
691  if (qcepDebug(DEBUG_FILES)) {
692  printMessage(tr("QxrdDataProcessorBase::loadGainMap(%1)").arg(name));
693  }
694 
696 
697  QString path = filePathInDataDirectory(name);
698 
699  if (res -> readImage(path)) {
700 
701  // printf("Read %d x %d image\n", res->get_Width(), res->get_Height());
702 
703  res -> loadMetaData();
704  res -> set_DataType(QcepDoubleImageData::GainData);
705  res -> setDefaultValue(1.0);
706 
707  newGainMapImage(res);
708 
709  set_GainMapPath(res -> get_FileName());
710  }
711 }
712 
713 void QxrdDataProcessorBase::saveGainMap(QString name, int canOverwrite)
714 {
715  QString path = filePathInDataDirectory(name);
716 
717  if (m_GainMap) {
718  saveNamedImageData(path, m_GainMap, QcepMaskDataPtr(), canOverwrite);
719 
720  set_GainMapPath(m_GainMap -> get_FileName());
721  }
722 }
723 
725 {
726  QString path = filePathInDataDirectory(name);
727 
728  QcepInt32ImageDataPtr data = m_Integrator->cachedGeometry();
729 
730  if (data) {
731  saveNamedImageData(path, data, QcepMaskDataPtr(), true);
732  }
733 }
734 
736 {
737  QString path = filePathInDataDirectory(name);
738 
739  QcepDoubleImageDataPtr data = m_Integrator->cachedIntensity();
740 
741  if (data) {
742  saveNamedImageData(path, data, QcepMaskDataPtr(), true);
743  }
744 }
745 
747 {
748  return &m_Masks;
749 }
750 
752 {
753  return m_Masks.count();
754 }
755 
757 {
758  int len = m_Masks.count();
759 
760  if (pos >= 0 && pos < len) {
761  return pos;
762  } else if (pos < 0 && pos >= -len) {
763  return len-pos;
764  } else {
765  return -1;
766  }
767 }
768 
770 {
772 
773  int w=0;
774 
775  if (d) {
776  w = d->get_Width();
777  } else if (mask()) {
778  w = mask()->get_Width();
779  }
780 
781  return w;
782 }
783 
785 {
787 
788  int h=0;
789 
790  if (d) {
791  h = d->get_Height();
792  } else if (mask()) {
793  h = mask()->get_Height();
794  }
795 
796  return h;
797 }
798 
800 {
801 
803  newMaskWidth(), newMaskHeight(), 0, this);
804 
805  m_Masks.push_front(m);
806 
807  printMessage(tr("new mask, %1 on stack").arg(m_Masks.count()));
808 
809  m_Masks.changed();
810 
811  newMask();
812 }
813 
815 {
816  if (m == NULL) {
818  newMaskWidth(), newMaskHeight(), 0, this);
819 
820  if (mask()) {
821  mask()->copyMaskTo(m);
822  }
823  }
824 
825  m_Masks.push_front(m);
826 
827 // m_Mask = mask;
828 
829  printMessage(tr("dup mask, %1 on stack").arg(m_Masks.count()));
830 
831  m_Masks.changed();
832 
833  newMask();
834 }
835 
837 {
838  if (amount == 0) {
839  return;
840  } else if (amount > 1) {
841  for (int i=0; i<amount; i++) {
842  popMaskStack(1);
843  }
844  } else if (amount < -1) {
845  for (int i=0; i<(-amount); i++) {
846  popMaskStack(-1);
847  }
848  } else if (amount == 1) {
849  if (m_Masks.count() >= 1) {
850 // m_Mask = m_Masks.first();
851  m_Masks.pop_front();
852  }
853  } else if (amount == -1) {
854  if (m_Masks.count() >= 1) {
855 // m_Mask = m_Masks.last();
856  m_Masks.pop_back();
857  }
858  }
859 
860  m_Masks.changed();
861 
862  newMask();
863 }
864 
866 {
867  m_Masks.clear();
868 
869  m_Masks.changed();
870 
871  newMask();
872 }
873 
875 {
876  popMaskStack();
877 }
878 
880 {
881  if (amount == 0) {
882  return;
883  } else if (amount > 1) {
884  for (int i=0; i<amount; i++) {
885  rollMaskStack(1);
886  }
887  } else if (amount < -1) {
888  for (int i=0; i<(-amount); i++) {
889  rollMaskStack(-1);
890  }
891  } else if (amount == 1) {
892  QcepMaskDataPtr m = m_Masks.first();
893  m_Masks.push_back(m);
894  m_Masks.pop_front();
895  } else if (amount == -1) {
896  QcepMaskDataPtr m = m_Masks.last();
897  m_Masks.push_front(m);
898  m_Masks.pop_back();
899  }
900 
901  m_Masks.changed();
902 
903  newMask();
904 }
905 
907 {
908  int p0 = maskStackPosition(0);
909  int p1 = maskStackPosition(pos);
910 
911  if ((p0 >= 0) && (p1 >= 0) && (p0 != p1)) {
912  QcepMaskDataPtr pm=m_Masks[p0];
913  m_Masks[p0] = m_Masks[p1];
914  m_Masks[p1] = pm;
915 
916  m_Masks.changed();
917 
918  newMask();
919  }
920 }
921 
923 {
924  int p0 = maskStackPosition(0);
925  int p1 = maskStackPosition(pos);
926 
927  if ((p0 >= 0) && (p1 >= 0)) {
928  QcepMaskDataPtr pm = m_Masks[p1];
929 
930  m_Masks[p0] -> andMask(pm);
931 
932  m_Masks.changed();
933 
934  newMask();
935  }
936 }
937 
939 {
940  int p0 = maskStackPosition(0);
941  int p1 = maskStackPosition(pos);
942 
943  if ((p0 >= 0) && (p1 >= 0)) {
944  QcepMaskDataPtr pm = m_Masks[p1];
945 
946  m_Masks[p0] -> orMask(pm);
947 
948  m_Masks.changed();
949 
950  newMask();
951  }
952 }
953 
955 {
956  int p0 = maskStackPosition(0);
957  int p1 = maskStackPosition(pos);
958 
959  if ((p0 >= 0) && (p1 >= 0)) {
960  QcepMaskDataPtr pm = m_Masks[p1];
961 
962  m_Masks[p0] -> xorMask(pm);
963 
964  m_Masks.changed();
965 
966  newMask();
967  }
968 }
969 
971 {
972  int p0 = maskStackPosition(0);
973  int p1 = maskStackPosition(pos);
974 
975  if ((p0 >= 0) && (p1 >= 0)) {
976  QcepMaskDataPtr pm = m_Masks[p1];
977 
978  m_Masks[p0] -> andNotMask(pm);
979 
980  m_Masks.changed();
981 
982  newMask();
983  }
984 }
985 
987 {
988  int p0 = maskStackPosition(0);
989  int p1 = maskStackPosition(pos);
990 
991  if ((p0 >= 0) && (p1 >= 0)) {
992  QcepMaskDataPtr pm = m_Masks[p1];
993 
994  m_Masks[p0] -> orNotMask(pm);
995 
996  m_Masks.changed();
997 
998  newMask();
999  }
1000 }
1001 
1003 {
1004  int p0 = maskStackPosition(0);
1005  int p1 = maskStackPosition(pos);
1006 
1007  if ((p0 >= 0) && (p1 >= 0)) {
1008  QcepMaskDataPtr pm = m_Masks[p1];
1009 
1010  m_Masks[p0] -> xorNotMask(pm);
1011 
1012  m_Masks.changed();
1013 
1014  newMask();
1015  }
1016 }
1017 
1019 {
1020  int p = maskStackPosition(pos);
1021 
1022  if (p >= 0) {
1023  m_Masks[p] -> invertMask();
1024 
1025  m_Masks.changed();
1026 
1027  newMask();
1028  }
1029 }
1030 
1032 {
1033  int p = maskStackPosition(pos);
1034 
1035  if (p >= 0) {
1036  m_Masks[p] -> growMask();
1037 
1038  m_Masks.changed();
1039 
1040  newMask();
1041  }
1042 }
1043 
1045 {
1046  int p = maskStackPosition(pos);
1047 
1048  if (p >= 0) {
1049  m_Masks[p] -> shrinkMask();
1050 
1051  m_Masks.changed();
1052 
1053  newMask();
1054  }
1055 }
1056 
1058 {
1059  int p = maskStackPosition(pos);
1060 
1061  if (p >= 0) {
1062  m_Masks[p] -> hideMaskAll();
1063 
1064  m_Masks.changed();
1065 
1066  newMask();
1067  }
1068 }
1069 
1071 {
1072  int p = maskStackPosition(pos);
1073 
1074  if (p >= 0) {
1075  m_Masks[p] -> showMaskAll();
1076 
1077  m_Masks.changed();
1078 
1079  newMask();
1080  }
1081 }
1082 
1084 {
1085  int p = maskStackPosition(pos);
1086 
1087  double min = get_MaskMinimumValue();
1088  double max = get_MaskMaximumValue();
1089 
1090  if (m_Data && p >= 0) {
1091  m_Masks[p] -> hideMaskRange(QSharedPointer< QcepImageData<double> >(m_Data), min, max);
1092 
1093  m_Masks.changed();
1094 
1095  newMask();
1096  }
1097 }
1098 
1100 {
1101  int p = maskStackPosition(pos);
1102 
1103  double min = get_MaskMinimumValue();
1104  double max = get_MaskMaximumValue();
1105 
1106  if (m_Data && p >= 0) {
1107  m_Masks[p] -> showMaskRange(QSharedPointer< QcepImageData<double> >(m_Data), min, max);
1108 
1109  m_Masks.changed();
1110 
1111  newMask();
1112  }
1113 }
1114 
1116 {
1117  if (qcepDebug(DEBUG_FILES)) {
1118  printMessage(tr("QxrdDataProcessorBase::loadMask(%1)").arg(name));
1119  }
1120 
1122 
1123  QString path = filePathInDataDirectory(name);
1124 
1125  if (res -> readImage(path)) {
1126 
1127  // printf("Read %d x %d image\n", res->get_Width(), res->get_Height());
1128 
1129  res -> loadMetaData();
1130  res -> set_DataType(QcepMaskData::MaskData);
1131 
1132  // res -> copyMaskTo(m_Mask);
1133 
1134  pushMaskStack(res);
1135 
1136  m_Masks.changed();
1137 
1138  newMask();
1139 
1140  set_MaskPath(mask() -> get_FileName());
1141 
1142  printMessage(tr("Loaded Mask from %1").arg(path));
1143  }
1144 }
1145 
1146 void QxrdDataProcessorBase::saveMask(QString name, int canOverwrite)
1147 {
1148  QString path = filePathInDataDirectory(name);
1149 
1150  if (mask()) {
1151  saveNamedMaskData(path, mask(), canOverwrite);
1152 
1153  set_MaskPath(mask() -> get_FileName());
1154  }
1155 }
1156 
1158 {
1159  clearMaskStack();
1160 
1161  set_MaskPath("");
1162 }
1163 
1164 void QxrdDataProcessorBase::saveNamedImageData(QString name, QcepDoubleImageDataPtr image, QcepMaskDataPtr overflow, int canOverwrite)
1165 {
1167 
1168  if (f) {
1169  f -> saveDoubleData(name, image, overflow, canOverwrite);
1170  }
1171 }
1172 
1173 void QxrdDataProcessorBase::saveNamedImageData(QString name, QcepInt16ImageDataPtr image, QcepMaskDataPtr overflow, int canOverwrite)
1174 {
1176 
1177  if (f) {
1178  f -> saveInt16Data(name, image, overflow, canOverwrite);
1179  }
1180 }
1181 
1182 void QxrdDataProcessorBase::saveNamedRawImageData(QString name, QcepInt16ImageDataPtr image, QcepMaskDataPtr overflow, int canOverwrite)
1183 {
1185 
1186  if (f) {
1187  f -> saveRaw16Data(name, image, overflow, canOverwrite);
1188  }
1189 }
1190 
1191 void QxrdDataProcessorBase::saveNamedImageData(QString name, QcepInt32ImageDataPtr image, QcepMaskDataPtr overflow, int canOverwrite)
1192 {
1194 
1195  if (f) {
1196  f -> saveInt32Data(name, image, overflow, canOverwrite);
1197  }
1198 }
1199 
1200 void QxrdDataProcessorBase::saveNamedRawImageData(QString name, QcepInt32ImageDataPtr image, QcepMaskDataPtr overflow, int canOverwrite)
1201 {
1203 
1204  if (f) {
1205  f -> saveRaw32Data(name, image, overflow, canOverwrite);
1206  }
1207 }
1208 
1209 void QxrdDataProcessorBase::saveNamedMaskData(QString name, QcepMaskDataPtr image, int canOverwrite)
1210 {
1212 
1213  if (f) {
1214  f -> saveMaskData(name, image, canOverwrite);
1215  }
1216 }
1217 
1219 {
1221 
1222  if (f) {
1223  f -> saveTextData(name, image, overflow, canOverwrite);
1224  }
1225 }
1226 
1228 {
1230 
1231  set_DarkImagePath("");
1232 }
1233 
1235 {
1237 
1238  set_BadPixelsPath("");
1239 }
1240 
1242 {
1244 
1245  set_GainMapPath("");
1246 }
1247 
1249  QcepDoubleImageDataPtr corrected,
1252  QcepMaskDataPtr mask,
1253  QcepMaskDataPtr overflow)
1254 {
1255  if (qcepDebug(DEBUG_PROCESS)) {
1256  printMessage(tr("processing acquired 16 bit image, %1 remaining")
1257  .arg(getAcquiredCount()));
1258  }
1259 
1260  if (img) {
1261  if (get_SaveRawImages()) {
1262  if (img->get_ObjectSaved()) {
1263  printMessage(tr("Image \"%1\" is already saved").arg(img->rawFileName()));
1264  } else {
1266  }
1267  }
1268 
1269  corrected -> copyFrom(img);
1270  corrected -> set_DateTime(QDateTime::currentDateTime());
1271 
1272  processAcquiredImage(corrected, corrected, dark, mask, overflow);
1273 
1274  return corrected;
1275  } else {
1276  return QcepDoubleImageDataPtr();
1277  }
1278 }
1279 
1281  QcepDoubleImageDataPtr corrected,
1284  QcepMaskDataPtr mask,
1285  QcepMaskDataPtr overflow)
1286 {
1287  if (qcepDebug(DEBUG_PROCESS)) {
1288  printMessage(tr("processing acquired 32 bit image, %1 remaining")
1289  .arg(getAcquiredCount()));
1290  }
1291 
1292  if (img) {
1293  if (get_SaveRawImages()) {
1294  if (img->get_ObjectSaved()) {
1295  printMessage(tr("Image \"%1\" is already saved").arg(img->rawFileName()));
1296  } else {
1298  }
1299  }
1300 
1301  corrected -> copyFrom(img);
1302  corrected -> set_DateTime(QDateTime::currentDateTime());
1303 
1304  processAcquiredImage(corrected, corrected, dark, mask, overflow);
1305 
1306  return corrected;
1307  } else {
1308  return QcepDoubleImageDataPtr();
1309  }
1310 }
1311 
1313  QcepDoubleImageDataPtr processed,
1316  QcepMaskDataPtr mask,
1317  QcepMaskDataPtr overflow)
1318 {
1319  return processAcquiredImage(processed, dimg, dark, mask, overflow);
1320 }
1321 
1323  QcepDoubleImageDataPtr processed,
1326  QcepMaskDataPtr mask,
1327  QcepMaskDataPtr overflow,
1328  QcepDoubleList v)
1329 {
1330  return processAcquiredImage(processed, dimg, dark, mask, overflow, v);
1331 }
1332 
1334  QcepDoubleImageDataPtr processed,
1337  QcepMaskDataPtr /*mask*/,
1338  QcepMaskDataPtr overflow,
1339  QcepDoubleList v)
1340 {
1341  if (processed && img) {
1342  processed->copyFrom(img);
1343 
1344  statusMessage(tr("Processing Image \"%1\"").arg(processed->get_FileName()));
1345 
1346  QTime tic;
1347  tic.start();
1348 
1349  if (v.length() > 0) {
1350  processed->set_Normalization(v);
1351  }
1352 
1353  if (qcepDebug(DEBUG_PROCESS)) {
1354  printMessage(tr("Processing Image \"%1\", image number %2, count %3")
1355  .arg(processed->get_FileName()).arg(processed->get_ImageNumber()).arg(getAcquiredCount()));
1356  }
1357 
1358  if (get_PerformDarkSubtraction()) {
1359  subtractDarkImage(processed, dark);
1360  processed -> set_ObjectSaved(false);
1361 
1362  int subTime = tic.restart();
1363 
1364  updateEstimatedTime(prop_PerformDarkSubtractionTime(), subTime);
1365 
1366  if (qcepDebug(DEBUG_PROCESS)) {
1367  printMessage(tr("Dark subtraction took %1 msec").arg(subTime));
1368  }
1369  }
1370 
1371  if (get_PerformBadPixels()) {
1372  correctBadPixels(processed);
1373  processed -> set_ObjectSaved(false);
1374 
1375  int badPxlTime = tic.restart();
1376 
1377  updateEstimatedTime(prop_PerformBadPixelsTime(), badPxlTime);
1378 
1379  if (qcepDebug(DEBUG_PROCESS)) {
1380  printMessage(tr("Bad Pixel correction took %1 msec").arg(badPxlTime));
1381  }
1382  }
1383 
1384  if (get_PerformGainCorrection()) {
1385  correctImageGains(processed);
1386  processed -> set_ObjectSaved(false);
1387 
1388  int gainTime = tic.restart();
1389 
1390  updateEstimatedTime(prop_PerformGainCorrectionTime(), gainTime);
1391 
1392  if (qcepDebug(DEBUG_PROCESS)) {
1393  printMessage(tr("Gain correction took %1 msec").arg(gainTime));
1394  }
1395  }
1396 
1397  if (get_SaveSubtracted()) {
1398  if (processed->get_ObjectSaved()) {
1399  printMessage(tr("Image \"%1\" is already saved").arg(processed->rawFileName()));
1400  } else {
1401  saveNamedImageData(QDir(subtractedOutputDirectory()).filePath(processed->get_FileBase()), processed, overflow);
1402  }
1403  }
1404 
1405  if (get_SaveAsText()) {
1406  saveNamedImageDataAsText(processed->get_FileName(), processed, overflow);
1407 
1408  updateEstimatedTime(prop_SaveAsTextTime(), tic.elapsed());
1409  }
1410 
1411  newData(processed, overflow);
1412 
1413  if (qcepDebug(DEBUG_PROCESS)) {
1414  printMessage(tr("Processing took %1 msec").arg(tic.restart()));
1415  }
1416 
1417  statusMessage(tr("Completed Processing Image \"%1\"").arg(processed->get_FileName()));
1418  }
1419 
1420  return processed;
1421 }
1422 
1424 {
1425  double newVal = prop -> value() * (1.0 - get_AveragingRatio()) + ((double) msec)/1000.0* get_AveragingRatio();
1426 
1427  prop -> setValue(newVal);
1428 }
1429 
1431 {
1432  // if (get_PerformDarkSubtraction()) {
1433  if (dark && image) {
1434  if (dark->get_ExposureTime() != image->get_ExposureTime()) {
1435  printMessage("Exposure times of acquired data and dark image are different, skipping");
1436  return;
1437  }
1438 
1439  if (dark->get_Width() != image->get_Width() ||
1440  dark->get_Height() != image->get_Height()) {
1441  printMessage("Dimensions of acquired data and dark image are different, skipping");
1442  return;
1443  }
1444 
1445  if (dark->get_CameraGain() != image->get_CameraGain()) {
1446  printMessage("Gains of acquired data and dark image are different, skipping");
1447  return;
1448  }
1449 
1450 // if (!(image->get_DataType() == QcepDoubleImageData::Raw16Data ||
1451 // image->get_DataType() == QcepDoubleImageData::Raw32Data)) {
1452 // printMessage("Acquired data is not a raw image, skipping background subtraction");
1453 // return;
1454 // }
1455 
1456  QcepMutexLocker lock1(__FILE__, __LINE__, dark->mutex());
1457  QcepMutexLocker lock2(__FILE__, __LINE__, image->mutex());
1458 
1459  int height = image->get_Height();
1460  int width = image->get_Width();
1461  int nres = image-> get_SummedExposures();
1462  int ndrk = dark -> get_SummedExposures();
1463  int npixels = width*height;
1464 
1465  if (nres <= 0) nres = 1;
1466 
1467  double ratio = ((double) nres)/((double) ndrk);
1468 
1469  // printf("Dark subtraction nres=%d, ndrk=%d, npixels=%d, ratio=%g\n",
1470  // nres, ndrk, npixels, ratio);
1471 
1472  double *result = image->data();
1473  double *dk = dark->data();
1474  double avgraw = 0;
1475  // double avgdark = 0;
1476 
1477  for (int i=0; i<npixels; i++) {
1478  // avgdark += dk[i];
1479  avgraw += result[i];
1480  result[i] = result[i]-ratio*dk[i];
1481  }
1482 
1483  // set_AverageDark(avgdark/npixels/ndrk);
1484  set_AverageRaw(avgraw/npixels/nres);
1485  set_Average(get_AverageRaw() - get_AverageDark());
1486 
1487  image -> set_DataType(QcepDoubleImageData::SubtractedData);
1488  }
1489  // }
1490 }
1491 
1493 {
1494  // if (get_PerformDarkSubtraction()) {
1495  if (dark && image) {
1496  if (dark->get_ExposureTime() != image->get_ExposureTime()) {
1497  printMessage("Exposure times of acquired data and dark image are different, skipping");
1498  return;
1499  }
1500 
1501  if (dark->get_Width() != image->get_Width() ||
1502  dark->get_Height() != image->get_Height()) {
1503  printMessage("Dimensions of acquired data and dark image are different, skipping");
1504  return;
1505  }
1506 
1507  if (dark->get_CameraGain() != image->get_CameraGain()) {
1508  printMessage("Gains of acquired data and dark image are different, skipping");
1509  return;
1510  }
1511 
1512 // if (!(image->get_DataType() == QcepDoubleImageData::Raw16Data ||
1513 // image->get_DataType() == QcepDoubleImageData::Raw32Data)) {
1514 // printMessage("Acquired data is not a raw image, skipping background subtraction");
1515 // return;
1516 // }
1517 
1518  QcepMutexLocker lock1(__FILE__, __LINE__, dark->mutex());
1519  QcepMutexLocker lock2(__FILE__, __LINE__, image->mutex());
1520 
1521  int height = image->get_Height();
1522  int width = image->get_Width();
1523  int nres = image-> get_SummedExposures();
1524  int ndrk = dark -> get_SummedExposures();
1525  int npixels = width*height;
1526 
1527  if (nres <= 0) nres = 1;
1528 
1529  double ratio = ((double) nres)/((double) ndrk);
1530 
1531  // printf("Dark subtraction nres=%d, ndrk=%d, npixels=%d, ratio=%g\n",
1532  // nres, ndrk, npixels, ratio);
1533 
1534  double *result = image->data();
1535  double *dk = dark->data();
1536  double avgraw = 0;
1537  // double avgdark = 0;
1538 
1539  for (int i=0; i<npixels; i++) {
1540  // avgdark += dk[i];
1541  avgraw += result[i];
1542  result[i] = result[i]+ratio*dk[i];
1543  }
1544 
1545  // set_AverageDark(avgdark/npixels/ndrk);
1546  set_AverageRaw(avgraw/npixels/nres);
1547  set_Average(get_AverageRaw() - get_AverageDark());
1548 
1549  image -> set_DataType(QcepDoubleImageData::SubtractedData);
1550  }
1551  // }
1552 }
1553 
1555 {
1556 }
1557 
1559 {
1560  if (image) {
1561  QcepDoubleImageDataPtr gains = gainMap();
1562 
1563  if (gains) {
1564  image -> multiply(gains);
1565  }
1566  }
1567 }
1568 
1570 {
1571  double estSerialTime = 0, estParallelTime = 0;
1572 
1574 
1575  if (acq && get_SaveRawImages()) {
1576  if (acq -> get_SummedExposures() > 1) {
1577  estSerialTime += acq -> get_Raw32SaveTime();
1578  } else {
1579  estSerialTime += acq -> get_Raw16SaveTime();
1580  }
1581  }
1582 
1583  if (get_PerformDarkSubtraction()) {
1584  estParallelTime += get_PerformDarkSubtractionTime();
1585  }
1586 
1587  if (get_PerformBadPixels()) {
1588  estParallelTime += get_PerformBadPixelsTime();
1589  }
1590 
1591  if (get_PerformGainCorrection()) {
1592  estParallelTime += get_PerformGainCorrectionTime();
1593  }
1594 
1595  if (get_SaveSubtracted()) {
1596  estSerialTime += get_SaveSubtractedTime();
1597  }
1598 
1599  if (get_SaveAsText()) {
1600  estSerialTime += get_SaveAsTextTime();
1601  }
1602 
1603  if (get_PerformIntegration()) {
1604  estParallelTime += get_PerformIntegrationTime();
1605  }
1606 
1607  if (get_DisplayIntegratedData()) {
1608  estSerialTime += get_DisplayIntegratedDataTime();
1609  }
1610 
1611  if (get_SaveIntegratedData()) {
1612  estSerialTime += get_SaveIntegratedDataTime();
1613  }
1614 
1615  set_EstimatedProcessingTime(estimatedProcessingTime(estSerialTime, estParallelTime));
1616 }
1617 
1618 double QxrdDataProcessorBase::estimatedProcessingTime(double estSerialTime, double estParallelTime)
1619 {
1620  return estSerialTime + estParallelTime;
1621 }
1622 
1624 {
1625  double min = get_MaskMinimumValue();
1626  double max = get_MaskMaximumValue();
1627 
1628  showMaskRange(min, max);
1629 }
1630 
1631 void QxrdDataProcessorBase::showMaskRange(double min, double max)
1632 {
1634 
1635  if (m_Data && mask()) {
1636  mask() -> showMaskRange(QSharedPointer< QcepImageData<double> >(m_Data), min, max);
1637 
1638  newMask();
1639  }
1640 }
1641 
1643 {
1645 
1646  if (mask()) {
1647  mask() -> hideMaskAll();
1648 
1649  newMask();
1650  }
1651 }
1652 
1654 {
1656 
1657  if (mask()) {
1658  mask() -> showMaskAll();
1659 
1660  newMask();
1661  }
1662 }
1663 
1665 {
1666  double min = get_MaskMinimumValue();
1667  double max = get_MaskMaximumValue();
1668 
1669  hideMaskRange(min, max);
1670 }
1671 
1672 void QxrdDataProcessorBase::hideMaskRange(double min, double max)
1673 {
1675 
1676 
1677  if (m_Data && mask()) {
1678  mask() -> hideMaskRange(QSharedPointer< QcepImageData<double> >(m_Data), min, max);
1679 
1680  newMask();
1681  }
1682 }
1683 
1685 {
1686  if (mask()) {
1687  mask() -> invertMask();
1688 
1689  newMask();
1690  }
1691 }
1692 
1694 {
1696 
1697  if (mask()) {
1698  mask() -> growMask();
1699 
1700  newMask();
1701  }
1702 }
1703 
1705 {
1707 
1708  if (mask()) {
1709  mask() -> shrinkMask();
1710 
1711  newMask();
1712  }
1713 }
1714 
1716 {
1718 
1719  if (mask()) {
1720  if ((rect.left() == rect.right()) && (rect.bottom() == rect.top())) {
1721  mask() -> maskCircle(rect.left(), rect.top(), get_MaskCircleRadius(), get_MaskSetPixels());
1722  } else {
1723  double cx = rect.center().x();
1724  double cy = rect.center().y();
1725  double rad = rect.width()/2;
1726 
1727  mask() -> maskCircle(cx, cy, rad, get_MaskSetPixels());
1728  }
1729 
1730  newMask();
1731  }
1732 }
1733 
1734 void QxrdDataProcessorBase::maskPolygon(QVector<QPointF> poly)
1735 {
1737 
1738  if (mask()) {
1739  // printf("QxrdDataProcessorBase::maskPolygon(%d points ...)\n", poly.size());
1740 
1741  int nRows = mask() -> get_Height();
1742  int nCols = mask() -> get_Width();
1743 
1744  QImage polyImage(nCols, nRows, QImage::Format_RGB32);
1745  QPainter polyPainter(&polyImage);
1746  QPolygonF polygon;
1747 
1748  foreach(QPointF pt, poly) {
1749  polygon.append(pt);
1750  }
1751 
1752  polyPainter.setPen(Qt::white);
1753  polyPainter.fillRect(0,0,nCols,nRows,Qt::black);
1754  polyPainter.setBrush(QBrush(Qt::white, Qt::SolidPattern));
1755  polyPainter.drawPolygon(poly);
1756 
1757  bool newval = get_MaskSetPixels();
1758 
1759  for (int j=0; j<nRows; j++) {
1760  for (int i=0; i<nCols; i++) {
1761  if (qGray(polyImage.pixel(i,j))) {
1762  mask() -> setMaskValue(i, j, newval);
1763  }
1764  }
1765  }
1766 
1767  newMask();
1768  }
1769 }
1770 
1771 void QxrdDataProcessorBase::measurePolygon(QVector<QPointF> poly)
1772 {
1773  foreach(QPointF pt, poly) {
1774  printMessage(tr("Measure pt (%1,%2) = %3").arg(pt.x()).arg(pt.y())
1775  .arg(m_Data -> value(pt.x(),pt.y())));
1776  }
1777 
1779 }
1780 
1782 {
1783  foreach(QPointF pt, poly) {
1784  printMessage(tr("Measure pt (%1,%2)").arg(pt.x()).arg(pt.y()));
1785  }
1786 
1788 }
1789 
1791 {
1792  if (poly.size() >= 3) {
1793  double x0 = poly[0].x();
1794  double y0 = poly[0].y();
1795  double x1 = poly[1].x();
1796  double y1 = poly[1].y();
1797  double x2 = poly[2].x();
1798  double y2 = poly[2].y();
1799  double dx1 = x0-x1, dy1 = y0-y1, dx2 = x2-x1, dy2 = y2-y1;
1800  double a1 = atan2(dy1,dx1), a2 = atan2(dy2,dx2);
1801 
1802  statusMessage(tr("Angle: @ %1,%2, ang %3 deg").arg(x1).arg(y1).arg((a2-a1)/M_PI*180.0));
1803  } else if (poly.size() == 2) {
1804  double x0 = poly[0].x();
1805  double y0 = poly[0].y();
1806  double x1 = poly[1].x();
1807  double y1 = poly[1].y();
1808  double dx = x1-x0;
1809  double dy = y1-y0;
1810  double ang = atan2(dy,dx);
1811  double len = sqrt(dx*dx+dy*dy);
1812 
1813  statusMessage(tr("Line: %1,%2 - %3,%4 : D %5,%6 : L %7 : Ang %8").
1814  arg(x0).arg(y0).arg(x1).arg(y1).
1815  arg(dx).arg(dy).arg(len).arg(ang/M_PI*180.0));
1816 
1817  } else if (poly.size() == 1) {
1818  statusMessage(tr("Point: %1,%2").arg(poly[0].x()).arg(poly[0].y()));
1819  }
1820 }
1821 
1823 {
1824 // if (qcepDebug(DEBUG_INTEGRATOR)) {
1825 // printMessage(tr("processor.data() == %1").arg((long) m_Data.data()));
1826 // }
1827 
1828  return m_Data;
1829 }
1830 
1832 {
1833  return m_DarkFrame;
1834 }
1835 
1837 {
1838  return m_GainMap;
1839 }
1840 
1842 {
1843  return m_BadPixels;
1844 }
1845 
1847 {
1848  return m_LiveData;
1849 }
1850 
1852 {
1853  if (m_Masks.isEmpty()) {
1854  return QcepMaskDataPtr();
1855  } else {
1856  return m_Masks.first();
1857  }
1858 }
1859 
1861 {
1862  if (m_Masks.isEmpty()) {
1863  newMaskStack();
1864  }
1865 }
1866 
1868 {
1869  return m_Overflow;
1870 }
1871 
1873 {
1874  return m_AcquiredCount.fetchAndAddOrdered(+1) + 1;
1875 }
1876 
1878 {
1879  int res = m_AcquiredCount.fetchAndAddOrdered(-1) - 1;
1880 
1881  if (res == 0) {
1882  m_ProcessWaiting.wakeAll();
1883  }
1884 
1885  return res;
1886 }
1887 
1889 {
1890  return m_AcquiredCount.fetchAndAddOrdered(0);
1891 }
1892 
1894 {
1895  QMutex mutex;
1896  QcepMutexLocker lock(__FILE__, __LINE__, &mutex);
1897 
1898  if (getAcquiredCount() == 0) {
1899  return 1;
1900  }
1901 
1902  if (m_ProcessWaiting.wait(&mutex, (int)(time*1000))) {
1903  return getAcquiredCount()==0;
1904  } else {
1905  return 0;
1906  }
1907 }
1908 
1910 {
1911  if (m_Experiment == NULL) {
1912  printMessage("Problem: QxrdDataProcessorBase::experiment == NULL");
1913  }
1914 
1915  return m_Experiment;
1916 }
1917 
1919 {
1920  if (m_CenterFinder == NULL) {
1921  printMessage("Problem QxrdDataProcessorBase::centerFinder == NULL");
1922  }
1923 
1924  return m_CenterFinder;
1925 }
1926 
1928 {
1929  if (m_Integrator == NULL) {
1930  printMessage("Problem QxrdDataProcessorBase::integrator == NULL");
1931  }
1932 
1933  return m_Integrator;
1934 }
1935 
1937 {
1938  if (m_PolarTransform == NULL) {
1939  printMessage("Problem QxrdDataProcessorBase::polarTransform == NULL");
1940  }
1941 
1942  return m_PolarTransform;
1943 }
1944 
1946 {
1947  if (m_PolarNormalization == NULL) {
1948  printMessage("Problem QxrdDataProcessorBase::polarNormalization == NULL");
1949  }
1950 
1951  return m_PolarNormalization;
1952 }
1953 
1955 {
1956  if (m_DistortionCorrection == NULL) {
1957  printMessage("Problem QxrdDataProcessorBase::distortion == NULL");
1958  }
1959 
1960  return m_DistortionCorrection;
1961 }
1962 
1963 void QxrdDataProcessorBase::newImage(int ncols, int nrows)
1964 {
1965  m_Data -> resize(ncols, nrows);
1966  m_Data -> fill(0);
1967 
1969 }
1970 
1971 void QxrdDataProcessorBase::exponentialTail(double cx, double cy, double width, int oversample)
1972 {
1973  int nr = m_Data -> get_Height();
1974  int nc = m_Data -> get_Width();
1975 
1976  for (int y=0; y<nr; y++) {
1977  for (int x=0; x<nc; x++) {
1978  double sum = 0;
1979 
1980  for (int iy = 0; iy < oversample; iy++) {
1981  double yy = (double) y + ((double) iy)/((double) oversample) - cy;
1982  double yy2 = yy*yy;
1983  for (int ix = 0; ix < oversample; ix++) {
1984  double xx = (double) x + ((double) ix)/((double) oversample) - cx;
1985  double xx2 = xx*xx;
1986  double r = sqrt(yy2 + xx2);
1987  sum += exp(-r/width);
1988  }
1989  }
1990 
1991  m_Data -> setValue(x, y, m_Data -> value(x,y) + sum/(oversample*oversample));
1992  }
1993  }
1994 
1996 }
1997 
1998 void QxrdDataProcessorBase::reciprocalTail(double cx, double cy, double strength, int oversample)
1999 {
2000  int nr = m_Data -> get_Height();
2001  int nc = m_Data -> get_Width();
2002 
2003  for (int y=0; y<nr; y++) {
2004  for (int x=0; x<nc; x++) {
2005  double sum = 0;
2006 
2007  for (int iy = 0; iy < oversample; iy++) {
2008  double yy = (double) y + ((double) iy)/((double) oversample) - cy;
2009  double yy2 = yy*yy;
2010  for (int ix = 0; ix < oversample; ix++) {
2011  double xx = (double) x + ((double) ix)/((double) oversample) - cx;
2012  double xx2 = xx*xx;
2013  double r = sqrt(yy2 + xx2);
2014  sum += strength/r;
2015  }
2016  }
2017 
2018  m_Data -> setValue(x, y, m_Data -> value(x,y) + sum/(oversample*oversample));
2019  }
2020  }
2021 
2023 }
2024 
2025 void QxrdDataProcessorBase::powderRing(double cx, double cy, double radius, double width, double strength, int oversample)
2026 {
2027  int nr = m_Data -> get_Height();
2028  int nc = m_Data -> get_Width();
2029 
2030  for (int y=0; y<nr; y++) {
2031  for (int x=0; x<nc; x++) {
2032  double sum = 0;
2033 
2034  for (int iy = 0; iy < oversample; iy++) {
2035  double yy = (double) y + ((double) iy)/((double) oversample) - cy;
2036  double yy2 = yy*yy;
2037  for (int ix = 0; ix < oversample; ix++) {
2038  double xx = (double) x + ((double) ix)/((double) oversample) - cx;
2039  double xx2 = xx*xx;
2040  double r = sqrt(yy2 + xx2);
2041 
2042  double ndr = (r - radius)/width;
2043 
2044  if (fabs(ndr) < 6) {
2045  double val = strength*exp(-2*ndr*ndr)/width*sqrt(2.0/M_PI);
2046  sum += val;
2047  }
2048  }
2049  }
2050 
2051  m_Data -> setValue(x, y, m_Data -> value(x,y) + sum/(oversample*oversample));
2052  }
2053  }
2054 
2056 }
2057 
2058 void QxrdDataProcessorBase::ellipse(double cx, double cy, double a, double e, double ang, double width, double strength, int oversample)
2059 {
2060  int nr = m_Data -> get_Height();
2061  int nc = m_Data -> get_Width();
2062 
2063  for (int y=0; y<nr; y++) {
2064  for (int x=0; x<nc; x++) {
2065  double sum = 0;
2066 
2067  for (int iy = 0; iy < oversample; iy++) {
2068  double yy = (double) y + ((double) iy)/((double) oversample) - cy;
2069  double yy2 = yy*yy;
2070  for (int ix = 0; ix < oversample; ix++) {
2071  double xx = (double) x + ((double) ix)/((double) oversample) - cx;
2072  double xx2 = xx*xx;
2073  double r = sqrt(yy2 + xx2);
2074  double th = atan2(yy,xx);
2075  double elr = a*(1-e*e)/(1 - e*cos(th - ang));
2076  double ndr = (elr - r)/width;
2077 
2078  if (fabs(ndr) < 6) {
2079  double val = strength*exp(-2*ndr*ndr)/width*sqrt(2.0/M_PI);
2080  sum += val;
2081  }
2082  }
2083  }
2084 
2085  m_Data -> setValue(x, y, m_Data -> value(x,y) + sum/(oversample*oversample));
2086  }
2087  }
2088 
2090 }
2091 
2093 {
2095 
2096  if (f) {
2097  if (this->get_SaveIntegratedData()) {
2099 
2100  if (expt) {
2101  expt->openScanFile();
2102  f->writeOutputScan(expt->scanFile(), data);
2103  }
2104  }
2105 
2106  if (this->get_SaveIntegratedInSeparateFiles()) {
2107  f->writeOutputScan(integratedOutputDirectory(), data);
2108  }
2109  }
2110 }
2111 
2113 {
2114  if (this->get_DisplayIntegratedData()) {
2115  emit newIntegrationAvailable(data);
2116  }
2117 }
2118 
2119 void QxrdDataProcessorBase::fileWriteTest(int dim, QString path)
2120 {
2121  long sz = dim*dim;
2122  quint32 *buff = new quint32[sz];
2123 
2124  QTime tic;
2125  tic.start();
2126  int totalt = 0;
2127 
2128  for (int i=0; i<10; i++) {
2129  QString fileName = path+tr("%1.junk").arg(i,5,10,QChar('0'));
2130 
2131  FILE *f = fopen(qPrintable(fileName), "w");
2132 
2133  if (f) {
2134  fwrite(buff, sz, sizeof(quint32), f);
2135  fclose(f);
2136 
2137  int dt = tic.restart();
2138  totalt += dt;
2139  printMessage(tr("file %1 written in %2 msec").arg(fileName).arg(dt));
2140  }
2141  }
2142 
2143  printMessage(tr("average write speed %1 MB/sec")
2144  .arg(((double) sz)*40.0*1000.0/(1e6*((double) totalt))));
2145  delete [] buff;
2146 }
2147 
2149 {
2150  QTime tic;
2151  tic.start();
2152 
2153  if (m_Data && mask()) {
2154  double *res = new double[65536];
2155  long npixels = (m_Data -> get_Height()) * (m_Data -> get_Width());
2156  double *data = m_Data -> data();
2157  short *maskp = mask() -> data();
2158 
2159  for (int i=0; i<65536; i++) {
2160  res[i] = 0;
2161  }
2162 
2163  for (long i=0; i<npixels; i++) {
2164  double v = data[i];
2165  short bin = maskp[i];
2166  bin &= 255;
2167  res[bin] += v;
2168  }
2169 
2170  int dt = tic.restart();
2171 
2172  printMessage(tr("ROI calculated in %1 msec").arg(dt));
2173 
2174  delete [] res;
2175  }
2176 }
2177 
2179 {
2180  QTime tic;
2181  tic.start();
2182 
2183  if (m_Data && mask()) {
2184  double *res = new double[65536];
2185  long npixels = m_Data -> get_Height() * m_Data -> get_Width();
2186  double *data = m_Data -> data();
2187  short *maskp = mask() -> data();
2188 
2189  double minVal = *data;
2190  double maxVal = minVal;
2191 
2192  for (long i=0; i<npixels; i++) {
2193  double v = data[i];
2194  if (v < minVal) minVal = v;
2195  if (v > maxVal) maxVal = v;
2196  }
2197 
2198  for (int i=0; i<65536; i++) {
2199  res[i] = 0;
2200  }
2201 
2202  for (long i=0; i<npixels; i++) {
2203  double v = data[i];
2204  short bin = maskp[i];
2205  res[bin] += v;
2206  }
2207 
2208  int dt = tic.restart();
2209 
2210  printMessage(tr("Histogram calculated in %1 msec").arg(dt));
2211 
2212  delete [] res;
2213  }
2214 }
2215 
2217 {
2218  return m_GenerateTestImage;
2219 }
2220 
2222 {
2224 
2225  m_OutputScan -> set_Title(title);
2226 }
2227 
2229 {
2230  if (m_OutputScan) {
2231  m_OutputScan->append(x,y);
2232  }
2233 }
2234 
2236 {
2237  if (m_OutputScan) {
2239  }
2240 }
2241 
2242 void QxrdDataProcessorBase::saveOutputScan(QString /*fileName*/)
2243 {
2244  if (m_OutputScan) {
2245 
2246  }
2247 }
2248 
2249 QStringList QxrdDataProcessorBase::integrateRectangle(int x0, int y0, int x1, int y1)
2250 {
2251  double sum = 0;
2252  double npx = 0;
2253 
2255  QcepMaskDataPtr msk = mask();
2256  QStringList res;
2257 
2258  if (dat) {
2259  if (msk) {
2260  for (int y=y0; y<y1; y++) {
2261  for (int x=x0; x<x1; x++) {
2262  if (msk->value(x,y)) {
2263  sum += dat->value(x,y);
2264  npx += 1;
2265  }
2266  }
2267  }
2268  } else {
2269  for (int y=y0; y<y1; y++) {
2270  for (int x=x0; x<x1; x++) {
2271  sum += dat->value(x,y);
2272  npx += 1;
2273  }
2274  }
2275  }
2276 
2277  printMessage(tr("integrateRectange(\"%1\",%2,%3,%4,%5)=[%6,%7]=%8")
2278  .arg(dat->get_FileName())
2279  .arg(x0).arg(y0).arg(x1).arg(y1).arg(sum).arg(npx).arg(sum/npx));
2280 
2281  if (npx > 0) {
2282  res << tr("%1").arg(sum/npx);
2283  } else {
2284  res << "0";
2285  }
2286 
2287  res << tr("%1").arg(sum);
2288  res << tr("%1").arg(npx);
2289  res << dat->get_FileName();
2290  }
2291 
2292  return res;
2293 }
2294 
2296 {
2299 
2300  subtractDarkImage(dat, dark);
2301 }
2302 
2304 {
2307 
2308  unsubtractDarkImage(dat, dark);
2309 }
2310 
2312 {
2314 
2315  int wid = dat->get_Width();
2316  int ht = dat->get_Height();
2317 
2318  for (int y=0; y<ht; y++) {
2319  for (int x=0; x<wid; x++) {
2320  dat->setValue(x, y, dat->value(x, y) * scalar);
2321  }
2322  }
2323 }
2324 
2326 {
2328 
2329  int wid = dat->get_Width();
2330  int ht = dat->get_Height();
2331 
2332  for (int y=0; y<ht; y++) {
2333  for (int x=0; x<wid; x++) {
2334  dat->setValue(x, y, dat->value(x, y) + offset);
2335  }
2336  }
2337 }
2338 
2340 {
2342  QxrdMaskStackPtr masks = maskStack();
2343 
2344  if (get_ZingerMask() == ZingerNoMask) {
2345  mask = QcepMaskDataPtr();
2346  } else if (get_ZingerMask() == ZingerDataMask && m_Data) {
2347  mask = m_Data->mask();
2348  } else if (masks) {
2349  mask = masks->value(get_ZingerMask());
2350  }
2351 
2352  int wid = m_Data->get_Width();
2353  int ht = m_Data->get_Height();
2354  int sz1 = get_ZingerSize1();
2355  int sz2 = get_ZingerSize2();
2356  double thr = get_ZingerThreshold();
2357 
2358  QcepMaskDataPtr dest
2360 
2361  for (int y=0; y<ht; y++) {
2362  for (int x=0; x<wid; x++) {
2363  if (mask==NULL || mask->value(x,y)) {
2364  double sum = 0, n = 0;
2365  double val = 0;
2366 
2367  for (int dy=-sz2; dy<=sz2; dy++) {
2368  for (int dx=-sz2; dx<=sz2; dx++) {
2369  if (mask==NULL || mask->value(x+dx, y+dy)) {
2370  if (dx == 0 && dy == 0) {
2371  val = m_Data->value(x+dx, y+dy);
2372  } else {
2373  sum += m_Data->value(x+dx, y+dy);
2374  n += 1;
2375  }
2376  }
2377  }
2378  }
2379 
2380  if (n > 0 && fabs(val-sum/n) >= thr) {
2381  dest->setValue(x,y,0);
2382  }
2383  }
2384  }
2385  }
2386 
2387  if (sz1 > 0) {
2388  for (int i=0; i<sz1; i++) {
2389  dest->growMask();
2390  }
2391  }
2392 
2393  if (mask) {
2394  for (int y=0; y<ht; y++) {
2395  for (int x=0; x<wid; x++) {
2396  if (mask->value(x,y) == 0) {
2397  dest->setValue(x,y,0);
2398  }
2399  }
2400  }
2401  }
2402 
2403  pushMaskStack(dest);
2404  m_Masks.changed();
2405  newMask();
2406 }
2407 
QSharedPointer< QxrdExperiment > QxrdExperimentPtr
QxrdPolarTransformPtr polarTransform() const
QSharedPointer< QxrdCenterFinder > QxrdCenterFinderPtr
QSharedPointer< QxrdWindow > QxrdWindowPtr
Definition: qxrdwindow-ptr.h:6
void multiplyData(double scalar)
QcepMaskDataPtr mask() const
QcepDoubleImageDataPtr m_BadPixels
void powderRing(double cx, double cy, double radius, double width, double strength, int oversample)
QString experimentDirectory() const
static QcepIntegratedDataPtr newIntegratedData(AllocationStrategy strat, QcepDoubleImageDataPtr image, QcepObject *parent)
void newBadPixelsImage(QcepDoubleImageDataPtr image)
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
void subtractDarkImage(QcepDoubleImageDataPtr image, QcepDoubleImageDataPtr dark)
QcepDoubleImageDataPtr m_GainMap
QxrdPolarNormalizationPtr m_PolarNormalization
QSharedPointer< QxrdAcquisition > QxrdAcquisitionPtr
virtual void readSettings(QSettings *set, QString section)
Definition: qcepobject.cpp:119
QcepDoubleImageDataPtr darkImage() const
QString rawOutputDirectory() const
QxrdCenterFinderPtr m_CenterFinder
void newDarkImage(QcepInt16ImageDataPtr image)
void saveOutputScan(QString fileName)
QxrdAcquisitionWPtr m_Acquisition
QcepDoubleImageDataPtr processAcquiredImage(QcepDoubleImageDataPtr processed, QcepDoubleImageDataPtr dimg, QcepDoubleImageDataPtr dark, QcepMaskDataPtr mask, QcepMaskDataPtr overflow, QcepDoubleList v=QcepDoubleList())
void saveNamedImageDataAsText(QString name, QcepDoubleImageDataPtr image, QcepMaskDataPtr overflow, int canOverwrite=NoOverwrite)
QcepDoubleImageDataPtr takeNextFreeImage(int width, int height)
void criticalMessage(QString msg, QDateTime ts=QDateTime::currentDateTime()) const
QString filePathInSubtractedOutputDirectory(QString name) const
QxrdDistortionCorrectionPtr distortionCorrection() const
void appendToOutputScan(double x, double y)
QxrdGenerateTestImageWPtr generateTestImage() const
QString filePathInExperimentDirectory(QString name) const
void saveDark(QString name, int canOverwrite=NoOverwrite)
void newData(QcepDoubleImageDataPtr image, QcepMaskDataPtr overflow)
JSON Parse a string as a JSON object
void newOutputScan(QString title)
void setWindow(QxrdWindowWPtr win)
QWeakPointer< QxrdExperiment > QxrdExperimentWPtr
void statusMessage(QString msg, QDateTime ts=QDateTime::currentDateTime()) const
void newImage(int ncols, int nrows)
QSharedPointer< QcepIntegratedData > QcepIntegratedDataPtr
void popMaskStack(int amount=1)
QxrdGenerateTestImagePtr m_GenerateTestImage
void saveCachedIntensity(QString name)
void updateEstimatedTime(QcepDoubleProperty *prop, int msec)
QxrdDataProcessorBase(QcepSettingsSaverWPtr saver, QxrdExperimentWPtr doc, QxrdAcquisitionWPtr acq, QxrdFileSaverWPtr filesaver)
void saveData(QString name, int canOverwrite=NoOverwrite)
void ellipse(double cx, double cy, double a, double e, double ang, double width, double strength, int oversample)
void readSettings(QSettings *settings, QString section)
void newGainMapImage(QcepDoubleImageDataPtr image)
void writeSettings(QSettings *settings, QString section)
QcepDoubleImageDataPtr m_DarkFrame
void maskPolygon(QVector< QPointF > poly)
QcepDoubleImageDataPtr gainMap() const
static QcepDoubleImageDataPtr newDoubleImage(AllocationStrategy strat, int width, int height, QcepObject *parent)
#define INVOKE_CHECK(res)
Definition: qcepmacros.h:13
QxrdIntegratorPtr integrator() const
void printMeasuredPolygon(QVector< QPointF > poly)
QSharedPointer< QxrdPolarTransform > QxrdPolarTransformPtr
QcepDoubleImageDataPtr badPixels() const
QWeakPointer< QxrdWindow > QxrdWindowWPtr
Definition: qxrdwindow-ptr.h:9
QSharedPointer< QxrdGenerateTestImage > QxrdGenerateTestImagePtr
void saveGainMap(QString name, int canOverwrite=NoOverwrite)
void newIntegrationAvailable(QcepIntegratedDataPtr data)
QString existingOutputDirectory(QString dir, QString subdir) const
QcepDoubleImageDataPtr data() const
void loadBadPixels(QString name)
QSharedPointer< QxrdPolarNormalization > QxrdPolarNormalizationPtr
void saveCachedGeometry(QString name)
void measurePolygon(QVector< QPointF > poly)
QWeakPointer< QxrdFileSaver > QxrdFileSaverWPtr
QString filePathInDarkOutputDirectory(QString name) const
QStringList integrateRectangle(int x0, int y0, int x1, int y1)
QWeakPointer< QxrdGenerateTestImage > QxrdGenerateTestImageWPtr
QList< double > QcepDoubleList
Definition: qcepmacros.h:28
QxrdExperimentWPtr m_Experiment
QcepIntegratedDataPtr m_OutputScan
void correctBadPixels(QcepDoubleImageDataPtr image)
QcepDoubleImageDataPtr m_Data
QSharedPointer< QxrdIntegrator > QxrdIntegratorPtr
QSharedPointer< QcepSettingsSaver > QcepSettingsSaverPtr
void summarizeMeasuredPolygon(QVector< QPointF > poly)
QxrdIntegratorPtr m_Integrator
QcepDoubleImageDataPtr processAcquiredDoubleImage(QcepDoubleImageDataPtr processed, QcepDoubleImageDataPtr image, QcepDoubleImageDataPtr dark, QcepMaskDataPtr mask, QcepMaskDataPtr overflow)
void writeOutputScan(QcepIntegratedDataPtr d)
void pushMaskStack(QcepMaskDataPtr mask=QcepMaskDataPtr())
QxrdPolarTransformPtr m_PolarTransform
void saveNamedMaskData(QString name, QcepMaskDataPtr mask, int canOverwrite=NoOverwrite)
void offsetData(double offset)
virtual void writeSettings(QSettings *set, QString section)
Definition: qcepobject.cpp:114
void setAcquisition(QxrdAcquisitionWPtr acq)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
QcepDoubleImageDataPtr m_LiveData
QString subtractedOutputDirectory() const
void unsubtractDarkImage(QcepDoubleImageDataPtr image, QcepDoubleImageDataPtr dark)
QxrdPolarNormalizationPtr polarNormalization() const
QWeakPointer< QxrdAcquisition > QxrdAcquisitionWPtr
QSharedPointer< QcepInt32ImageData > QcepInt32ImageDataPtr
QcepDoubleImageDataPtr processAcquiredInt16Image(QcepDoubleImageDataPtr processed, QcepInt16ImageDataPtr image, QcepDoubleImageDataPtr dark, QcepMaskDataPtr mask, QcepMaskDataPtr overflow)
QSharedPointer< QxrdFileSaver > QxrdFileSaverPtr
void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime()) const
QxrdDistortionCorrectionPtr m_DistortionCorrection
QString darkOutputDirectory() const
void valueChanged(double val, int index)
QString filePathInDataDirectory(QString name) const
void saveNamedImageData(QString name, QcepDoubleImageDataPtr image, QcepMaskDataPtr overflow, int canOverwrite=NoOverwrite)
QxrdCenterFinderPtr centerFinder() const
void reciprocalTail(double cx, double cy, double strength, int oversample)
QxrdExperimentPtr experiment() const
void loadGainMap(QString name)
static QcepMaskDataPtr newMask(AllocationStrategy strat, int width, int height, int def, QcepObject *parent)
QString filePathInIntegratedOutputDirectory(QString name) const
void valueChanged(int val, int index)
QcepDoubleImageDataPtr processAcquiredInt32Image(QcepDoubleImageDataPtr processed, QcepInt32ImageDataPtr image, QcepDoubleImageDataPtr dark, QcepMaskDataPtr mask, QcepMaskDataPtr overflow)
QSharedPointer< QcepInt16ImageData > QcepInt16ImageDataPtr
void fileWriteTest(int dim, QString path)
QSharedPointer< QcepMaskData > QcepMaskDataPtr
QxrdFileSaverWPtr m_FileSaver
QcepMaskDataPtr overflow() const
QcepDoubleImageDataPtr liveData() const
QSharedPointer< QxrdDistortionCorrection > QxrdDistortionCorrectionPtr
void saveMask(QString name, int canOverwrite=NoOverwrite)
void exponentialTail(double cx, double cy, double width, int oversample)
void valueChanged(bool val, int index)
QWeakPointer< QcepSettingsSaver > QcepSettingsSaverWPtr
QString filePathInRawOutputDirectory(QString name) const
void saveNamedRawImageData(QString name, QcepInt16ImageDataPtr image, QcepMaskDataPtr overflow, int canOverwrite=NoOverwrite)
void correctImageGains(QcepDoubleImageDataPtr image)
void saveBadPixels(QString name, int canOverwrite=NoOverwrite)
QSharedPointer< QcepDoubleImageData > QcepDoubleImageDataPtr
QString integratedOutputDirectory() const