Xmipp  v3.23.11-Nereus
phantom_movie.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: David Strelak (davidstrelak@gmail.com)
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #pragma once
27 
28 #include "core/xmipp_filename.h"
29 #include "data/dimensions.h"
30 
31 template <typename T>
32 class MultidimArray;
33 
37 template <typename T>
38 class PhantomMovie final
39 {
40 public:
42  {
43  float a1;
44  float a2;
45  float b1;
46  float b2;
47  float k1_start;
48  float k1_end;
49  float k2_start;
50  float k2_end;
51  bool simple;
52  static constexpr auto doc = "x(t) = a1*t + a2*t*t + cos(t)/10\n"
53  "y(t) = b1*t + b2*t*t + sin(t*t)/5\n"
54  "The barrel/pincushion transform params are linearly interpolated between first and last frame.\n"
55  "For normalized coordinates ([-1..1]) its distance is given by:\n"
56  "r_out = r_in(1 + k1*(r_in)^2 + k2*(r_in)^4"
57  "X and Y shift can be overriden, then only a1 and b1 will be used";
58  static constexpr auto shift_param = "--shift";
59  static constexpr auto barrel_param = "--barrel";
60  static constexpr auto simple_param = "--simple";
61  };
62 
63  struct Options
64  {
65  bool skipBarrel;
66  bool skipShift;
68  bool skipDose;
69  bool skipIce;
70  };
71 
72  struct Ice
73  {
74  int seed;
75  float avg;
76  float stddev;
77  float min;
78  float max;
79  float low_w1;
80  float low_raised_w;
81  };
82 
83  struct Params
84  {
85  Dimensions req_size = Dimensions(1);
86  Dimensions work_size = Dimensions(1);
90  };
91 
92  enum class PhantomType
93  {
94  grid,
95  particleCross,
96  particleCircle
97  };
98 
99  struct Content
100  {
102  size_t xstep; // of the grid
103  size_t ystep; // of the grid
104  size_t thickness; // of the line
105  size_t minSize; // of the circle / cross
106  size_t maxSize; // of the circle / cross
107  size_t count; // of the circle / cross
108  float signal_val;
109  int seed;
110  float dose;
111  };
112 
113  PhantomMovie(DisplacementParams dp, Options o, Ice i, Content c, Params p) : params(p), dispParams(dp), options(o), ice(i), content(c) {}
114 
115  void run() const;
116 
117 private:
118  void addContent(MultidimArray<T> &movie) const;
119  void addGrid(MultidimArray<T> &frame) const;
120  void addCircles(MultidimArray<T> &frame) const;
121  void addCrosses(MultidimArray<T> &frame) const;
122  T bilinearInterpolation(const MultidimArray<T> &src, float x, float y) const;
123  auto shiftX(size_t t) const;
124  auto shiftY(size_t t) const;
125  void generateIce(MultidimArray<T> &frame) const;
126  template <bool SKIP_DOSE>
127  void generateMovie(const MultidimArray<T> &refFrame) const;
128  void applyLowPass(MultidimArray<T> &frame) const;
129  void displace(float &x, float &y, size_t n) const;
130  MultidimArray<T> findWorkSize() const;
131 
132  const Params params;
133  const DisplacementParams dispParams;
134  const Options options;
135  const Ice ice;
136  const Content content;
137 };
static constexpr auto doc
Definition: phantom_movie.h:52
doublereal * c
static double * y
static constexpr auto shift_param
Definition: phantom_movie.h:58
doublereal * x
#define i
static constexpr auto barrel_param
Definition: phantom_movie.h:59
PhantomMovie(DisplacementParams dp, Options o, Ice i, Content c, Params p)
void run() const
static constexpr auto simple_param
Definition: phantom_movie.h:60
int * n