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

SIRFReg #211

Merged
merged 391 commits into from Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
391 commits
Select commit Hold shift + click to select a range
42c5583
Set swapsize when changing datatype
Oct 8, 2018
d93b943
Save to file using nbyper not datatype string
Oct 8, 2018
3b89beb
Tiny codacy changes
Oct 8, 2018
d1b794e
Undo unintentional changes to files (eg whitespace)
Oct 9, 2018
dd7bdd9
update() -> process()
Oct 12, 2018
c3e25b8
Always use `const std::string &`
Oct 12, 2018
87c527b
Rename back->inverse (and fwrd->forward)
Oct 12, 2018
a4396f2
TODO commented out test. resample != aladin
Oct 8, 2018
b128e8c
SIRFReg::check_parameters -> const method
Oct 12, 2018
5f7244d
No need to store bool in SIRFRegImageWeightedMean::check_can_do_mean
Oct 12, 2018
f2a8ca9
filenames: use `.empty()` instead of `size() == 0`
Oct 12, 2018
20ad798
Remove SIRFRegMat44::fill()
Oct 12, 2018
44825b3
SIRFRegMat44::save_to_file() is now virtual
Oct 12, 2018
9416b97
Remove `using_namespace_std`
Oct 16, 2018
9c75a3e
Use enum for setting interpolation type
Oct 17, 2018
5eb63fe
Use SIRFREG_ options in CMake for grouping
Oct 16, 2018
6511a6d
Rename NiftiImage -> NiftiImageData
Oct 17, 2018
86126c9
Only return output if resampling is finished
Oct 22, 2018
6c49a5e
Merge remote-tracking branch 'CCP/master' into SIRFReg
Oct 24, 2018
06825db
SIRFRegMat44 -> SIRFRegAffineTransformation
Oct 19, 2018
2e0b45c
Update sirfreg_aladin
Oct 27, 2018
bc744b2
Check that an image is initialised before copying
Oct 27, 2018
591bd5c
Move offsets when cropping. Set to -1 to leave unchanged.
Nov 1, 2018
5d8e8f4
Get inverse of 4x4 matrix
Nov 1, 2018
fa12850
Merge remote-tracking branch 'CCP/master' into SIRFReg
Nov 1, 2018
638da54
Appease codacy (doesn't actually change anything)
Nov 2, 2018
d254980
fill from array (c++ and python, not matlab)
Nov 2, 2018
352a1b9
Add masks for floating and reference images (only c++ & matlab)
Nov 2, 2018
10b27be
Create folder if necessary before saving
Nov 2, 2018
1583471
Save transformation matrices in scientific notation
Nov 2, 2018
12c6e86
[ENH] Remove SIRFReg-specific BUILD_{PYTHON,MATLAB} variables.
ashgillman Nov 3, 2018
daed867
Merge pull request #229 from ashgillman/SIRFReg
rijobro Nov 3, 2018
5a6825d
[FIX] Build error with gcc 7.3.0
ashgillman Nov 4, 2018
2bfbd47
[FIX] Python import error, also applied similar patch to MATLAB.
ashgillman Nov 4, 2018
a9f5a30
Merge pull request #230 from ashgillman/SIRFReg
rijobro Nov 6, 2018
7d6bfcf
Merge remote-tracking branch 'CCP/master' into SIRFReg
Nov 12, 2018
afcaa32
Dont use " in matlab tests
Nov 16, 2018
adf83f2
Changes to be able to build on different systems
Nov 16, 2018
6fb4793
Merge pull request #232 from ashgillman/fix-missing-symbol
rijobro Nov 29, 2018
ea9386e
Remove dependence on SIRFRegMisc
Nov 29, 2018
4ff8d40
Template everything. matlab, python only float
Nov 30, 2018
e373ba8
Remove dependency on boost libs
Nov 30, 2018
fe2b981
Merge remote-tracking branch 'CCP/new_data_structure' into SIRFReg_ne…
Nov 30, 2018
5389944
Merge branch 'new_data_structure' into SIRFReg_new_data_structure
Nov 30, 2018
24b5192
Inherit NiftiImageData from sirf::ImageData
Dec 4, 2018
3899234
Get shared pointer from any type of transformation
Dec 3, 2018
e78db16
Merge remote-tracking branch 'CCP/master' into SIRFReg
Dec 5, 2018
d9fb128
changes to match update image structure
Dec 4, 2018
94a5532
use shared pointers where possible
Dec 5, 2018
f317e2a
Don't store deformations
Dec 5, 2018
f884b69
Construct NiftiImageData3D from ImageData (e.g., STIRImageData)
Dec 5, 2018
c01b98f
Superclass resample
Dec 5, 2018
7114fd7
Remove SIRFRegMisc
Dec 5, 2018
1aecbae
Remove deep_copy functionality
Dec 5, 2018
06a1054
No need for get_clone_sptr for transformations
Dec 5, 2018
67f7ccc
include directory sirf/common in base CMakeLists
Dec 5, 2018
245c3ac
Merge branch 'include_sirf_common' into SIRFReg
Dec 5, 2018
6f416b6
Get rid of boost::iequals
Dec 5, 2018
0ac4cc2
Tidy up CMakeLists
Dec 5, 2018
344138f
SIRFRegResample should return ImageData not NiftiImageData3D
Dec 6, 2018
356f2b5
Merge branch 'master' into SIRFReg
Dec 6, 2018
a1d234f
store shared pointers of affine transformations
Dec 6, 2018
f919b21
SIRFReg registration superclass
Dec 6, 2018
56c8956
Merge branch 'master' into SIRFReg
Dec 10, 2018
be8d9b4
data_handle -> sirf/iUtilities/DataHandle etc
Dec 10, 2018
b9aec01
Merge branch 'geometrical-info' into SIRFReg
Dec 10, 2018
4d01f1a
Set up geometrical info for NiftiImageData
Dec 11, 2018
bc2957e
new_data_container_sptr
Dec 11, 2018
0721dce
Merge branch 'master' into new_data_container_sptr
Dec 11, 2018
e79c55e
Only need new_data_container_sptr in DataContainer.h
Dec 11, 2018
7a0a984
use a fill method so that boost::shared_ptr could potentially be used
Dec 11, 2018
bb106a1
Revert "use a fill method so that boost::shared_ptr could potentially…
Dec 11, 2018
46b648f
Clear up whitespaces
Dec 11, 2018
308d554
Merge branch 'datacontainer_const_methods' into new_data_container_sptr
Dec 11, 2018
d9bea50
Merge branch 'geometrical-info' into SIRFReg
Dec 11, 2018
b5403be
Test new_data_container_sptr()
Dec 11, 2018
1d1586f
Merge branch 'new_data_container_sptr' into SIRFReg
Dec 11, 2018
457fae7
Merge branch 'ImageData_fill' into SIRFReg
Dec 11, 2018
0bd7c16
Mark all methods inherited from DataContainer const
Dec 11, 2018
6768901
same_image_data is virtual method, implemented in all derived NiftiIm…
Dec 11, 2018
c01eb97
Output of resample/registration is same as reference
Dec 11, 2018
7f42435
remove cstir_shared_ptr from printer
Dec 11, 2018
d30a2d5
Merge remote-tracking branch 'CCP/master' into SIRFReg
Dec 12, 2018
c84f669
Merge branch 'geometrical-info' into SIRFReg
Dec 12, 2018
a348797
Undo unintentional changes to files outside of Registration folder
Dec 13, 2018
2eeeaca
FindNiftyReg.cmake
Dec 13, 2018
b620b66
Move header files to include/sirf/cReg
Dec 13, 2018
9d06c34
Tidy CMake
Dec 13, 2018
c799d2e
Merge remote-tracking branch 'CCP/master' into SIRFReg
Dec 14, 2018
5d881de
Merge remote-tracking branch 'CCP/master' into SIRFReg
Dec 16, 2018
4196d76
Patch from kthielemans
Dec 16, 2018
a45a8d3
Edit for Travis
Dec 16, 2018
bed7e59
Changes for compilation on VM
Dec 16, 2018
c340d3c
Revert "Changes for compilation on VM"
KrisThielemans Dec 16, 2018
04a2229
Move ImageData.h from SIRF/common to sirf/common
KrisThielemans Dec 16, 2018
ce42aeb
use std::isnan
KrisThielemans Dec 16, 2018
aedf400
Python examples
Dec 17, 2018
fe3bcbb
set variables for na in example script to stop runtime errors in ubun…
ALEXJAZZ008008 Dec 18, 2018
b3ece29
Merge pull request #261 from ALEXJAZZ008008/SIRFReg
rijobro Dec 18, 2018
8c0c89d
Corrected python examples
Dec 17, 2018
af98060
Clone as sptr
Dec 18, 2018
f37ac3b
Get image type as string
Dec 18, 2018
705fbd1
pSIRFReg.NiftiImageData inherits from SIRF.ImageData
Dec 18, 2018
696ce89
Synergistic test
Dec 19, 2018
21b1eed
Create deep copies in python
Dec 19, 2018
57579f5
Initialise NiftiImageData3D from sirf::ImageData
Dec 19, 2018
a91730c
Resample: set images as ImageData instead of NiftiImageData3D
Dec 19, 2018
75f82a3
include Geometrical info from sirf/common
Dec 19, 2018
2adbdb7
Merge remote-tracking branch 'CCP/master' into SIRFReg
Dec 19, 2018
9754c57
Merge branch 'GadgeronImageWrap_order' into SIRFReg
Dec 19, 2018
6537ac5
set_up_geom_info - spacing for ismrmrd header
Dec 19, 2018
a3bc07a
Some corrections to set_up_geom_info()
Dec 20, 2018
dd6d377
Verbose output when using set_up_geom_info for MR ImageData
Dec 20, 2018
b873b3c
Save ISMRMRD header metadata to csv file
Dec 20, 2018
39c7e56
Fill in more geom_info for MR images
Dec 20, 2018
f89c9b8
Merge branch 'Write_method' into SIRFReg
Dec 20, 2018
6f9f885
Rename save_to_disk -> write
Dec 20, 2018
d8687e3
Revert "Create deep copies in python"
Dec 19, 2018
8508fce
Revert "Get image type as string"
Dec 20, 2018
cba86fc
Revert "Save ISMRMRD header metadata to csv file"
Dec 21, 2018
134f33a
Merge branch 'geometrical-info' into SIRFReg
Dec 21, 2018
833d680
Remove unnecessary _reg_maths includes
Dec 21, 2018
bb56dd3
Registration - set SIRF.ImageData
Dec 21, 2018
016dae7
Correct creation of NiftiImageData3D from SIRF.ImageData
Dec 21, 2018
8662066
Create registration executable for any algorithm and any image type
Dec 21, 2018
f98f26c
Examples for synergistic registration/resampling in python
Dec 21, 2018
2f260ee
Rename common->csirf
Dec 21, 2018
4ebc35e
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 3, 2019
a007d45
Merge branch 'geometrical-info' into SIRFReg
Jan 3, 2019
d49217e
Changes to match updates in master and GeometricalInfo
Jan 3, 2019
695ab24
Use correct write method
Jan 3, 2019
9d648ba
Merge branch 'geometrical-info' into SIRFReg
Jan 4, 2019
437ffa2
Print metadata without cloning image
Jan 4, 2019
2d847ef
Remove get_identity for 4x4 matrix. just use default constructor.
Jan 4, 2019
707ea88
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 7, 2019
7a06ea4
If no transformations applied, resample with identity matrix
Jan 7, 2019
3aa8c57
executable to check if two images match
Jan 7, 2019
6313d0a
Tiny change for geom info
Jan 7, 2019
1c17a4c
Fill in geom info for NiftiImageData
Jan 7, 2019
2e6aee0
Image comparison -> static function
Jan 7, 2019
db27adb
Correct templating
Jan 7, 2019
355e702
Covariant get_output avoids some casting
Jan 7, 2019
f9aa03f
Improve print nifti info
Jan 7, 2019
008d839
Remove superfluous constructor
Jan 8, 2019
87df509
Improve resampling
Jan 8, 2019
f227ad2
Synergistic resampling
Jan 8, 2019
5ab63a9
Only setup geom info if qform == 1
Jan 8, 2019
4f8b981
improve get_norm()
Jan 8, 2019
1daf49d
Merge branch 'stir_write_image_formats' into SIRFReg
Jan 8, 2019
7a6024c
Decrease verbose output
Jan 8, 2019
f96daab
test if we can do STIRImageData->NiftiImageData3D
Jan 8, 2019
48e46c3
When comparing images, resample if necessary
Jan 8, 2019
118f6b0
Print original datatype when dumping nifti info
Jan 8, 2019
8158c8a
Merge branch 'master' into SIRFReg
Jan 8, 2019
68c3671
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 9, 2019
a9a22e5
Warning if qform != 1 (instead of throwing error)
Jan 9, 2019
59e58c2
Same_image_data
Jan 9, 2019
1395d40
Use constructors as opposed to create_from_def/disp
Jan 9, 2019
962d18d
Remove unnecessary includes/forward declarations
Jan 9, 2019
6fb5f01
Consts in parser
Jan 9, 2019
9fb0743
unused include in transformation
Jan 9, 2019
80faf08
force integer division in some examples for Python 3
KrisThielemans Jan 9, 2019
0076868
Merge branch 'disable_python_matlab' into SIRFReg
Jan 10, 2019
ed34b17
change c++ filenames
Jan 10, 2019
31cc3bc
change c++ class names
Jan 10, 2019
7e1ca2c
Use pragma once
Jan 10, 2019
8703e93
cReg
Jan 10, 2019
4614276
cReg_p
Jan 10, 2019
5a5a277
test names
Jan 10, 2019
f8204bb
library SIRFReg->Reg
Jan 10, 2019
1fb9ec3
function names in cReg, cReg_p and corresponding python/matlab calls
Jan 10, 2019
7450a79
gmi_reg
Jan 10, 2019
481e417
cReg name comparisons
Jan 10, 2019
621f216
c-functions cReg_SIRFReg -> cReg
Jan 10, 2019
247b0f4
python/matlab classes SIRFReg->Registration
Jan 10, 2019
7e38b3d
remove sirfreg from comments
Jan 10, 2019
fc2f400
cREG_INCLUDE_DIR
Jan 10, 2019
85af047
Synergistic SIRFReg->Nifti
Jan 10, 2019
65a4116
libload msirfreg->reg
Jan 10, 2019
c0e48bc
Remove SIRFReg from c++ comments
Jan 10, 2019
92be38a
SIRFREG_ENABLE -> REG_ENABLE
Jan 10, 2019
6a671d9
import pSIRFReg->pReg
Jan 10, 2019
ad5f325
mSIRFReg -> mReg
Jan 10, 2019
8ee0efb
SIRFReg in comment
Jan 10, 2019
0106d18
remove SIRFReg from test_mReg
Jan 10, 2019
91cb3ba
msirfreg -> mreg
Jan 10, 2019
7b5b4d4
sirfreg_print_nifti_info -> sirf_print_nifti_info
Jan 10, 2019
b50d28d
creg_p pragma once
Jan 10, 2019
1865f87
#ifndef CSIRFREG ->CREG
Jan 10, 2019
dcbbd22
by default, use 1 time point for f3d
Jan 10, 2019
c2cff78
Only synergistic registration/resample executables
Jan 10, 2019
cb8c434
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 10, 2019
299cbea
Merge branch 'master' into SIRFReg
Jan 11, 2019
f9be9c8
Merge branch 'disable_python_matlab' into SIRFReg
Jan 11, 2019
15c5b1c
Merge branch 'disable_python_matlab' into SIRFReg
Jan 11, 2019
197c72d
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 11, 2019
0b27e2b
Use _sptr suffix
Jan 11, 2019
63be3b0
Merge branch 'geom_info' into SIRFReg
Jan 11, 2019
df53c2b
update copyrights
Jan 11, 2019
3c48c87
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 11, 2019
754b442
Merge branch 'geom_info' into SIRFReg
Jan 11, 2019
19ef0a2
Update doxygen
Jan 11, 2019
21483a9
get_typeid() -> get_typename()
Jan 11, 2019
9e78c2e
Merge branch 'master' into SIRFReg
Jan 11, 2019
13435c5
Set reference and floating masks in matlab and python
Jan 11, 2019
4933698
Build registration by default (needed for travis)
Jan 14, 2019
839de8a
Generate wrapper code depending on NiftyReg version
Jan 15, 2019
438bffb
Include memory for Travis
Jan 16, 2019
7a3b2a7
Find out if STIR has been built with ITK or not
Jan 16, 2019
b4a64ad
STIRConfig.cmake has been updated
Jan 17, 2019
ccacf04
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 17, 2019
9541db0
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 18, 2019
526a134
Remove duplicate method in Registration.m
Jan 18, 2019
e7969a7
Construct NiftiImageData types from array & geom info
Jan 18, 2019
3259a5e
in python, create NiftiImageData3D from any SIRFImageData
Jan 21, 2019
70950bb
Only find openmp if niftyreg was compiled with it.
Jan 24, 2019
17d5442
SIRFImageData python write abstract method missing filename argument
Jan 24, 2019
6130479
For some reason, can't use abstract write method in python
Jan 24, 2019
81d6c0f
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 24, 2019
09c9f96
Merge branch 'include-stir-first' into SIRFReg
Jan 24, 2019
4bdbc50
Use aliases in Matlab without copying folders
Jan 25, 2019
98700c8
Avoid eval
Jan 26, 2019
1139e60
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 28, 2019
51f0443
Merge branch 'aliases_in_matlab' into SIRFReg
Jan 28, 2019
1d0ea42
use set_up_engine
Jan 28, 2019
f503984
More verbose output if problem setting up geom info for MR
Jan 28, 2019
cc923e5
Fix some errors found by XCode
Jan 28, 2019
ae009c0
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 28, 2019
eff6a18
typo in set_up_MR
Jan 28, 2019
ba314a3
Merge branch 'aliases_in_matlab' into SIRFReg
Jan 28, 2019
446fd36
matlab alias for set_up_Reg
Jan 28, 2019
2ad078d
in registration, parameter file is optional
Jan 28, 2019
5e452ac
Remove superfluous cout
Jan 28, 2019
de0b362
NiftiImageData inherits from SIRF.ImageData
Jan 28, 2019
60e1e6e
Alias ImageData is NiftiImageData3D, not NiftiImageData
Jan 29, 2019
7c43c09
Construct tensor image from three SIRFImageData
Jan 29, 2019
707a43e
try catch with pReg test
Jan 29, 2019
746a89f
Matlab examples for registration/resampling
Jan 29, 2019
8dd577c
Rename registration/resample to sirf_* to avoid confusion with other …
Jan 29, 2019
e055b76
tidy target_link_libraries mreg
Jan 29, 2019
ef3b0ef
Minimise use of boost
Jan 29, 2019
b1b22c1
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 29, 2019
46a0105
Remove `same_image_data`
Jan 30, 2019
92af17c
mreg tests working directory in current built directory
Jan 30, 2019
95f5dd6
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 30, 2019
c9786dc
Synergistic testing
Jan 30, 2019
ff4fff6
set_up_reg docstring
Jan 30, 2019
2242e81
Merge branch 'aliases_in_matlab' into SIRFReg
Jan 30, 2019
bc36e44
Undo some unintentional changes
Jan 30, 2019
5f1d6e7
Merge remote-tracking branch 'CCP/master' into SIRFReg
Jan 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -266,3 +266,7 @@ coverage.xml
*_out.txt
# submodules which should be explicitly force-pushed
/data

# Dont track NiftyAladinSym.cpp/NiftyF3dSym.cpp as they are generated with CMake's configure_file
NiftyAladinSym.cpp
NiftyF3dSym.cpp
14 changes: 14 additions & 0 deletions CMakeLists.txt
Expand Up @@ -138,3 +138,17 @@ ADD_SUBDIRECTORY(src/common)
ADD_SUBDIRECTORY(src/xSTIR)
ADD_SUBDIRECTORY(src/xGadgetron)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/setup.py.cmake")

# Optional registration
option(REG_ENABLE "Build the SIRF registration package" ON)
if (REG_ENABLE)
ADD_SUBDIRECTORY(src/Registration)
endif()

# Synergistic code currently only works if STIR (with ITK), Gadgetron and Registration are built
if (REG_ENABLE AND STIR_REGISTRIES AND cGadgetron_LIBRARY_DIRS AND "${STIR_BUILT_WITH_ITK}")
MESSAGE(STATUS "Registration, Gadgetron and STIR (with ITK) have been built. Building synergistic code.")
ADD_SUBDIRECTORY(src/Synergistic)
else()
MESSAGE(STATUS "One or more of the following components are missing: Registration, Gadgetron and STIR (with ITK). Synergistic code will not be built.")
endif()
86 changes: 86 additions & 0 deletions cmake/FindNiftyReg.cmake
@@ -0,0 +1,86 @@
#========================================================================
# Author: Richard Brown
# Copyright 2016, 2017 University College London
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#=========================================================================

set(NiftyReg_FOUND 0)

SET(NiftyReg_Binary_DIR CACHE PATH "NiftyReg binary directory" )

# Ask for the binary and check
IF (NOT IS_DIRECTORY ${NiftyReg_Binary_DIR})
MESSAGE(FATAL_ERROR "Enter the binary directory of NiftyReg.")
ENDIF()

IF(EXISTS "${NiftyReg_Binary_DIR}/CMakeCache.txt")
LOAD_CACHE("${NiftyReg_Binary_DIR}" READ_WITH_PREFIX "nifty" "NiftyReg_SOURCE_DIR" "CMAKE_INSTALL_PREFIX" "USE_OPENMP")
endif()

SET(NiftyReg_Source_DIR ${niftyNiftyReg_SOURCE_DIR})
SET(NiftyReg_Install_DIR ${niftyCMAKE_INSTALL_PREFIX})
SET(NiftyReg_built_with_openmp ${niftyUSE_OPENMP})

# Include
INCLUDE_DIRECTORIES(${NiftyReg_Source_DIR}/reg-io/nrrd/NrrdIO) # ugly, but required for nrrdIO.h
INCLUDE_DIRECTORIES(${NiftyReg_Binary_DIR}) # ugly, but required for NrrdConfigure.h
INCLUDE_DIRECTORIES(${NiftyReg_Install_DIR}/include)

# Get the NiftyReg versions from its CMakeLists.txt
# This for older versions of NiftyReg
FILE(READ ${NiftyReg_Source_DIR}/CMakeLists.txt NiftyReg_CMakeLists)
STRING(REGEX MATCH "NiftyReg_VERSION_MAJOR ([0-9]*)" _ ${NiftyReg_CMakeLists} )
SET(NiftyReg_VERSION_MAJOR ${CMAKE_MATCH_1})
STRING(REGEX MATCH "NiftyReg_VERSION_MINOR ([0-9]*)" _ ${NiftyReg_CMakeLists} )
SET(NiftyReg_VERSION_MINOR ${CMAKE_MATCH_1})
STRING(REGEX MATCH "NiftyReg_VERSION_PATCH ([0-9]*)" _ ${NiftyReg_CMakeLists} )
SET(NiftyReg_VERSION_PATCH ${CMAKE_MATCH_1})
# This for more recent versions of NiftyReg
IF (NOT DEFINED NiftyReg_VERSION_MAJOR)
STRING(REGEX MATCH "NR_VERSION_MAJOR ([0-9]*)" _ ${NiftyReg_CMakeLists} )
SET(NiftyReg_VERSION_MAJOR ${CMAKE_MATCH_1})
STRING(REGEX MATCH "NR_VERSION_MINOR ([0-9]*)" _ ${NiftyReg_CMakeLists} )
SET(NiftyReg_VERSION_MINOR ${CMAKE_MATCH_1})
FILE(READ ${NiftyReg_Source_DIR}/niftyreg_build_version.txt NiftyReg_VERSION_PATCH)
ENDIF()
SET(NR_VERSION "${NiftyReg_VERSION_MAJOR}.${NiftyReg_VERSION_MINOR}.${NiftyReg_VERSION_PATCH}")
string(REGEX REPLACE "\n$" "" NR_VERSION "${NR_VERSION}")

SET(NiftyReg_requiredLibs
_reg_aladin
_reg_blockMatching
_reg_f3d
_reg_maths
_reg_ReadWriteImage
_reg_resampling
_reg_tools
reg_nifti
reg_png
_reg_femTrans
_reg_globalTrans
_reg_localTrans
_reg_measure
)

# Loop over each library, find it and add it.
# Do it twice to resolve linking errors depending on order
FOREACH(elem ${NiftyReg_requiredLibs} ${NiftyReg_requiredLibs})
FIND_LIBRARY(NiftyReg_${elem} ${elem} HINTS ${NiftyReg_Install_DIR}/lib)
MARK_AS_ADVANCED(NiftyReg_${elem})
SET(NiftyReg_Libs ${NiftyReg_Libs} ${NiftyReg_${elem}} )
ENDFOREACH(elem ${NiftyReg_requiredLibs})

# Success!
set(NiftyReg_FOUND 1)
2 changes: 2 additions & 0 deletions cmake/setup.py.cmake
Expand Up @@ -18,6 +18,8 @@ if(BUILD_PYTHON)
python_pkg_alias(pygadgetron "sirf.pygadgetron")
python_pkg_alias(pystir "sirf.pystir")
python_pkg_alias(pyiutilities "sirf.pyiutilities")
python_pkg_alias(pReg "sirf.Reg")
python_pkg_alias(pyreg "sirf.pyreg")
# convert to python CSV tuple for setup.py configure_file
string(REPLACE ";" "', '" PYTHON_SETUP_PKGS_CSV "${PYTHON_SETUP_PKGS}")
set(PYTHON_SETUP_PKGS_CSV "'${PYTHON_SETUP_PKGS_CSV}'")
Expand Down
55 changes: 55 additions & 0 deletions doxygen/doxygengroups.h
@@ -0,0 +1,55 @@
/*
CCP PETMR Synergistic Image Reconstruction Framework (SIRF)
Copyright 2019 University College London

This is software developed for the Collaborative Computational
Project in Positron Emission Tomography and Magnetic Resonance imaging
(http://www.ccppetmr.ac.uk/).

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

// define some doxygen groups and namespace
// This file does not contain any code

/*! \namespace sirf
\brief Namespace for the SIRF library (and some/most of its applications)

This namespace encompasses the whole
library. All classes, functions and symbols are in this namespace.
This has the effect that conflicts with any other library is
impossible (except if that library uses the same namespace...).
*/

/*!
\defgroup PET SIRF PET
\ingroup SIRF
All PET functionality of SIRF.
*/

/*!
\defgroup MR SIRF MR
\ingroup SIRF
All MR functionality of SIRF.
*/

/*!
\defgroup Registration SIRF registration
\ingroup SIRF
All registration/resampling functionality of SIRF.
*/

/*!
\defgroup Synergistic SIRF synergistic
\ingroup SIRF
All synergistic functionality of SIRF.
*/
173 changes: 173 additions & 0 deletions examples/Matlab/Registration/sirf_registration.m
@@ -0,0 +1,173 @@
function registration(varargin)
% Registration of SIRF images.
% --eng_ref <eng> engine for reference image [default: Reg]
% --eng_flo <eng> engine for floating image [default: Reg]
% --ref <file> reference image (default: test.nii.gz)
% --flo <file> floating image (default: test2.nii.gz)
% --par <file> parameter file (default: niftyreg_aladin.par)
% --algo <algo> registration algorithm [default: NiftyAladinSym]
% --rmask mask of reference image
% --fmask mask of floating image
% --warped <file> warped image filename [default: warped]
% --TM_forward forward transformation matrix (if rigid/affine)
% --TM_inverse inverse transformation matrix (if rigid/affine)
% --disp_fwd_4D 4D forward displacement field image
% --def_fwd_4D 4D forward deformation field image
% --disp_inv_4D 4D inverse displacement field image
% --def_inv_4D 4D inverse deformation field image

% CCP PETMR Synergistic Image Reconstruction Framework (SIRF).
% Copyright 2018 - 2019 University College London.
%
% This is software developed for the Collaborative Computational
% Project in Positron Emission Tomography and Magnetic Resonance imaging
% (http://www.ccppetmr.ac.uk/).
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
% http://www.apache.org/licenses/LICENSE-2.0
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.

%% Parse the input
i=1;
while i <= length(varargin)
if strcmp(varargin{i},'eng_ref')
eng_ref = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'eng_flo')
eng_flo = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'ref')
ref_file = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'flo')
flo_file = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'algo')
algo = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'warped')
warped = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'par')
par_file = get_arg(varargin,i,1);
i=i+2;

elseif strcmp(varargin{i},'rmask')
rmask = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'fmask')
fmask = get_arg(varargin,i,1);
i=i+2;

elseif strcmp(varargin{i},'TM_forward')
TM_forward = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'TM_inverse')
TM_inverse = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'disp_fwd_4D')
disp_fwd_4D = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'disp_inv_4D')
disp_inv_4D = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'def_fwd_4D')
def_fwd_4D = get_arg(varargin,i,1);
i=i+2;
elseif strcmp(varargin{i},'def_inv_4D')
def_inv_4D = get_arg(varargin,i,1);
i=i+2;
else
error(['Unknown argument: ' varargin{i} '. Use help(function) for help.']);
end
end

%% Default values
% If using default ref or flo images, need SIRF data
if ~exist('ref_file','var') || ~exist('flo_file','var')
SIRF_PATH = getenv('SIRF_PATH');
examples_path = fullfile(SIRF_PATH, '/data/examples/Registration');
end

if ~exist('eng_ref','var') eng_ref = 'Reg'; end
if ~exist('eng_flo','var') eng_flo = 'Reg'; end
if ~exist('ref_file','var') ref_file = fullfile(examples_path, 'test.nii.gz'); end
if ~exist('flo_file','var') flo_file = fullfile(examples_path, 'test2.nii.gz'); end
if ~exist('algo','var') algo = 'NiftyAladinSym'; end
if ~exist('warped','var') warped = 'warped'; end
if ~exist('par_file','var') par_file = fullfile(examples_path, 'paramFiles/niftyreg_aladin.par'); end

%% Registration
% Open reference and floating images
disp(['Engine for reference image: ', eng_ref])
disp(['Engine for floating image: ', eng_flo])
disp(['Reference image: ', ref_file])
disp(['Floating image: ', flo_file])

% Dynamically set up the engines required
set_up_Reg();
eng_ref = set_up_engine(eng_ref);
eng_flo = set_up_engine(eng_flo);

ref = eng_ref.ImageData(ref_file);
flo = eng_flo.ImageData(flo_file);

% Dynamically create resample algorithm
reg = eval(['mReg.' algo]);
reg.set_reference_image(ref)
reg.set_floating_image(flo)
if exist('par_file','var')
reg.set_parameter_file(par_file);
end
if exist('rmask_file','var')
rmask = eng_ref.ImageData(rmask_file);
reg.set_reference_mask(rmask)
end
if exist('fmask_file','var')
fmask = eng_ref.ImageData(fmask_file);
reg.set_floating_mask(fmask)
end

reg.process();

%% Output
reg.get_output().write(warped);

% TMs
if exist('TM_forward','var')
reg.get_transformation_matrix_forward().write(TM_forward)
end
if exist('TM_inverse','var')
reg.get_transformation_matrix_forward().write(TM_inverse)
end

% Disp fields
if exist('disp_fwd_4D','var')
reg.get_displacement_field_forward().write(disp_fwd_4D)
end
if exist('disp_inv_4D','var')
reg.get_displacement_field_inverse().write(disp_inv_4D)
end

% Def fields
if exist('def_fwd_4D','var')
reg.get_deformation_field_forward().write(def_fwd_4D)
end
if exist('disp_inv_4D','var')
reg.get_deformation_field_inverse().write(def_inv_4D)
end

end

function arg = get_arg(list,index,increment)
if (index+increment > length(list))
error(['Not sufficient arguments following: ' list{index}])
end
arg = list{index+increment};
end