SIRF  3.4.0
NonCartesianEncoding.h
Go to the documentation of this file.
1 /*
2 SyneRBI Synergistic Image Reconstruction Framework (SIRF)
3 Copyright 2020 - 2021 Physikalisch-Technische Bundesanstalt (PTB)
4 
5 This is software developed for the Collaborative Computational
6 Project in Synergistic Reconstruction for Biomedical Imaging (formerly CCP PETMR)
7 (http://www.ccpsynerbi.ac.uk/).
8 
9 Licensed under the Apache License, Version 2.0 (the "License");
10 you may not use this file except in compliance with the License.
11 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 
19 This file contains code snippets from
20 Gadgetron/apps/clients/gadgetron_ismrmrd_client/gadgetron_ismrmrd_client.cpp
21 by Michael S. Hansen
22 
23 GADGETRON SOFTWARE LICENSE V1.0, NOVEMBER 2011
24 
25 PERMISSION IS HEREBY GRANTED, FREE OF CHARGE, TO ANY PERSON OBTAINING
26 A COPY OF THIS SOFTWARE AND ASSOCIATED DOCUMENTATION FILES (THE
27 "SOFTWARE"), TO DEAL IN THE SOFTWARE WITHOUT RESTRICTION, INCLUDING
28 WITHOUT LIMITATION THE RIGHTS TO USE, COPY, MODIFY, MERGE, PUBLISH,
29 DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THE SOFTWARE, AND TO
30 PERMIT PERSONS TO WHOM THE SOFTWARE IS FURNISHED TO DO SO, SUBJECT TO
31 THE FOLLOWING CONDITIONS:
32 
33 THE ABOVE COPYRIGHT NOTICE, THIS PERMISSION NOTICE, AND THE LIMITATION
34 OF LIABILITY BELOW SHALL BE INCLUDED IN ALL COPIES OR REDISTRIBUTIONS
35 OF SUBSTANTIAL PORTIONS OF THE SOFTWARE.
36 
37 SOFTWARE IS BEING DEVELOPED IN PART AT THE NATIONAL HEART, LUNG, AND BLOOD
38 INSTITUTE, NATIONAL INSTITUTES OF HEALTH BY AN EMPLOYEE OF THE FEDERAL
39 GOVERNMENT IN THE COURSE OF HIS OFFICIAL DUTIES. PURSUANT TO TITLE 17,
40 SECTION 105 OF THE UNITED STATES CODE, THIS SOFTWARE IS NOT SUBJECT TO
41 COPYRIGHT PROTECTION AND IS IN THE PUBLIC DOMAIN. EXCEPT AS CONTAINED IN
42 THIS NOTICE, THE NAME OF THE AUTHORS, THE NATIONAL HEART, LUNG, AND BLOOD
43 INSTITUTE (NHLBI), OR THE NATIONAL INSTITUTES OF HEALTH (NIH) MAY NOT
44 BE USED TO ENDORSE OR PROMOTE PRODUCTS DERIVED FROM THIS SOFTWARE WITHOUT
45 SPECIFIC PRIOR WRITTEN PERMISSION FROM THE NHLBI OR THE NIH.THE SOFTWARE IS
46 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
47 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
48 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
50 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
51 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
52 */
53 
63 #ifndef NONCARTESIAN_ENCODING_H
64 #define NONCARTESIAN_ENCODING_H
65 
67 
68 #include <gadgetron/hoNDArray.h>
69 #include <gadgetron/vector_td.h>
70 #include <gadgetron/vector_td_utilities.h>
71 
72 #include <gadgetron/hoNDFFT.h>
73 #include <gadgetron/hoNFFT.h>
74 
75 
76 namespace sirf{
77 
78 typedef Gadgetron::hoNDArray<std::complex<float> > CFGThoNDArr;
79 
87 template <unsigned int D>
88 class Gridder
89 {
90 public:
91  typedef Gadgetron::hoNDArray<Gadgetron::vector_td<float,D> > TrajectoryArrayType;
92 
93  Gridder(const std::vector<size_t> img_output_dims, const TrajectoryArrayType &traj) :
94  nufft_operator_(Gadgetron::from_std_vector<size_t, D>(img_output_dims), (float)this->oversampling_factor_, (float)this->kernel_size_)
95  {
96  setup_nufft(img_output_dims, traj);
97  }
98 
99  void setup_nufft(const std::vector<size_t> img_output_dims, const TrajectoryArrayType &traj)
100  {
101  if( img_output_dims.size() != D)
102  throw LocalisedException("The image dimensions of the output should be of the dimensions of the Gridder." , __FILE__, __LINE__);
103 
104  traj.get_dimensions(this->trajdims_);
105  this->output_dims_ = img_output_dims;
106  this->nufft_operator_.preprocess(traj);
107  }
108 
109  void ifft(CFGThoNDArr& img, const CFGThoNDArr& kdata) const
110  {
111  auto sptr_const_dcw = std::make_shared<Gadgetron::hoNDArray<float> >( this->trajdims_);
112  float const normed_dcw_value = 1.0;
113 
114  sptr_const_dcw ->fill(normed_dcw_value);
115 
116  img.create(this->output_dims_);
117  img.fill(std::complex<float>(0.f, 0.f));
118 
119  this->nufft_operator_.compute(kdata, img, sptr_const_dcw.get(), Gadgetron::NFFT_comp_mode::BACKWARDS_NC2C);
120  }
121 
122  void fft(CFGThoNDArr& kdata, const CFGThoNDArr& img) const
123  {
124  auto sptr_unit_dcw = std::make_shared<Gadgetron::hoNDArray<float> >( this->trajdims_);
125  sptr_unit_dcw ->fill(1.f);
126  kdata.create(this->trajdims_);
127 
128  this->nufft_operator_.compute(img, kdata, sptr_unit_dcw.get(), Gadgetron::NFFT_comp_mode::FORWARDS_C2NC);
129  }
130 
131 protected:
132  static const size_t oversampling_factor_ = 2;
133  static size_t const kernel_size_ = 2;
134 
135  std::vector<size_t> trajdims_;
136  std::vector<size_t> output_dims_;
137 
138  mutable Gadgetron::hoNFFT_plan<float, D> nufft_operator_;
139 };
140 
141 typedef Gridder<2> Gridder2D;
142 
143 
156 {
157 public:
159 
160  virtual void forward(MRAcquisitionData& ac, const CFImage& img) const;
161  virtual void backward(CFImage& img, const MRAcquisitionData& ac) const;
162 protected:
163  Gridder2D::TrajectoryArrayType get_trajectory(const MRAcquisitionData& ac) const;
164 
165 };
166 
168 {
169 public:
171 
172  virtual void forward(MRAcquisitionData& ac, const CFImage& img) const;
173  virtual void backward(CFImage& img, const MRAcquisitionData& ac) const;
174 protected:
175  Gridder2D::TrajectoryArrayType get_trajectory(const MRAcquisitionData& ac) const;
176  std::vector<int> get_slice_encoding_subset_indices(const MRAcquisitionData& full_dataset, unsigned int kspace_enc_step_2) const;
177 
178 };
179 
180 
181 } // namespace sirf
182 #endif // NONCARTESIAN_ENCODING_H
183 
Definition: LocalisedException.h:32
Abstract class defining the interface to perform Fourier transforms.
Definition: FourierEncoding.h:51
Class to perform a NUFFT for 2D data.
Definition: NonCartesianEncoding.h:88
File for cartesian fourier encoding and trajectory setting.
Abstract data container.
Definition: GeometricalInfo.cpp:141
Definition: NonCartesianEncoding.h:167
Implementation to perform a non-cartesian FFT for RPE MR data.
Definition: NonCartesianEncoding.h:155
Abstract MR acquisition data container class.
Definition: gadgetron_data_containers.h:216