From 88f47b7e0f3521bab97a49f05fb272068acfca43 Mon Sep 17 00:00:00 2001 From: Ali Aghaeifar Date: Sun, 20 Oct 2024 13:05:05 +0200 Subject: [PATCH] better random positioning --- src/kernels.cu | 14 +++++--------- src/spinwalk.cu | 17 +++++++---------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/kernels.cu b/src/kernels.cu index e2a23a8..ab68e34 100644 --- a/src/kernels.cu +++ b/src/kernels.cu @@ -215,7 +215,7 @@ void sim(const simulation_parameters *param, const float *pFieldMap, const uint8 // update old position with the new one if(param->enRecordTrajectory && (current_timepoint != 0 || dummy_scan != 0)) - xyz1 += 3; + xyz1 += 3; for (uint8_t i=0; i < 3; i++) xyz1[i] = xyz_old[i] = xyz_new[i]; // increase timepoint @@ -240,15 +240,11 @@ void sim(const simulation_parameters *param, const float *pFieldMap, const uint8 __host__ #endif void randPosGen(float *spin_position_xyz, const simulation_parameters ¶m) -{ - float res[3]; - for (uint8_t i = 0; i < 3; i++) - res[i] = param.fov[i] / param.fieldmap_size[i]; - +{ std::mt19937 gen(param.seed); - std::uniform_real_distribution dist_initial_x(res[0], param.fov[0] - res[0]); - std::uniform_real_distribution dist_initial_y(res[1], param.fov[1] - res[1]); - std::uniform_real_distribution dist_initial_z(res[2], param.fov[2] - res[2]); + std::uniform_real_distribution dist_initial_x(0.01*param.fov[0], 0.99*param.fov[0]); + std::uniform_real_distribution dist_initial_y(0.01*param.fov[1], 0.99*param.fov[1]); + std::uniform_real_distribution dist_initial_z(0.01*param.fov[2], 0.99*param.fov[2]); for (size_t i = 0; i < param.n_spins; i++) { diff --git a/src/spinwalk.cu b/src/spinwalk.cu index 7a103d7..56ced6d 100644 --- a/src/spinwalk.cu +++ b/src/spinwalk.cu @@ -205,13 +205,13 @@ bool run(simulation_parameters param, std::map()); gpuCheckKernelExecutionError(__FILE__, __LINE__); - cu_sim<<>>(d_param,thrust::raw_pointer_cast(d_pFieldMap.data()), - thrust::raw_pointer_cast(d_pMask.data()), - thrust::raw_pointer_cast(d_M0.data()), - thrust::raw_pointer_cast(d_XYZ0_scaled.data()), - thrust::raw_pointer_cast(d_M1.data()), - thrust::raw_pointer_cast(d_XYZ1.data()), - thrust::raw_pointer_cast(d_T.data())); + cu_sim<<>>(d_param, thrust::raw_pointer_cast(d_pFieldMap.data()), + thrust::raw_pointer_cast(d_pMask.data()), + thrust::raw_pointer_cast(d_M0.data()), + thrust::raw_pointer_cast(d_XYZ0_scaled.data()), + thrust::raw_pointer_cast(d_M1.data()), + thrust::raw_pointer_cast(d_XYZ1.data()), + thrust::raw_pointer_cast(d_T.data())); gpuCheckKernelExecutionError(__FILE__, __LINE__); // copy data back to CPU size_t shift = 3*param.n_TE*param.n_spins*sl; @@ -253,9 +253,6 @@ bool run(simulation_parameters param, std::map TE; for(int i=0; i