TEST(Projection, Forward) { cudaDeviceReset(); //Case 1: { int3 dimsvolume = {8, 8, 8}; int3 dimsimage = {8, 8, 1}; tfloat3 angles = tfloat3(PI / 2.0f, PI / 2.0f, 0.0f); tfloat2 shifts = tfloat2(0, 0); tfloat weight = (tfloat)1; tfloat* d_inputvolume = (tfloat*)CudaMallocFromBinaryFile("Data\\Projection\\Input_Forward_1.bin"); tfloat* d_volumepsf = CudaMallocValueFilled(ElementsFFT(dimsvolume), (tfloat)1); tfloat* d_proj = (tfloat*)CudaMallocValueFilled(Elements(dimsimage), (tfloat)0); tfloat* desired_output = (tfloat*)MallocFromBinaryFile("Data\\Projection\\Output_Forward_1.bin"); tfloat* d_projpsf = CudaMallocValueFilled(ElementsFFT(dimsimage), (tfloat)0); d_ProjForward(d_inputvolume, d_volumepsf, dimsvolume, d_proj, d_projpsf, &angles, &shifts, T_INTERP_CUBIC, 1); tfloat* h_output = (tfloat*)MallocFromDeviceArray(d_proj, Elements(dimsimage) * sizeof(tfloat)); double MeanAbsolute = GetMeanAbsoluteError((tfloat*)desired_output, (tfloat*)h_output, Elements(dimsimage)); ASSERT_LE(MeanAbsolute, 1e-5); cudaFree(d_inputvolume); cudaFree(d_proj); free(desired_output); free(h_output); } cudaDeviceReset(); }
TEST(Reconstruction, Fourier) { cudaDeviceReset(); //Case 1: /*{ int3 dimsvolume = {16, 16, 16}; int3 dimsimage = {16, 16, 2249}; tfloat* d_inputproj = (tfloat*)CudaMallocFromBinaryFile("Data\\Reconstruction\\Input_ARTProj_2.bin"); tfloat3* h_inputangles = (tfloat3*)MallocFromBinaryFile("Data\\Reconstruction\\Input_ARTAngles_2.bin"); tfloat* desired_output = (tfloat*)MallocFromBinaryFile("Data\\Reconstruction\\Output_ART_2.bin"); tfloat* d_volume; cudaMalloc((void**)&d_volume, Elements(dimsvolume) * sizeof(tfloat)); tfloat* h_output = (tfloat*)MallocFromDeviceArray(d_volume, Elements(dimsvolume) * sizeof(tfloat)); tfloat outputmax = (tfloat)-999999; for (int i = 0; i < Elements(dimsvolume); i++) outputmax = max(outputmax, h_output[i]); //for (int i = 0; i < Elements(dimsvolume); i++) //h_output[i] /= outputmax; double MeanAbsolute = GetMeanAbsoluteError((tfloat*)desired_output, (tfloat*)h_output, Elements(dimsvolume)); //ASSERT_LE(MeanRelative, 1e-5); cudaFree(d_volume); cudaFree(d_inputproj); free(desired_output); free(h_output); }*/ //Case 2: { int3 dimsori = toInt3(128, 128, 128); int3 dimspadded = toInt3(259, 259, 259); tfloat* h_weights = (tfloat*)malloc(ElementsFFT(dimspadded) * sizeof(tfloat)); ReadMRC("d_weights.mrc", (void**)&h_weights); tfloat* d_weights = (tfloat*)CudaMallocFromHostArray(h_weights, ElementsFFT(dimspadded) * sizeof(tfloat)); tcomplex* h_data = (tcomplex*)malloc(ElementsFFT(dimspadded) * sizeof(tcomplex)); ReadMRC("d_dataRe.mrc", (void**)&h_weights); for (int i = 0; i < ElementsFFT(dimspadded); i++) h_data[i].x = h_weights[i]; ReadMRC("d_dataIm.mrc", (void**)&h_weights); for (int i = 0; i < ElementsFFT(dimspadded); i++) h_data[i].y = h_weights[i]; tcomplex* d_data = (tcomplex*)CudaMallocFromHostArray(h_data, ElementsFFT(dimspadded) * sizeof(tcomplex)); tfloat* d_reconstructed = CudaMallocValueFilled(Elements(dimsori), (tfloat)0); d_ReconstructGridding(d_data, d_weights, d_reconstructed, dimsori, dimspadded); } cudaDeviceReset(); }
TEST(Masking, ConeMask) { cudaDeviceReset(); //Case 1: { int3 dims = toInt3(64, 64, 64); tfloat* d_volume = CudaMallocValueFilled(ElementsFFT(dims), (tfloat)1); d_ConeMaskFT(d_volume, d_volume, dims, make_float3(cos(ToRad(30.0)), sin(ToRad(30.0)), 0), ToRad(10.0)); d_WriteMRC(d_volume, toInt3(dims.x / 2 + 1, dims.y, dims.z), "d_conemask.mrc"); } cudaDeviceReset(); }