@@ -18,10 +18,10 @@ namespace rl {
1818 * of the cropping during the NUFFT. I also tested simply grid adj * grid, which gave reasonable results but would do a double
1919 * convolution with the gridding kernel.
2020 */
21- template <int ND> auto KSpaceSingle (GridOpts<ND> const &gridOpts, TrajectoryN<ND> const &traj, float const λ, Basis::CPtr basis)
22- -> Re2
21+ template <int ND>
22+ auto KSpaceSingle (GridOpts<ND> const &gridOpts, TrajectoryN<ND> const &traj, float const max, Basis::CPtr basis) -> Re2
2323{
24- Log::Print (" Precon" , " Starting preconditioner calculation λ {} " , λ );
24+ Log::Print (" Precon" , " Starting preconditioner calculation" );
2525 TrajectoryN<ND> newTraj (traj.points () * 2 .f , MulToEven (traj.matrix (), 2 ), traj.voxelSize () / 2 .f );
2626 auto nufft = TOps::MakeNUFFT<ND>(gridOpts, newTraj, 1 , basis);
2727 Cx3 W (nufft->oshape );
@@ -30,7 +30,7 @@ template <int ND> auto KSpaceSingle(GridOpts<ND> const &gridOpts, TrajectoryN<ND
3030 CxN<ND + 2 > ones (AddBack (traj.matrix (), psf.dimension (ND), psf.dimension (ND + 1 )));
3131 ones.setConstant (1 .f );
3232 TOps::Pad<ND + 2 > padX (ones.dimensions (), psf.dimensions ());
33- CxN<ND + 2 > xcor (padX.oshape );
33+ CxN<ND + 2 > xcor (padX.oshape );
3434 xcor.device (Threads::TensorDevice ()) = padX.forward (ones);
3535 FFT::Forward (xcor, FirstN<ND>(Sz3{0 , 1 , 2 }));
3636 xcor.device (Threads::TensorDevice ()) = xcor * xcor.conjugate ();
@@ -40,9 +40,8 @@ template <int ND> auto KSpaceSingle(GridOpts<ND> const &gridOpts, TrajectoryN<ND
4040 float scale =
4141 std::pow (Product (FirstN<ND>(psf.dimensions ())), 1 .5f ) / Product (traj.matrix ()) / Product (FirstN<ND>(ones.dimensions ()));
4242 Re3 weights = nufft->forward (xcor).abs () * scale;
43-
44- // weights.device(Threads::TensorDevice()) = (weights == 0.f).select(weights.constant(1.f), (1.f + λ) / (weights + λ));
45- weights.device (Threads::TensorDevice ()) = (weights < 1 .f ).select (weights.constant (1 .f ), 1 .f / weights);
43+ Log::Print (" Precon" , " Thresholding to {}" , max);
44+ weights.device (Threads::TensorDevice ()) = (weights < 1 .f / max).select (weights.constant (max), 1 .f / weights);
4645
4746 float const norm = Norm<true >(weights);
4847 if (!std::isfinite (norm)) {
@@ -70,9 +69,9 @@ auto KSpaceMulti(Cx5 const &smaps, GridOpts<3> const &gridOpts, Trajectory const
7069 Index const nTrace = traj.nTraces ();
7170 Re3 weights (nC, nSamp, nTrace);
7271
73- auto nufft = TOps::NUFFT<3 >(gridOpts, newTraj, 1 , basis);
74- Sz5 const psfShape = nufft.ishape ;
75- Sz5 const smapShape = smaps.dimensions ();
72+ auto nufft = TOps::NUFFT<3 >(gridOpts, newTraj, 1 , basis);
73+ Sz5 const psfShape = nufft.ishape ;
74+ Sz5 const smapShape = smaps.dimensions ();
7675 Index const nB = smapShape[3 ];
7776 if (nB > 1 && nB != psfShape[3 ]) {
7877 throw Log::Failure (" Precon" , " SENSE maps had basis dimension {}, expected {}" , nB, psfShape[3 ]);
@@ -159,7 +158,7 @@ template <int ND, int NB> auto MakeKSpacePrecon(PreconOpts const &opts,
159158 Log::Print (" Precon" , " Using no preconditioning" );
160159 return nullptr ;
161160 } else if (opts.type == " single" ) {
162- Re2 const w = KSpaceSingle (gridOpts, traj, opts.λ );
161+ Re2 const w = KSpaceSingle (gridOpts, traj, opts.max );
163162 return std::make_shared<TOps::TensorScale<3 + NB, 1 , NB>>(shape, w.cast <Cx>());
164163 } else if (opts.type == " multi" ) {
165164 throw Log::Failure (" Precon" , " Multichannel preconditioner requested without SENSE maps" );
@@ -193,10 +192,10 @@ template <int ND, int NB> auto MakeKSpacePrecon(PreconOpts const &opts,
193192 Log::Print (" Precon" , " Using no preconditioning" );
194193 return nullptr ;
195194 } else if (opts.type == " single" ) {
196- Re2 const w = KSpaceSingle (gridOpts, traj, opts.λ );
195+ Re2 const w = KSpaceSingle (gridOpts, traj, opts.max );
197196 return std::make_shared<TOps::TensorScale<3 + NB, 1 , NB>>(shape, w.cast <Cx>());
198197 } else if (opts.type == " multi" ) {
199- Re3 const w = KSpaceMulti (smaps, gridOpts, traj, opts.λ );
198+ Re3 const w = KSpaceMulti (smaps, gridOpts, traj, opts.max );
200199 return std::make_shared<TOps::TensorScale<3 + NB, 0 , NB>>(shape, w.cast <Cx>());
201200 } else {
202201 return LoadKSpacePrecon<NB>(opts.type , traj.nSamples (), traj.nTraces (), shape);
0 commit comments