Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rearchitect and Reinstate GPU #114

Open
wants to merge 319 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
319 commits
Select commit Hold shift + click to select a range
9423847
Bump NiftyReg version
onurulgen Mar 1, 2023
323182c
Generate coverage and upload it to Coveralls
onurulgen Mar 2, 2023
07e0558
Add badge for the coverage
onurulgen Mar 2, 2023
8538e7f
Add RNifti library
onurulgen Mar 6, 2023
414622b
Add NiftiImageData::Iterator::reset() to reset the iterator
onurulgen Mar 7, 2023
c631dc0
Add move constructor and assignment operator for NiftiImage
onurulgen Mar 7, 2023
4015cbf
Refactorise NiftiImage
onurulgen Mar 7, 2023
5bf6ca8
Add utility functions to NiftiImage
onurulgen Mar 13, 2023
a3b0cc9
Fix dimensions after initialisation of NiftiImage
onurulgen Mar 13, 2023
c863946
Fix a bug causing accessing freed memory in reg_io_WriteImageFile()
onurulgen Mar 13, 2023
43686ab
Refactorisations
onurulgen Mar 13, 2023
61de023
Refactor reg_createControlPointGrid() using automatic memory management
onurulgen Mar 13, 2023
001d498
Refactor reg_createSymmetricControlPointGrids() using automatic memor…
onurulgen Mar 13, 2023
058d4e9
Refactor reg_createImagePyramid() using automatic memory management
onurulgen Mar 13, 2023
0c1e715
Refactor reg_createMaskPyramid() using automatic memory management
onurulgen Mar 13, 2023
3a6d10c
Refactor reg_aladin class using automatic memory management
onurulgen Mar 13, 2023
1130e1f
Refactor reg_aladin_sym class using automatic memory management
onurulgen Mar 13, 2023
591fa91
Refactor reg_aladin app using automatic memory management
onurulgen Mar 13, 2023
4e5db2c
Refactor reg_base class using automatic memory management
onurulgen Mar 13, 2023
099572c
Refactor reg_f3d class using automatic memory management
onurulgen Mar 13, 2023
76c6652
Refactor reg_f3d2 class using automatic memory management
onurulgen Mar 13, 2023
ea8fac0
Refactor reg_f3d app using automatic memory management
onurulgen Mar 13, 2023
d9bc22b
Refactor reg_test_imageGradient using NiftiImage
onurulgen Mar 13, 2023
4f22230
Small fixes
onurulgen Mar 13, 2023
876a88d
Add NiftiImage::disown() to release the wrapped pointer
onurulgen Mar 14, 2023
495ce95
Use NiftiImage::disown() in reg_test_imageGradient
onurulgen Mar 14, 2023
8f96921
Refactor reg_test_interpolation using NiftiImage
onurulgen Mar 14, 2023
751f447
Add NiftiImage::realloc() to reallocate the image data
onurulgen Mar 14, 2023
19883fb
Add NiftiImage::setDim() to set a dimension of the image
onurulgen Mar 14, 2023
d13cf2d
Add ability to NiftiImage for copying only image info
onurulgen Mar 14, 2023
5f92c68
Update tests to leverage new abilities of NiftiImage
onurulgen Mar 14, 2023
4947c2e
Add an enum for NiftiImage dimensions
onurulgen Mar 15, 2023
d087265
Small fixes
onurulgen Mar 15, 2023
379c8f9
Add ability to NiftiImageData for extracting volume data
onurulgen Mar 15, 2023
4061036
Handle optimise* variables in Compute::NormaliseGradient()
onurulgen Mar 15, 2023
b226687
Refactorisations
onurulgen Mar 17, 2023
e9f5eaf
Add NiftiImage::copyData() to copy the pixel data from another image
onurulgen Mar 17, 2023
ade981c
Extend NiftiImage constructor to optionally allocate image data
onurulgen Mar 17, 2023
961700a
Add NiftiImage::totalBytes() to return the total size of the image da…
onurulgen Mar 17, 2023
53ad3a4
Add move constructor and assignment operator to NiftiImageData
onurulgen Mar 17, 2023
f3ba1f5
Remove nodeNumber parameter from GetMaximalLength() and NormaliseGrad…
onurulgen Mar 17, 2023
3592c61
Fix possible bugs causing accessing freed memory
onurulgen Mar 17, 2023
21ed730
Add tests for *Compute::GetMaximalLength() and *Compute::NormaliseGra…
onurulgen Mar 19, 2023
1d50702
Fix a bug in tests causing wrong voxel count calculation
onurulgen Mar 19, 2023
c597115
Fix HAVE_ZLIB definition
onurulgen Mar 20, 2023
c5dbb42
Refactor CMakeLists
onurulgen Mar 20, 2023
7deef0b
Refactorisations
onurulgen Mar 24, 2023
26d195b
Add NormaliseGradient() for CUDA and refactor GetMaximalLength()
onurulgen Mar 24, 2023
516b5ab
Extend tests for *Compute::GetMaximalLength() and *Compute::Normalise…
onurulgen Mar 24, 2023
72b1874
Move platform and measure initialisation into reg_base::SetPlatformTy…
onurulgen Mar 24, 2023
b58b3c8
Refactor NR_CUDA_SAFE_CALL() and NR_CUDA_CHECK_KERNEL()
onurulgen Mar 27, 2023
84afbe4
Refactorisations
onurulgen Mar 28, 2023
a6401b9
Modernise CUDA conjugate gradient functions
onurulgen Mar 29, 2023
66e48c8
Remove unnecessary testing functions
onurulgen Mar 29, 2023
a4ae032
Add tests for conjugate gradient
onurulgen Mar 30, 2023
66db3e8
Refactorisations
onurulgen Apr 3, 2023
9db2187
Generate test data only once for NormaliseGradientTest
onurulgen Apr 3, 2023
18495c9
Refactorisations
onurulgen Apr 5, 2023
1f84a28
Add *Content::UpdateWarped() to transfer warped image to the CUDA device
onurulgen Apr 5, 2023
a753c7f
Use CPU for GetWarpedImage()
onurulgen Apr 5, 2023
54a9990
Use CPU for reg_f3d2::GetWarpedImage()
onurulgen Apr 6, 2023
28bfb04
Handle NiftiImage copy options with an enum
onurulgen Jun 8, 2023
e5a0f42
Fix GPU version of ResampleImage() to make on a par with CPU version
onurulgen Jun 9, 2023
3f92721
Fix GPU version of GetImageGradient() to make on a par with CPU version
onurulgen Jun 9, 2023
5009c86
Refactor cudaCommon_createTextureObject()
onurulgen Jun 9, 2023
6739421
Move EPS value into reg_test_common.h
onurulgen Jun 9, 2023
eb246e6
Refactor reg_localTransformation_kernels.cu
onurulgen Jun 12, 2023
2cccd64
Refactor reg_localTransformation_gpu.cu
onurulgen Jun 12, 2023
c7971ae
Fix GPU version of GetDeformationField() to make on a par with CPU ve…
onurulgen Jun 16, 2023
e15d328
Add tests for *Compute::GetDeformationField()
onurulgen Jun 16, 2023
467027d
Refactorisations
onurulgen Jun 16, 2023
3cbbb00
Add tests for *Compute::VoxelCentricToNodeCentric()
onurulgen Jun 21, 2023
1f6452c
Fix GPU version of VoxelCentricToNodeCentric() to make on a par with …
onurulgen Jun 21, 2023
d59deb9
Fix macOS compilation errors
onurulgen Jun 22, 2023
e6855af
Fix the precision bug of reg_lncc
onurulgen Jun 22, 2023
6cfe8d7
Optimise reg_voxelCentric2NodeCentric_kernel()
onurulgen Jun 23, 2023
d37b15c
Issue #92: Added LNCC unit tests
mmodat Jun 23, 2023
84e79e4
Merge branch 'rearchitect-and-reinstate-gpu' of https://github.com/KC…
mmodat Jun 23, 2023
aa79bf2
Refactorisations
onurulgen Jun 23, 2023
a349585
Fix a bug causing wrong calculation of the affine transformation matrix
onurulgen Jun 28, 2023
5b7d8fe
Issue #92: fix affine initialisation in f3d. matrix went out of scope…
mmodat Jul 7, 2023
a1ed246
Copy affine transformation into reg_base instead of linking
onurulgen Jul 11, 2023
19f45f6
Make affine transformation memory managed in reg_aladin*
onurulgen Jul 11, 2023
570d7a9
Fix CUDA 12 incompatibilities
onurulgen Jul 11, 2023
46bb6c8
Fix a memory leak
onurulgen Jul 11, 2023
c425883
#92: block match & LTS CPU/CUDA regression tests
mmodat Jul 14, 2023
9506815
Refactor the LTS regression test
onurulgen Jul 14, 2023
9e85760
Refactor the BlockMatching regression test
onurulgen Jul 14, 2023
fdf30a4
Refactor the LNCC test
onurulgen Jul 17, 2023
ab5ce4f
Rename OptimiseKernel to LtsKernel
onurulgen Jul 17, 2023
655c6fd
Issue#92: Added BM unit test and fix mask handling
mmodat Jul 18, 2023
4444768
Refactorisations
onurulgen Jul 18, 2023
63bccdd
#92 fixed shared mem race condition in block match
mmodat Jul 19, 2023
8653742
Add NiftiImage::getDataType() returning the current data type
onurulgen Jul 20, 2023
2cd5ce4
Refactor _reg_resampling
onurulgen Jul 20, 2023
efb6331
Fix memory leaks in Content
onurulgen Jul 20, 2023
4006362
Refactor reg_nmi
onurulgen Jul 20, 2023
37c3370
Add symmetric scheme support for reg_nmi_gpu #92
onurulgen Jul 20, 2023
688d9ac
Add NMI regression tests #92
onurulgen Jul 20, 2023
fb586da
#92: Set the test seed to constant for reproducibility
mmodat Jul 24, 2023
4f29800
Issue #92: added a unit test for nmi
mmodat Jul 24, 2023
cd09926
Issue #92: activate CUDA for NMI test
mmodat Jul 24, 2023
a10fe1d
#72 #92 Added an error message when ln is set to 0
mmodat Jul 24, 2023
7204698
Add symmetric scheme support for reg_optimiser_gpu and reg_conjugateG…
onurulgen Jul 24, 2023
6b33dce
Add symmetric scheme support for reg_test_conjugateGradient #92
onurulgen Jul 24, 2023
da81948
#92: added bending energy tests
mmodat Jul 25, 2023
6e67a5b
Issue #68: checks for exising folder before saving
mmodat Jul 25, 2023
76efc9f
Refactorisations
onurulgen Jul 27, 2023
4a98c08
Rearchitect reg_measure to handle forward and backward similarity mea…
onurulgen Jul 31, 2023
c101e74
Disable OpenMP for coverage
onurulgen Jul 31, 2023
8129f1a
Rearchitect reg_measure to handle forward and backward voxel-based si…
onurulgen Aug 1, 2023
30c427d
Remove the symmetric scheme warning from reg_ssd_gpu
onurulgen Aug 3, 2023
82fe6aa
Rearchitect Content classes #92
onurulgen Aug 3, 2023
4bbc879
Add Debug header to handle errors and logging #92
onurulgen Aug 23, 2023
846b2f1
Refactor _reg_common_cuda #92
onurulgen Aug 24, 2023
3516bfe
Convert NMI regression test to a multi-measure regression test #92
onurulgen Aug 24, 2023
cece094
Refactor Cuda::TransferNiftiToDevice and remove Cuda::TransferNiftiTo…
onurulgen Aug 29, 2023
48751ff
Make SSD GPU on a par with the CPU version #92
onurulgen Aug 29, 2023
b1036be
#92 Added nmi gradient test
mmodat Aug 30, 2023
babf772
#92 Added nmi gradient test + pull
mmodat Aug 30, 2023
6fc1323
#92 removed readwritebinary as not needed
mmodat Aug 30, 2023
7d96dfd
#92 changed the def field test to be a unit test against known output
mmodat Aug 30, 2023
7580249
#92 Added spine composition to the unit test
mmodat Aug 30, 2023
eba4a9f
Add NiftiImage::setPixDim()
onurulgen Aug 30, 2023
2ec3de1
Fix test errors
onurulgen Aug 30, 2023
aa472f8
Turn math macros into inline functions #92
onurulgen Aug 30, 2023
c9540be
#92 addded test for composition of DF. CPU only for now
mmodat Aug 31, 2023
a269f05
Fix a bug causing shrunk output images
onurulgen Aug 31, 2023
004414e
Refactor Compute::GetApproximatedGradient()
onurulgen Sep 1, 2023
97966ff
Add NiftiImage::setIntentName()
onurulgen Sep 4, 2023
e1b7ad8
Refactorisations
onurulgen Sep 4, 2023
43181d5
Add more float* operations
onurulgen Sep 8, 2023
9fe8399
Add CUDA image operations
onurulgen Sep 8, 2023
557cc05
Add reg_getMinValue_gpu() and reg_getMaxValue_gpu()
onurulgen Sep 8, 2023
7548147
Implement CudaCompute::GetDefFieldFromVelocityGrid() #92
onurulgen Sep 8, 2023
3557636
#92: fix issue in reg_resample - fix failing test - fix output display
mmodat Sep 8, 2023
86e784f
Merge branch 'rearchitect-and-reinstate-gpu' of https://github.com/KC…
onurulgen Sep 8, 2023
ef4f55b
Fix a bug causing early freeing of the image data
onurulgen Sep 8, 2023
327d516
Refactorisations
onurulgen Sep 8, 2023
4aa2734
Fix precision of GetBasisSplineValue() and GetBasisSplineDerivativeVa…
onurulgen Sep 12, 2023
1b8600c
Fix a bug causing inconsistent results in successive runs of 2D f3d r…
onurulgen Sep 14, 2023
242049a
Refactorisations
onurulgen Sep 14, 2023
80cecbd
Fix wrong calculation of CUDA ApproxLinearEnergyGradient(), GetLandma…
onurulgen Sep 14, 2023
bc7ab04
Refactorisations
onurulgen Sep 18, 2023
336eec5
Implement CudaCompute::ApproxLinearEnergyGradient() #92
onurulgen Sep 18, 2023
8b0df8b
Fixes for CUDA 12
onurulgen Sep 18, 2023
422f69b
Add approximate linear energy gradient regression test #92
onurulgen Sep 18, 2023
0ce908b
Implement CudaCompute::ApproxLinearEnergy() #92
onurulgen Sep 21, 2023
60939a3
Add approximate linear energy regression test #92
onurulgen Sep 21, 2023
118e1da
Fix a bug in reg_spline_approxLinearEnergyGradient_gpu()
onurulgen Oct 5, 2023
e1ec1f4
Refactorisations
onurulgen Oct 5, 2023
47c4a84
Implement the kernel convolution for CUDA #92
onurulgen Oct 6, 2023
9f24fa1
Add regression tests for kernel convolution #92
onurulgen Oct 9, 2023
9b32632
Use ConvKernelType instead of NREG_CONV_KERNEL_TYPE
onurulgen Oct 10, 2023
230c6b9
Fix a bug in the kernel convolution regression test
onurulgen Oct 11, 2023
e04dacd
Optimise Cuda::KernelConvolution()
onurulgen Oct 11, 2023
b6d5097
Optimise reg_getMinMaxValue_gpu()
onurulgen Oct 12, 2023
a8f1232
Update compose deformation field test to include CUDA
onurulgen Oct 12, 2023
d925b8c
Add composition support for CudaCompute::GetDeformationField() #92
onurulgen Oct 13, 2023
563a842
Refactorisations
onurulgen Oct 18, 2023
4c1bc6a
Enable CUDA for NMI gradient unit test
onurulgen Oct 19, 2023
a39e685
Add content creator for f3d2 #92
onurulgen Oct 19, 2023
a4e1918
Refactorisations
onurulgen Oct 23, 2023
67cc123
Add regression tests for Compute::GetDeformationField() #92
onurulgen Oct 23, 2023
694ec87
Remove identifiers starting with a single underscore
onurulgen Oct 23, 2023
b1670e4
Refactorisations
onurulgen Oct 30, 2023
44e6b1b
Fix a bug in CudaCompute::VoxelCentricToNodeCentric() #92
onurulgen Oct 30, 2023
2f65fc9
Make CudaCompute::ResampleImage() on a par with CPU #92
onurulgen Oct 30, 2023
97bce9e
Make CudaCompute::GetDeformationField() on a par with CPU #92
onurulgen Oct 30, 2023
3db10fa
Temporarily disable GetDeformationFieldTest
onurulgen Oct 30, 2023
5eb3163
Make CudaCompute::NormaliseGradient() on a par with CPU #92
onurulgen Oct 31, 2023
1c315f1
Optimise CudaCompute::GetMaximalLength() #92
onurulgen Oct 31, 2023
cd064cb
Update tests
onurulgen Nov 1, 2023
cc92a52
Make CudaCompute::ApproxBendingEnergyGradient() on a par with CPU #92
onurulgen Nov 6, 2023
f021929
Add regression tests for approximate bending energy and approximate b…
onurulgen Nov 6, 2023
f4c3c15
Refactorisations
onurulgen Nov 13, 2023
52204d7
Implement reg_getNmiValue for CUDA #92
onurulgen Nov 14, 2023
bc4c672
Make reg_getVoxelBasedNmiGradient_gpu() on a par with CPU #92
onurulgen Nov 15, 2023
86db434
Add multi-timepoint support for MeasureTest #92
onurulgen Nov 15, 2023
5577571
Refactorisations
onurulgen Nov 16, 2023
f953b5f
Convert reference and floating images to float arrays from cudaArrays…
onurulgen Nov 17, 2023
1e8b36e
Refactorisations
onurulgen Nov 20, 2023
13697c3
Implement multi-timepoint support for CUDA #92
onurulgen Nov 20, 2023
b2a32ff
Implement reg_optimiser_gpu::Perturbation() #92
onurulgen Nov 23, 2023
8182839
Refactor Optimiser #92
onurulgen Nov 23, 2023
592d01d
Optimise Optimiser #92
onurulgen Nov 24, 2023
25aba87
Refactorisations
onurulgen Nov 24, 2023
b9c9bec
Use float gam instead of double in CudaOptimiser
onurulgen Nov 27, 2023
708106f
Optimise CudaResampling #92
onurulgen Nov 28, 2023
b46beb1
Combine GitHub Actions workflows for testing into a single file
onurulgen Nov 29, 2023
07d5ce7
Update GitHub Actions workflow for coverage
onurulgen Nov 29, 2023
f0ebbb1
Refactor CudaLocalTransformation
onurulgen Nov 29, 2023
ce26c69
Optimise Cuda::ApproxLinearEnergyGradient() #92
onurulgen Nov 30, 2023
120386a
Refactorisations
onurulgen Dec 1, 2023
6511740
Optimise Cuda::GetDeformationField() #92
onurulgen Dec 1, 2023
29647ad
Refactor CudaTools #92
onurulgen Jan 8, 2024
a73014e
Optimise Cuda::VoxelCentricToNodeCentric() #92
onurulgen Jan 9, 2024
92ec3ce
Optimise Cuda::DefFieldCompose() #92
onurulgen Jan 10, 2024
4c60059
Implement CudaCompute::SymmetriseVelocityFields() #92
onurulgen Jan 15, 2024
540f10b
Add symmetrise velocity fields regression test #92
onurulgen Jan 15, 2024
b34de37
Implement CudaCompute::UpdateVelocityField() #92
onurulgen Jan 16, 2024
0ddb72b
Add update velocity field regression test #92
onurulgen Jan 16, 2024
cbdea7c
Print the version info
onurulgen Jan 16, 2024
d2bfbe1
Implement Cuda::ResampleGradient() #92
onurulgen Jan 22, 2024
be7e6b7
Add resample gradient regression test #92
onurulgen Jan 22, 2024
1675ba7
Refactorisations
onurulgen Jan 23, 2024
c19f0bd
Add Cuda::GetIntermediateDefFieldFromVelGrid() #92
onurulgen Jan 23, 2024
1a8f4e1
Implement CudaCompute::ExponentiateGradient() #92
onurulgen Jan 24, 2024
69c1fe6
Add exponentiate gradient regression test #92
onurulgen Jan 24, 2024
45698ba
Refactor Cuda::GetAffineDeformationField() #92
onurulgen Jan 25, 2024
db09c2f
Refactor affine deformation field unit test #92
onurulgen Jan 26, 2024
387139a
Add composition to affine deformation field unit test #92
onurulgen Jan 26, 2024
f7d5fc5
Add testing for compute to affine deformation field unit test #92
onurulgen Jan 29, 2024
0a4ba26
Use real index numbers returned from maskCuda in deformationFieldCuda…
onurulgen Jan 30, 2024
587eac1
Use Codecov for coverage
onurulgen Jan 31, 2024
c3c9fda
Update minimum CMake version and use the new CUDA method
onurulgen Feb 5, 2024
2c3432c
Add a GitHub Action to build executables on a release #92
onurulgen Feb 6, 2024
2931554
Use self-hosted runners to enable CUDA for coverage
onurulgen Feb 8, 2024
18cc32b
Add a GitHub Action for static code analysis
onurulgen Feb 13, 2024
640ec07
Fix GPU ID parsing error in reg_f3d
onurulgen Feb 14, 2024
f5a5990
Upgrade libpng to 1.6.42
onurulgen Feb 15, 2024
a74e436
Upgrade zlib to 1.3.1
onurulgen Feb 15, 2024
193ef44
Upgrade RNifti and dependencies
onurulgen Feb 16, 2024
3abfaaa
Fix zlib compilation error
onurulgen Feb 16, 2024
f21c5fb
Fix linting issues of reg_png
onurulgen Feb 19, 2024
1fde5bb
Fix linting issues of nifti1_io
onurulgen Feb 19, 2024
b90d0d5
Enable inline suppressions for static code analysis
onurulgen Feb 19, 2024
7d1f3f8
Exclude Eigen library from static code analysis
onurulgen Feb 19, 2024
6cbbccd
Enable CRT secure warnings
onurulgen Feb 19, 2024
f5e227f
Fix linting issues
onurulgen Feb 20, 2024
1c99a7a
Eliminate dead code
onurulgen Feb 22, 2024
a560060
Use git to download Eigen library
onurulgen Feb 22, 2024
e6d09fc
Refactorisations
onurulgen Feb 23, 2024
cee3df5
Rename Measure as MeasureCreator
onurulgen Feb 23, 2024
e568f95
Refactor _reg_maths* and _reg_common_cuda_kernels
onurulgen Mar 5, 2024
e9f51fe
Embed Eigen library
onurulgen Mar 6, 2024
ebf0387
Replace Divide() with IndexToDims()
onurulgen Mar 6, 2024
f680bce
Add include directories for OpenMP
onurulgen Mar 8, 2024
43c39fa
Refactorisations
onurulgen Jun 1, 2024
7cfe146
Update macOS images in GitHub Actions
onurulgen Jun 12, 2024
41cd5a1
Update the OS image for Coverage
onurulgen Jun 12, 2024
65934f2
Fix linting issues
onurulgen Jun 12, 2024
dd78e8e
Use NiftiImage instead of nifti_image in _reg_ReadWriteImage
onurulgen Jul 12, 2024
cbbdd00
Change the image acquisition behaviour of NiftiImage
onurulgen Jul 12, 2024
1cea3df
Revert "Enable CRT secure warnings"
onurulgen Aug 19, 2024
2915900
Fix *Content::CastImageData() and eliminate its duplicates
onurulgen Aug 19, 2024
d515493
Use NiftiImage in Content classes
onurulgen Aug 27, 2024
7e1e926
Revert "Use float gam instead of double in CudaOptimiser"
onurulgen Aug 27, 2024
a148f14
Fix Floor(), Ceil(), and Round() functions
onurulgen Aug 27, 2024
da1da73
Merge branch 'master' into rearchitect-and-reinstate-gpu
onurulgen Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rearchitect Content classes #92
  • Loading branch information
onurulgen committed Aug 3, 2023
commit 82fe6aae1e4cccd7c72b4b1395d42b69e260b754
2 changes: 1 addition & 1 deletion niftyreg_build_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
299
300
4 changes: 0 additions & 4 deletions reg-lib/AladinContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,3 @@ AladinContent::~AladinContent() {
delete blockMatchingParams;
}
/* *************************************************************** */
void AladinContent::SetCaptureRange(const int voxelCaptureRangeIn) {
blockMatchingParams->voxelCaptureRange = voxelCaptureRangeIn;
}
/* *************************************************************** */
2 changes: 1 addition & 1 deletion reg-lib/AladinContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ class AladinContent: public Content {
protected:
#endif
// Functions for testing
virtual void SetCaptureRange(const int captureRangeIn);
virtual void SetCaptureRange(const int& captureRangeIn) { blockMatchingParams->voxelCaptureRange = captureRangeIn; }
virtual void SetBlockMatchingParams(_reg_blockMatchingParam *bmp) { blockMatchingParams = bmp; }
};
1 change: 1 addition & 0 deletions reg-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ add_library(_reg_compute ${NIFTYREG_LIBRARY_TYPE}
Compute.cpp
AladinContent.cpp
Content.cpp
DefContent.cpp
F3dContent.cpp
Platform.cpp
Measure.cpp
Expand Down
2 changes: 1 addition & 1 deletion reg-lib/Compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void Compute::UpdateControlPointPosition(float *currentDof,
}
/* *************************************************************** */
void Compute::GetImageGradient(int interpolation, float paddingValue, int activeTimepoint) {
F3dContent& con = dynamic_cast<F3dContent&>(this->con);
DefContent& con = dynamic_cast<DefContent&>(this->con);
reg_getImageGradient(con.GetFloating(),
con.GetWarpedGradient(),
con.GetDeformationField(),
Expand Down
5 changes: 4 additions & 1 deletion reg-lib/ContentCreatorFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

#include "ContentCreator.h"
#include "AladinContentCreator.h"
#include "DefContentCreator.h"
#include "F3dContentCreator.h"

enum class ContentType { Base, Aladin, F3d };
enum class ContentType { Base, Aladin, Def, F3d };

class ContentCreatorFactory {
public:
virtual ContentCreator* Produce(const ContentType& conType) {
switch (conType) {
case ContentType::Aladin:
return new AladinContentCreator();
case ContentType::Def:
return new DefContentCreator();
case ContentType::F3d:
return new F3dContentCreator();
default:
Expand Down
67 changes: 67 additions & 0 deletions reg-lib/DefContent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "DefContent.h"
#include "_reg_resampling.h"

/* *************************************************************** */
DefContent::DefContent(nifti_image *referenceIn,
nifti_image *floatingIn,
nifti_image *localWeightSimIn,
int *referenceMaskIn,
mat44 *transformationMatrixIn,
size_t bytesIn):
Content(referenceIn, floatingIn, referenceMaskIn, transformationMatrixIn, bytesIn) {
AllocateWarpedGradient();
AllocateVoxelBasedMeasureGradient();
AllocateLocalWeightSim(localWeightSimIn);
}
/* *************************************************************** */
DefContent::~DefContent() {
DeallocateWarpedGradient();
DeallocateVoxelBasedMeasureGradient();
DeallocateLocalWeightSim();
}
/* *************************************************************** */
void DefContent::AllocateLocalWeightSim(nifti_image *localWeightSimIn) {
if (!localWeightSimIn) return;
localWeightSim = nifti_copy_nim_info(reference);
localWeightSim->dim[0] = localWeightSim->ndim = localWeightSimIn->dim[0];
localWeightSim->dim[4] = localWeightSim->nt = localWeightSimIn->dim[4];
localWeightSim->dim[5] = localWeightSim->nu = localWeightSimIn->dim[5];
localWeightSim->nvox = NiftiImage::calcVoxelNumber(localWeightSim, localWeightSim->ndim);
localWeightSim->data = malloc(localWeightSim->nvox * localWeightSim->nbyper);
reg_getDeformationFromDisplacement(voxelBasedMeasureGradient);
reg_resampleImage(localWeightSimIn, localWeightSim, voxelBasedMeasureGradient, nullptr, 1, 0);
}
/* *************************************************************** */
void DefContent::DeallocateLocalWeightSim() {
if (localWeightSim) {
nifti_image_free(localWeightSim);
localWeightSim = nullptr;
}
}
/* *************************************************************** */
void DefContent::AllocateWarpedGradient() {
warpedGradient = nifti_dup(*deformationField, false);
}
/* *************************************************************** */
void DefContent::DeallocateWarpedGradient() {
if (warpedGradient) {
nifti_image_free(warpedGradient);
warpedGradient = nullptr;
}
}
/* *************************************************************** */
void DefContent::AllocateVoxelBasedMeasureGradient() {
voxelBasedMeasureGradient = nifti_dup(*deformationField, false);
}
/* *************************************************************** */
void DefContent::DeallocateVoxelBasedMeasureGradient() {
if (voxelBasedMeasureGradient) {
nifti_image_free(voxelBasedMeasureGradient);
voxelBasedMeasureGradient = nullptr;
}
}
/* *************************************************************** */
void DefContent::ZeroVoxelBasedMeasureGradient() {
memset(voxelBasedMeasureGradient->data, 0, voxelBasedMeasureGradient->nvox * voxelBasedMeasureGradient->nbyper);
}
/* *************************************************************** */
40 changes: 40 additions & 0 deletions reg-lib/DefContent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include "Content.h"

class DefContent: public virtual Content {
public:
DefContent() = delete;
DefContent(nifti_image *referenceIn,
nifti_image *floatingIn,
nifti_image *localWeightSimIn = nullptr,
int *referenceMaskIn = nullptr,
mat44 *transformationMatrixIn = nullptr,
size_t bytesIn = sizeof(float));
virtual ~DefContent();

// Getters
virtual nifti_image* GetLocalWeightSim() { return localWeightSim; }
virtual nifti_image* GetVoxelBasedMeasureGradient() { return voxelBasedMeasureGradient; }
virtual nifti_image* GetWarpedGradient() { return warpedGradient; }

// Methods for transferring data from nifti to device
virtual void UpdateVoxelBasedMeasureGradient() {}
virtual void UpdateWarpedGradient() {}

// Auxiliary methods
virtual void ZeroVoxelBasedMeasureGradient();

protected:
nifti_image *localWeightSim = nullptr;
nifti_image *voxelBasedMeasureGradient = nullptr;
nifti_image *warpedGradient = nullptr;

private:
void AllocateLocalWeightSim(nifti_image*);
void DeallocateLocalWeightSim();
void AllocateVoxelBasedMeasureGradient();
void DeallocateVoxelBasedMeasureGradient();
void AllocateWarpedGradient();
void DeallocateWarpedGradient();
};
16 changes: 16 additions & 0 deletions reg-lib/DefContentCreator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "ContentCreator.h"
#include "DefContent.h"

class DefContentCreator: public ContentCreator {
public:
virtual DefContent* Create(nifti_image *reference,
nifti_image *floating,
nifti_image *localWeightSim = nullptr,
int *referenceMask = nullptr,
mat44 *transformationMatrix = nullptr,
size_t bytes = sizeof(float)) {
return new DefContent(reference, floating, localWeightSim, referenceMask, transformationMatrix, bytes);
}
};
54 changes: 1 addition & 53 deletions reg-lib/F3dContent.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include "F3dContent.h"
#include "_reg_tools.h"
#include "_reg_resampling.h"

/* *************************************************************** */
F3dContent::F3dContent(nifti_image *referenceIn,
Expand All @@ -10,54 +8,19 @@ F3dContent::F3dContent(nifti_image *referenceIn,
int *referenceMaskIn,
mat44 *transformationMatrixIn,
size_t bytesIn):
DefContent(referenceIn, floatingIn, localWeightSimIn, referenceMaskIn, transformationMatrixIn, bytesIn),
Content(referenceIn, floatingIn, referenceMaskIn, transformationMatrixIn, bytesIn),
controlPointGrid(controlPointGridIn) {
if (!controlPointGridIn) {
reg_print_fct_error("F3dContent::F3dContent()");
reg_print_msg_error("controlPointGridIn can't be nullptr");
reg_exit();
}
AllocateWarpedGradient();
AllocateTransformationGradient();
AllocateVoxelBasedMeasureGradient();
AllocateLocalWeightSim(localWeightSimIn);
}
/* *************************************************************** */
F3dContent::~F3dContent() {
DeallocateWarpedGradient();
DeallocateTransformationGradient();
DeallocateVoxelBasedMeasureGradient();
DeallocateLocalWeightSim();
}
/* *************************************************************** */
void F3dContent::AllocateLocalWeightSim(nifti_image *localWeightSimIn) {
if (!localWeightSimIn) return;
localWeightSim = nifti_copy_nim_info(reference);
localWeightSim->dim[0] = localWeightSim->ndim = localWeightSimIn->dim[0];
localWeightSim->dim[4] = localWeightSim->nt = localWeightSimIn->dim[4];
localWeightSim->dim[5] = localWeightSim->nu = localWeightSimIn->dim[5];
localWeightSim->nvox = NiftiImage::calcVoxelNumber(localWeightSim, localWeightSim->ndim);
localWeightSim->data = malloc(localWeightSim->nvox * localWeightSim->nbyper);
reg_getDeformationFromDisplacement(voxelBasedMeasureGradient);
reg_resampleImage(localWeightSimIn, localWeightSim, voxelBasedMeasureGradient, nullptr, 1, 0);
}
/* *************************************************************** */
void F3dContent::DeallocateLocalWeightSim() {
if (localWeightSim) {
nifti_image_free(localWeightSim);
localWeightSim = nullptr;
}
}
/* *************************************************************** */
void F3dContent::AllocateWarpedGradient() {
warpedGradient = nifti_dup(*deformationField, false);
}
/* *************************************************************** */
void F3dContent::DeallocateWarpedGradient() {
if (warpedGradient) {
nifti_image_free(warpedGradient);
warpedGradient = nullptr;
}
}
/* *************************************************************** */
void F3dContent::AllocateTransformationGradient() {
Expand All @@ -71,22 +34,7 @@ void F3dContent::DeallocateTransformationGradient() {
}
}
/* *************************************************************** */
void F3dContent::AllocateVoxelBasedMeasureGradient() {
voxelBasedMeasureGradient = nifti_dup(*deformationField, false);
}
/* *************************************************************** */
void F3dContent::DeallocateVoxelBasedMeasureGradient() {
if (voxelBasedMeasureGradient) {
nifti_image_free(voxelBasedMeasureGradient);
voxelBasedMeasureGradient = nullptr;
}
}
/* *************************************************************** */
void F3dContent::ZeroTransformationGradient() {
memset(transformationGradient->data, 0, transformationGradient->nvox * transformationGradient->nbyper);
}
/* *************************************************************** */
void F3dContent::ZeroVoxelBasedMeasureGradient() {
memset(voxelBasedMeasureGradient->data, 0, voxelBasedMeasureGradient->nvox * voxelBasedMeasureGradient->nbyper);
}
/* *************************************************************** */
19 changes: 2 additions & 17 deletions reg-lib/F3dContent.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include "Content.h"
#include "DefContent.h"

class F3dContent: public virtual Content {
class F3dContent: public virtual DefContent {
public:
F3dContent() = delete;
F3dContent(nifti_image *referenceIn,
Expand All @@ -16,35 +16,20 @@ class F3dContent: public virtual Content {

// Getters
virtual nifti_image* GetControlPointGrid() { return controlPointGrid; }
virtual nifti_image* GetLocalWeightSim() { return localWeightSim; }
virtual nifti_image* GetTransformationGradient() { return transformationGradient; }
virtual nifti_image* GetVoxelBasedMeasureGradient() { return voxelBasedMeasureGradient; }
virtual nifti_image* GetWarpedGradient() { return warpedGradient; }

// Methods for transferring data from nifti to device
virtual void UpdateControlPointGrid() {}
virtual void UpdateTransformationGradient() {}
virtual void UpdateVoxelBasedMeasureGradient() {}
virtual void UpdateWarpedGradient() {}

// Auxiliary methods
virtual void ZeroTransformationGradient();
virtual void ZeroVoxelBasedMeasureGradient();

protected:
nifti_image *controlPointGrid = nullptr;
nifti_image *localWeightSim = nullptr;
nifti_image *transformationGradient = nullptr;
nifti_image *voxelBasedMeasureGradient = nullptr;
nifti_image *warpedGradient = nullptr;

private:
void AllocateLocalWeightSim(nifti_image*);
void DeallocateLocalWeightSim();
void AllocateWarpedGradient();
void DeallocateWarpedGradient();
void AllocateTransformationGradient();
void DeallocateTransformationGradient();
void AllocateVoxelBasedMeasureGradient();
void DeallocateVoxelBasedMeasureGradient();
};
5 changes: 3 additions & 2 deletions reg-lib/Measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ reg_measure* Measure::Create(const MeasureType& measureType) {
return new reg_kld();
case MeasureType::Mind:
return new reg_mind();
case MeasureType::Mindssc:
case MeasureType::MindSsc:
return new reg_mindssc();
}
reg_print_fct_error("Measure::Create");
reg_print_msg_error("Unsupported measure type");
reg_exit();
return nullptr;
}
/* *************************************************************** */
void Measure::Initialise(reg_measure& measure, F3dContent& con, F3dContent *conBw) {
void Measure::Initialise(reg_measure& measure, DefContent& con, DefContent *conBw) {
measure.InitialiseMeasure(con.GetReference(),
con.GetFloating(),
con.GetReferenceMask(),
Expand Down
6 changes: 3 additions & 3 deletions reg-lib/Measure.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#include "F3dContent.h"
#include "DefContent.h"
#include "_reg_measure.h"

enum class MeasureType { Nmi, Ssd, Dti, Lncc, Kld, Mind, Mindssc };
enum class MeasureType { Nmi, Ssd, Dti, Lncc, Kld, Mind, MindSsc };

class Measure {
public:
virtual reg_measure* Create(const MeasureType& measureType);
virtual void Initialise(reg_measure& measure, F3dContent& con, F3dContent *conBw = nullptr);
virtual void Initialise(reg_measure& measure, DefContent& con, DefContent *conBw = nullptr);
};
8 changes: 3 additions & 5 deletions reg-lib/_reg_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,7 @@ void reg_base<T>::CheckParameters() {
/* *************************************************************** */
template<class T>
void reg_base<T>::InitialiseSimilarity() {
// TODO Move this function to reg_f3d
F3dContent& con = dynamic_cast<F3dContent&>(*this->con);
DefContent& con = dynamic_cast<DefContent&>(*this->con);

if (measure_nmi)
measure->Initialise(*measure_nmi, con);
Expand Down Expand Up @@ -604,8 +603,7 @@ double reg_base<T>::ComputeSimilarityMeasure() {
template<class T>
void reg_base<T>::GetVoxelBasedGradient() {
// The voxel based gradient image is filled with zeros
// TODO Temporarily call F3dContent. This function will be moved to reg_f3d
dynamic_cast<F3dContent&>(*con).ZeroVoxelBasedMeasureGradient();
dynamic_cast<DefContent&>(*con).ZeroVoxelBasedMeasureGradient();

// The intensity gradient is first computed
// if(measure_nmi || measure_ssd ||
Expand Down Expand Up @@ -725,7 +723,7 @@ void reg_base<T>::UseMIND(int timepoint, int offset) {
template<class T>
void reg_base<T>::UseMINDSSC(int timepoint, int offset) {
if (!measure_mindssc)
measure_mindssc.reset(dynamic_cast<reg_mindssc*>(measure->Create(MeasureType::Mindssc)));
measure_mindssc.reset(dynamic_cast<reg_mindssc*>(measure->Create(MeasureType::MindSsc)));
measure_mindssc->SetTimepointWeight(timepoint, 1.0);//weight set to 1.0 to indicate timepoint is active
measure_mindssc->SetDescriptorOffset(offset);
#ifndef NDEBUG
Expand Down
1 change: 0 additions & 1 deletion reg-lib/_reg_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class reg_base: public InterfaceOptimiser {
unsigned levelToPerform;
T gradientSmoothingSigma;
T similarityWeight;
bool additive_mc_nmi;
bool useConjGradient;
bool useApproxGradient;
bool verbose;
Expand Down
1 change: 1 addition & 0 deletions reg-lib/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ cuda_add_library(${NAME} ${NIFTYREG_LIBRARY_TYPE}
CudaCompute.cpp
CudaContent.cpp
CudaContext.cpp
CudaDefContent.cpp
CudaF3dContent.cpp
CudaKernelFactory.cpp
CudaMeasure.cpp
Expand Down
Loading