### Build and Install NiftyReg Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Steps to clone, configure, build, and install NiftyReg using CMake. Includes setting environment variables and verifying the installation. ```bash git clone https://github.com/KCL-BMEIS/niftyreg.git niftyreg # Create build and install directories mkdir niftyreg_build niftyreg_install cd niftyreg_build # Configure with ccmake (interactive) or cmake (scripted) cmake -DCMAKE_INSTALL_PREFIX=../niftyreg_install \ -DBUILD_ALL_DEP=ON \ -DUSE_OPENMP=ON \ -DUSE_CUDA=OFF \ -DUSE_OPENCL=OFF \ -DBUILD_TESTING=OFF \ -DBUILD_SHARED_LIBS=OFF \ ../niftyreg # Build and install make -j$(nproc) make install # Add to PATH export NIFTYREG_INSTALL=../niftyreg_install export PATH=${PATH}:${NIFTYREG_INSTALL}/bin # Verify installation reg_f3d --version ``` -------------------------------- ### Install Executables and Libraries Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Installs the built NiftyReg executables and libraries to their respective runtime destinations. This ensures they are available after installation. ```cmake foreach(MODULE_NAME ${MODULE_LIST}) install(TARGETS ${MODULE_NAME} RUNTIME DESTINATION bin COMPONENT Runtime LIBRARY DESTINATION lib COMPONENT Runtime ARCHIVE DESTINATION lib COMPONENT Runtime ) endforeach(MODULE_NAME) ``` -------------------------------- ### Build and Install NIfTI Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/niftilib/CMakeLists.txt Builds the nifti1_io library and installs it to specified runtime, library, and archive destinations. It also links against the 'znz' library. ```cmake set(NAME reg_nifti) add_library(${NAME} nifti1_io.c) target_link_libraries(${NAME} znz) install(TARGETS ${NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) ``` -------------------------------- ### Install NiftyReg Executables and Libraries Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/nrrd/CMakeLists.txt Installs the NiftyReg executable, libraries, and header files to their respective directories. This prepares the build for deployment or further use. ```cmake install(TARGETS reg_nrrd RUNTIME DESTINATION bin COMPONENT Development LIBRARY DESTINATION lib COMPONENT Development ARCHIVE DESTINATION lib COMPONENT Development ) install(FILES NrrdIO/NrrdIO.h ${CMAKE_BINARY_DIR}/NrrdConfigure.h DESTINATION include COMPONENT Development) ``` -------------------------------- ### Build and Install reg_png Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/png/CMakeLists.txt Builds the 'reg_png' library from 'reg_png.cpp' and links it with the PNG library and '_reg_tools'. Installation rules are defined for runtime, library, and archive components. ```cmake add_library(reg_png reg_png.cpp) target_link_libraries(reg_png ${PNG_LIBRARY} _reg_tools) install(TARGETS reg_png RUNTIME DESTINATION bin COMPONENT Development LIBRARY DESTINATION lib COMPONENT Development ARCHIVE DESTINATION lib COMPONENT Development ) ``` -------------------------------- ### Install Helper Scripts Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Installs helper shell scripts used for parameter configuration and running NiftyReg jobs. These are placed in the bin directory. ```cmake install(PROGRAMS groupwise_niftyreg_params.sh DESTINATION bin COMPONENT Runtime) install(PROGRAMS groupwise_niftyreg_run.sh DESTINATION bin COMPONENT Runtime) ``` -------------------------------- ### Build and Install NiftyReg on Linux/macOS Source: https://github.com/kcl-bmeis/niftyreg/wiki/install Compile the NiftyReg source code using make and then install it to the specified prefix. Update your profile to include the NiftyReg binary directory in your PATH. ```bash make make install ``` ```bash export NIFTYREG_INSTALL=niftyreg_install PATH=${PATH}:${NIFTYREG_INSTALL}/bin export PATH ``` -------------------------------- ### Build and Install PNG Static Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/png/CMakeLists.txt Builds the PNG library as a static library and links it with the 'z' library. It also defines installation rules for the library and its headers. ```cmake add_library(png STATIC ${png_srcs}) target_link_libraries(png z) install(TARGETS png LIBRARY DESTINATION lib COMPONENT Development ARCHIVE DESTINATION lib COMPONENT Development ) install(FILES ${png_hdrs} ${CMAKE_BINARY_DIR}/pnglibconf.h DESTINATION include COMPONENT Development) ``` -------------------------------- ### Example Affine Transformation Matrix Output Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt An example of the 4x4 affine transformation matrix output by reg_aladin, representing spatial transformations. ```text # Example affine output file (outputAffine.txt) — 4x4 matrix: # 0.999 -0.043 0.012 2.341 # 0.042 0.998 0.048 -1.205 # -0.014 -0.047 0.998 3.712 ``` -------------------------------- ### Install NrrdIO Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/nrrd/CMakeLists.txt Installs the compiled reg_NrrdIO library to the appropriate destination directory. This makes the library available for linking by other targets. ```cmake install(TARGETS reg_NrrdIO LIBRARY DESTINATION lib COMPONENT Development ARCHIVE DESTINATION lib COMPONENT Development ) target_link_libraries(reg_NrrdIO z) ``` -------------------------------- ### Verify NiftyReg Installation Source: https://github.com/kcl-bmeis/niftyreg/wiki/install After setting up the environment variables, open a new terminal to verify that NiftyReg commands are accessible. ```bash reg_f3d -h ``` -------------------------------- ### Install znz Library Components Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/znzlib/CMakeLists.txt Configures the installation of the znz library targets, specifying runtime, library, and archive destinations for the 'Development' component. This ensures the library is correctly placed after building. ```cmake install(TARGETS znz RUNTIME DESTINATION bin COMPONENT Development LIBRARY DESTINATION lib COMPONENT Development ARCHIVE DESTINATION lib COMPONENT Development ) ``` -------------------------------- ### Add and Install zlib Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/zlib/CMakeLists.txt This snippet conditionally adds the zlib library if it's not found. It compiles the library from its source files and defines installation rules for different component types. ```cmake if(NOT ZLIB_FOUND) add_library(z adler32.c compress.c crc32.c deflate.c gzclose.c gzlib.c gzread.c gzwrite.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c) install(TARGETS z RUNTIME DESTINATION bin COMPONENT Development LIBRARY DESTINATION lib COMPONENT Development ARCHIVE DESTINATION lib COMPONENT Development ) set(ZLIB_LIBRARY "z") endif(NOT ZLIB_FOUND) ``` -------------------------------- ### Build ALADIN Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Defines the ALADIN library, links it with necessary NiftyReg sub-libraries and external libraries (OpenCL, CUDA), and sets up installation rules. ```cmake add_library(_reg_aladin ${NIFTYREG_LIBRARY_TYPE} _reg_aladin.cpp _reg_aladin_sym.cpp) target_link_libraries(_reg_aladin _reg_blockMatching _reg_compute _reg_kernels _reg_localTrans _reg_resampling _reg_globalTrans _reg_tools _reg_ReadWriteImage ${NR_OPENCL_LIBRARIES} ${NR_CUDA_LIBRARIES} ) install(TARGETS _reg_aladin RUNTIME DESTINATION lib LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_aladin") ``` -------------------------------- ### Configure NiftyReg Build on Linux/macOS Source: https://github.com/kcl-bmeis/niftyreg/wiki/install Configure the NiftyReg build using CMake in the build directory. Set the CMAKE_INSTALL_PREFIX to specify the installation location. ```bash mkdir niftyreg_build cd niftyreg_build ccmake ``` -------------------------------- ### Build CPU Maths Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Defines and installs the CPU maths library. This library is a dependency for other modules. ```cmake add_library(_reg_maths ${NIFTYREG_LIBRARY_TYPE} cpu/Maths.cpp ) install(TARGETS _reg_maths RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_maths") ``` -------------------------------- ### Build CPU Tools Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Defines and installs the CPU tools library, linking against the maths and nifti libraries. This is a core dependency for transformations and measurements. ```cmake add_library(_reg_tools ${NIFTYREG_LIBRARY_TYPE} cpu/_reg_tools.cpp) target_link_libraries(_reg_tools _reg_maths reg_nifti ) install(TARGETS _reg_tools RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_tools") ``` -------------------------------- ### Build Global Transformation Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Defines and installs the global transformation library, which depends on the tools library. Used for global registration steps. ```cmake add_library(_reg_globalTrans ${NIFTYREG_LIBRARY_TYPE} cpu/_reg_globalTrans.cpp) target_link_libraries(_reg_globalTrans _reg_tools) install(TARGETS _reg_globalTrans RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_globalTrans") ``` -------------------------------- ### Build F3D Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Defines the F3D library, specifying its source files, linking it with required NiftyReg sub-libraries and external libraries (OpenCL, CUDA), and configuring installation. ```cmake set(_reg_f3d_files _reg_base.cpp _reg_f3d.cpp _reg_f3d2.cpp ) set(_reg_f3d_libraries _reg_blockMatching _reg_compute _reg_kernels _reg_localTrans _reg_globalTrans _reg_resampling _reg_measure _reg_tools _reg_ReadWriteImage ${NR_OPENCL_LIBRARIES} ${NR_CUDA_LIBRARIES} ) add_library(_reg_f3d ${NIFTYREG_LIBRARY_TYPE} ${_reg_f3d_files}) target_link_libraries(_reg_f3d ${_reg_f3d_libraries}) install(TARGETS _reg_f3d RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_f3d") ``` -------------------------------- ### Build Block Matching Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Defines and installs the block matching library, which depends on the global transformation library. Used for specific registration algorithms. ```cmake add_library(_reg_blockMatching ${NIFTYREG_LIBRARY_TYPE} cpu/_reg_blockMatching.cpp) target_link_libraries(_reg_blockMatching _reg_globalTrans) install(TARGETS _reg_blockMatching RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_blockMatching") ``` -------------------------------- ### Module List Definition Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Defines a list of all NiftyReg modules that will be built as executables. This list is used later for installation. ```cmake set(MODULE_LIST reg_average reg_tools reg_resample reg_measure reg_transform reg_jacobian reg_aladin reg_f3d ) ``` -------------------------------- ### Build Resampling Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Defines and installs the image resampling library, which depends on the global transformation library. Essential for applying transformations. ```cmake add_library(_reg_resampling ${NIFTYREG_LIBRARY_TYPE} cpu/_reg_resampling.cpp) target_link_libraries(_reg_resampling _reg_globalTrans) install(TARGETS _reg_resampling RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_resampling") ``` -------------------------------- ### Add znz Library and Link Dependencies Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/znzlib/CMakeLists.txt Defines the znz library using znzlib.c and links it against the 'z' library. This is a standard CMake setup for libraries. ```cmake add_library(znz znzlib.c) target_link_libraries(znz z) ``` -------------------------------- ### Build Compute Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Defines and installs the compute library, which aggregates various computation-related source files and links against the measurement library. This library is central to the registration process. ```cmake add_library(_reg_compute ${NIFTYREG_LIBRARY_TYPE} Compute.cpp AladinContent.cpp Content.cpp DefContent.cpp F3dContent.cpp Optimiser.cpp Platform.cpp MeasureCreator.cpp ) target_link_libraries(_reg_compute _reg_measure) install(TARGETS _reg_compute RUNTIME DESTINATION lib LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_compute") ``` -------------------------------- ### Build CPU Kernels Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Defines and installs the CPU kernels library, which includes various CPU-specific implementations for registration tasks. It depends on the block matching library. ```cmake add_library(_reg_kernels ${NIFTYREG_LIBRARY_TYPE} cpu/CpuKernelFactory.cpp cpu/CpuAffineDeformationFieldKernel.cpp cpu/CpuBlockMatchingKernel.cpp cpu/CpuConvolutionKernel.cpp cpu/CpuLtsKernel.cpp cpu/CpuResampleImageKernel.cpp ) target_link_libraries(_reg_kernels _reg_blockMatching ) install(TARGETS _reg_kernels RUNTIME DESTINATION lib LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_kernels") ``` -------------------------------- ### Build Local Transformation Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Defines and installs the local transformation library, which includes spline basis and regularization. It depends on global transformation and tools libraries. ```cmake add_library(_reg_localTrans ${NIFTYREG_LIBRARY_TYPE} cpu/_reg_splineBasis.cpp cpu/_reg_localTrans.cpp cpu/_reg_localTrans_regul.cpp cpu/_reg_localTrans_jac.cpp ) target_link_libraries(_reg_localTrans _reg_tools _reg_globalTrans ) install(TARGETS _reg_localTrans RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_localTrans") ``` -------------------------------- ### Landmark-Constrained Registration with reg_f3d Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Enables landmark-constrained registration by providing a text file with corresponding landmark points in reference and floating images. This helps to guide the registration process. ```bash reg_f3d \ -ref reference.nii.gz \ -flo floating.nii.gz \ -land 0.01 landmarks.txt \ -cpp cpp_landmark.nii.gz \ -res warped_landmark.nii.gz ``` ```text # landmarks.txt format (3D): refX refY refZ floX floY floZ (one per line) # 100.5 120.3 55.0 98.2 119.8 53.4 # 200.1 80.0 60.0 197.5 78.1 58.9 ``` -------------------------------- ### Set Number of Levels for Optimization Source: https://github.com/kcl-bmeis/niftyreg/wiki/executable Use the -lp flag to specify the number of levels to use for optimization after image pyramids are created. The default value is set by -ln. For example, -ln 3 -lp 2 skips the full resolution level. ```bash reg_aladin -ref -flo -ln 3 -lp 2 ``` -------------------------------- ### RegAladin Help Option Source: https://github.com/kcl-bmeis/niftyreg/wiki/executable Use the -help flag to list all available options for the reg_aladin executable without running any registration. ```bash reg_aladin -help ``` -------------------------------- ### GPU Accelerated Registration with reg_aladin Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Uses centre-of-mass initialization and enables GPU acceleration via CUDA for registration. Requires a CUDA-enabled build. ```bash # Use centre-of-mass initialisation and GPU acceleration (CUDA build) reg_aladin \ -ref reference.nii.gz \ -flo floating.nii.gz \ -comi \ -platf 1 \ -gpuid 0 \ -aff affine_gpu.txt \ -voff ``` -------------------------------- ### Initialize and Refine Affine Registration with reg_aladin Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Initializes registration from an existing affine matrix and disables symmetry for refinement. Outputs a refined affine transformation matrix. ```bash # Initialise from existing affine matrix, disable symmetry reg_aladin \ -ref reference.nii.gz \ -flo floating.nii.gz \ -inaff initial_affine.txt \ -noSym \ -aff refined_affine.txt ``` -------------------------------- ### Define Executable and Link Libraries (reg_aladin) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Defines the 'reg_aladin' executable and links it with the '_reg_aladin' library. This is for the ALADIN registration algorithm. ```cmake add_executable(reg_aladin reg_aladin.cpp) target_link_libraries(reg_aladin _reg_aladin) ``` -------------------------------- ### Configure NiftyReg Build with CMake Source: https://github.com/kcl-bmeis/niftyreg/wiki/install Use this command to set CMake variables for building NiftyReg, including enabling CUDA, OpenMP, and OpenCL, and specifying compiler paths. This is particularly useful for complex build environments like macOS where CUDA and OpenMP require different compilers. ```bash ccmake -DCUDA_HOST_COMPILER=/usr/bin/clang \ -DCMAKE_C_COMPILER= -DCMAKE_CXX_COMPILER= \ -DUSE_CUDA=ON -DUSE_OPENMP=ON -DUSE_OPENCL=ON ``` -------------------------------- ### GPU-Accelerated Registration with reg_f3d Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Utilizes GPU acceleration for faster registration by specifying the platform and GPU device ID. Requires a compatible GPU and NiftyReg build. ```bash reg_f3d \ -ref reference.nii.gz \ -flo floating.nii.gz \ -platf 1 \ -gpuid 0 \ -cpp cpp_gpu.nii.gz \ -res result_gpu.nii.gz ``` -------------------------------- ### Complete Rigid to Non-linear Registration Pipeline Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt A bash script demonstrating a multi-stage registration pipeline using NiftyReg executables: reg_aladin for affine, reg_f3d for non-linear, reg_resample for applying transformations, reg_measure for quality assessment, reg_jacobian for deformation analysis, and reg_transform for conversion. ```bash #!/bin/bash # Complete rigid -> affine -> non-linear registration pipeline REF=reference.nii.gz FLO=floating.nii.gz # Step 1: Rigid + affine registration reg_aladin \ -ref ${REF} \ -flo ${FLO} \ -aff affine.txt \ -res warped_affine.nii.gz \ -ln 3 -lp 3 \ -omp 8 # Step 2: Non-linear registration initialised with affine result reg_f3d \ -ref ${REF} \ -flo ${FLO} \ -aff affine.txt \ -cpp cpp.nii.gz \ -res warped_nonlinear.nii.gz \ -sx 5.0 -be 0.005 \ -ln 3 -lp 3 \ -omp 8 # Step 3: Apply transformation to a label map (nearest-neighbour) reg_resample \ -ref ${REF} \ -flo labels.nii.gz \ -trans cpp.nii.gz \ -res warped_labels.nii.gz \ -inter 0 # Step 4: Check registration quality reg_measure \ -ref ${REF} \ -flo warped_nonlinear.nii.gz \ -nmi -ncc # Step 5: Analyse local deformation reg_jacobian \ -trans cpp.nii.gz \ -ref ${REF} \ -jac jac_det.nii.gz \ -jacL log_jac_det.nii.gz # Step 6: Convert CPP grid to deformation field for external tools reg_transform \ -ref ${REF} \ -def cpp.nii.gz deformation_field.nii.gz ``` -------------------------------- ### Full reg_aladin Configuration Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Comprehensive usage of reg_aladin for affine registration, specifying output paths, masks, and various registration parameters. ```bash # Full affine registration with explicit output paths and masking reg_aladin \ -ref reference.nii.gz \ -flo floating.nii.gz \ -aff affine_transform.txt \ -res warped_floating.nii.gz \ -rmask reference_brain_mask.nii.gz \ -fmask floating_brain_mask.nii.gz \ -ln 3 \ -lp 3 \ -maxit 10 \ -pv 50 \ -pi 50 \ -smooR 1.0 \ -smooF 1.0 ``` -------------------------------- ### Define Executable and Link Libraries (reg_tools) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Defines the 'reg_tools' executable and links it with necessary NiftyReg libraries. This executable provides various image registration utility functions. ```cmake add_executable(reg_tools reg_tools.cpp) target_link_libraries(reg_tools _reg_measure _reg_blockMatching _reg_resampling _reg_maths _reg_tools _reg_ReadWriteImage) ``` -------------------------------- ### Inspect NIfTI Transformation Header with Python Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Use nibabel in Python to load a NIfTI transformation file and print its header information, including intent code, name, and parameters. ```python import nibabel as nib img = nib.load('control_point_grid.nii.gz') hdr = img.header print('intent_code:', hdr['intent_code']) # 1007 = NIFTI_INTENT_VECTOR print('intent_name:', hdr['intent_name']) # b'NREG_TRANS' print('intent_p1 :', hdr['intent_p1']) # 2 = CUB_SPLINE_GRID print('intent_p2 :', hdr['intent_p2']) # scaling-squaring steps print('shape :', img.shape) # (nx, ny, nz, 1, 3) ``` -------------------------------- ### Rigid Registration Only Source: https://github.com/kcl-bmeis/niftyreg/wiki/executable Use the -rigOnly flag to perform rigid registration only. By default, an initial rigid step is used before an affine transformation is optimized. ```bash reg_aladin -ref -flo -rigOnly ``` -------------------------------- ### Build and Link Test Executables Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-test/CMakeLists.txt Iterates through the list of defined test executables, creates each executable from its corresponding C++ source file, links necessary libraries including Catch2 for testing, and discovers tests. ```cmake foreach(EXEC ${EXEC_LIST}) add_executable(${EXEC} ${EXEC}.cpp) target_link_libraries(${EXEC} PRIVATE Catch2::Catch2WithMain _reg_aladin _reg_f3d) catch_discover_tests(${EXEC}) endforeach(EXEC) ``` -------------------------------- ### Initialize with Affine Transformation Source: https://github.com/kcl-bmeis/niftyreg/wiki/executable Use the -inaff flag to specify an affine transformation to initialize the current optimization. By default, the geometrical centers of the images are aligned. ```bash reg_aladin -ref -flo -inaff ``` -------------------------------- ### Create Affine Matrix from Parameters Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Creates a new affine transformation matrix from specified rotation, translation, scale, and shear parameters. The parameters are applied in a specific order (rotation, translation, scale, shear). ```bash reg_transform \ -makeAff 5.0 0.0 0.0 2.0 -1.5 0.5 1.0 1.0 1.0 0.0 0.0 0.0 \ my_affine.txt ``` -------------------------------- ### Basic RegAladin Command Source: https://github.com/kcl-bmeis/niftyreg/wiki/executable This is the minimum requirement to run pairwise rigid or affine registration. It specifies the reference and floating images. ```bash reg_aladin -ref -flo ``` -------------------------------- ### Define Executable and Link Libraries (reg_resample) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Defines the 'reg_resample' executable and links it with relevant NiftyReg libraries. This is used for resampling images based on transformation fields. ```cmake add_executable(reg_resample reg_resample.cpp) target_link_libraries(reg_resample _reg_resampling _reg_localTrans _reg_tools _reg_globalTrans _reg_ReadWriteImage) ``` -------------------------------- ### Clone NiftyReg Repository Source: https://github.com/kcl-bmeis/niftyreg/wiki/install Use Git to download the NiftyReg source code. Choose the HTTPS or SSH URL based on your Git configuration. ```bash git clone https://github.com/KCL-BMEIS/niftyreg.git niftyreg ``` ```bash git clone git@github.com:KCL-BMEIS/niftyreg.git niftyreg ``` -------------------------------- ### Compile NiftyReg Core Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/nrrd/CMakeLists.txt Compiles the main NiftyReg library (reg_nrrd) using its source file and linking against helper tools and the NrrdIO library. ```cmake add_library(reg_nrrd reg_nrrd.cpp) target_link_libraries(reg_nrrd _reg_tools reg_NrrdIO) ``` -------------------------------- ### Display GPU Information with reg_gpuinfo Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Use reg_gpuinfo to list available GPU platforms and devices when NiftyReg is compiled with CUDA or OpenCL support. This information is useful for selecting specific GPUs for computation. ```bash # List all available GPU platforms and device IDs reg_gpuinfo # Example output: # Platform 0: NVIDIA CUDA # Device 0: NVIDIA A100-SXM4-40GB (compute 8.0, 40536 MB) # Device 1: NVIDIA GeForce RTX 3090 (compute 8.6, 24268 MB) # Platform 2: OpenCL # Device 0: Intel(R) UHD Graphics 630 ``` ```bash # Use identified GPU with reg_aladin or reg_f3d reg_aladin -ref ref.nii.gz -flo flo.nii.gz -platf 1 -gpuid 0 -aff out.txt reg_f3d -ref ref.nii.gz -flo flo.nii.gz -platf 1 -gpuid 1 -cpp cpp.nii.gz ``` -------------------------------- ### Define Executable and Link Libraries (reg_average) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Defines the 'reg_average' executable and links it with required NiftyReg libraries. This is used for averaging images. ```cmake add_executable(reg_average reg_average.cpp) target_link_libraries(reg_average _reg_resampling _reg_globalTrans _reg_localTrans _reg_maths _reg_tools _reg_ReadWriteImage) ``` -------------------------------- ### Define Executable and Link Libraries (reg_transform) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Defines the 'reg_transform' executable and links it with necessary NiftyReg libraries. This application is used for applying or manipulating transformation fields. ```cmake add_executable(reg_transform reg_transform.cpp) target_link_libraries(reg_transform _reg_resampling _reg_localTrans _reg_tools _reg_globalTrans _reg_maths _reg_ReadWriteImage) ``` -------------------------------- ### Specify Output Affine Transformation Source: https://github.com/kcl-bmeis/niftyreg/wiki/executable Specify a custom filename for the output affine transformation matrix using the -aff flag. The default is 'outputAffine.txt'. ```bash reg_aladin -ref -flo -aff ``` -------------------------------- ### Convert FSL FLIRT Affine to NiftyReg Format Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Converts an affine transformation matrix from FSL FLIRT's .mat format to NiftyReg's text format. Requires reference and floating images to define the coordinate system. ```bash reg_transform -flirtAff2NR flirt_affine.mat reference.nii.gz floating.nii.gz niftyreg_affine.txt ``` -------------------------------- ### Rigid-Only Registration with reg_aladin Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Configures reg_aladin to perform rigid-only registration (6 DoF), skipping the affine step and outputting a rigid transformation matrix. ```bash # Rigid-only registration (6 DoF), skip affine step reg_aladin \ -ref reference.nii.gz \ -flo floating.nii.gz \ -rigOnly \ -aff rigid_transform.txt \ -res warped_rigid.nii.gz ``` -------------------------------- ### Define Executable and Link Libraries (reg_f3d) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Defines the 'reg_f3d' executable and links it with the '_reg_f3d' library. This is likely for a specific 3D registration method. ```cmake add_executable(reg_f3d reg_f3d.cpp) target_link_libraries(reg_f3d _reg_f3d) ``` -------------------------------- ### Define Executable and Link Libraries (reg_measure) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Defines the 'reg_measure' executable and links it with required NiftyReg libraries. This tool is used for measuring image properties or registration accuracy. ```cmake add_executable(reg_measure reg_measure.cpp) target_link_libraries(reg_measure _reg_resampling _reg_tools _reg_measure _reg_ReadWriteImage) ``` -------------------------------- ### Multi-Channel Registration with reg_f3d Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Handles multi-channel or multi-modal registration by allowing different similarity metrics (e.g., LNCC, SSD) to be specified for different image components or time points. ```bash reg_f3d \ -ref reference.nii.gz \ -flo floating.nii.gz \ --lncc 2.0 \ --ssd \ -cpp cpp_multichannel.nii.gz \ -res result_multichannel.nii.gz ``` -------------------------------- ### Define Executable and Link Libraries (reg_jacobian) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Defines the 'reg_jacobian' executable and links it with relevant NiftyReg libraries. This tool is used for computing Jacobian determinants of transformation fields. ```cmake add_executable(reg_jacobian reg_jacobian.cpp) target_link_libraries(reg_jacobian _reg_resampling _reg_localTrans _reg_tools _reg_globalTrans _reg_ReadWriteImage) ``` -------------------------------- ### Configure PNG Library Configuration File Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/png/CMakeLists.txt Generates the configuration file 'pnglibconf.h' for the PNG library from a prebuilt template. This file is essential for customizing PNG library behavior. ```cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lpng/pnglibconf.h.prebuilt ${CMAKE_BINARY_DIR}/pnglibconf.h) include_directories(${CMAKE_BINARY_DIR}) ``` -------------------------------- ### Define PNG Library Headers and Sources Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/png/CMakeLists.txt Defines lists of header and source files for the PNG library. These lists are used to build the static PNG library. ```cmake set(png_hdrs lpng/png.h lpng/pngconf.h lpng/pngdebug.h lpng/pnginfo.h lpng/pngpriv.h lpng/pngstruct.h ) set(png_srcs lpng/png.c lpng/pngerror.c lpng/pngget.c lpng/pngmem.c lpng/pngpread.c lpng/pngread.c lpng/pngrio.c lpng/pngrtran.c lpng/pngrutil.c lpng/pngset.c lpng/pngtrans.c lpng/pngwio.c lpng/pngwrite.c lpng/pngwtran.c lpng/pngwutil.c ) ``` -------------------------------- ### Define Measurement Files and Library Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-lib/CMakeLists.txt Collects various measurement source files and builds them into the _reg_measure library. This library depends on the tools and resampling libraries. ```cmake set(measure_files cpu/_reg_nmi.cpp cpu/_reg_ssd.cpp cpu/_reg_kld.cpp cpu/_reg_lncc.cpp cpu/_reg_dti.cpp cpu/_reg_mind.cpp ) add_library(_reg_measure ${NIFTYREG_LIBRARY_TYPE} ${measure_files}) target_link_libraries(_reg_measure _reg_tools _reg_resampling) install(TARGETS _reg_measure RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_measure") ``` -------------------------------- ### Apply Transformation to Landmarks Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Applies a given transformation to a set of landmark points. The input landmarks are in mm coordinates, and the output landmarks are transformed accordingly. ```bash reg_transform \ -land affine_transform.txt landmarks_ref.txt landmarks_warped.txt ``` -------------------------------- ### Set Number of Levels for Pyramidal Approach Source: https://github.com/kcl-bmeis/niftyreg/wiki/executable Use the -ln flag to specify the number of levels for the pyramidal coarse-to-fine approach. The default value is 3. ```bash reg_aladin -ref -flo -ln ``` -------------------------------- ### Basic Non-Linear Registration with reg_f3d Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Performs basic non-linear registration using a Free-Form Deformation model. Requires reference and floating images, and an affine transformation for initialization. ```bash reg_f3d \ -ref reference.nii.gz \ -flo floating.nii.gz \ -aff affine_transform.txt \ -cpp control_point_grid.nii.gz \ -res warped_nonlinear.nii.gz ``` -------------------------------- ### Find Math Library (libm) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/png/CMakeLists.txt Locates the math library 'libm' on non-Windows systems. If not found, it prints a status message indicating disabled floating-point support. ```cmake if(NOT WIN32) find_library(M_LIBRARY NAMES m PATHS /usr/lib /usr/local/lib ) if(NOT M_LIBRARY) message(STATUS "math library 'libm' not found - floating point support disabled") endif(NOT M_LIBRARY) else(NOT WIN32) # the m library is not needed on windows set(M_LIBRARY "") endif(NOT WIN32) ``` -------------------------------- ### Define QNANHIBIT Preprocessor Macro Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/nrrd/CMakeLists.txt Adds a preprocessor definition for TEEM based on the QNANHIBIT variable. This ensures that the build reflects the correct NaN handling for the target platform. ```cmake if(QNANHIBIT) add_definitions(-DTEEM_QNANHIBIT=1) else(QNANHIBIT) add_definitions(-DTEEM_QNANHIBIT=0) endif(QNANHIBIT) ``` -------------------------------- ### Configure NIfTI NaN Support Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/niftilib/CMakeLists.txt Enables NaN support for NIfTI images by defining a preprocessor macro. This option is controlled by the USE_NII_NAN CMake variable. ```cmake option(USE_NII_NAN "To enable NaN support with nifti images" ON) mark_as_advanced(FORCE USE_NII_NAN) if(USE_NII_NAN) add_definitions(-DUSE_NII_NAN) endif(USE_NII_NAN) ``` -------------------------------- ### Define Build Options for TEEM Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/nrrd/CMakeLists.txt Sets preprocessor definitions for the TEEM library, controlling features like build mode, DIO, and ZLIB support. These are essential for cross-platform compatibility and feature enablement. ```cmake add_definitions(-DTEEM_BUILD=1) add_definitions(-DTEEM_DIO=0) add_definitions(-DTEEM_ZLIB=1) ``` -------------------------------- ### Apply Affine Transformation with Cubic Interpolation Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Applies an affine transformation to a floating image using cubic interpolation and saves the result. This is a common use case for basic registration refinement. ```bash reg_resample \ -ref reference.nii.gz \ -flo floating.nii.gz \ -trans affine_transform.txt \ -res warped_affine.nii.gz \ -inter 3 ``` -------------------------------- ### Define NiftyReg Test Executables Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-test/CMakeLists.txt This snippet defines a list of test executables for NiftyReg. Each executable is added to the EXEC_LIST variable. ```cmake set(EXEC_LIST reg_test_getDeformationField ${EXEC_LIST}) set(EXEC_LIST reg_test_composeField ${EXEC_LIST}) set(EXEC_LIST reg_test_imageGradient ${EXEC_LIST}) set(EXEC_LIST reg_test_interpolation ${EXEC_LIST}) set(EXEC_LIST reg_test_lncc ${EXEC_LIST}) set(EXEC_LIST reg_test_nmi ${EXEC_LIST}) set(EXEC_LIST reg_test_nmi_gradient ${EXEC_LIST}) set(EXEC_LIST reg_test_normaliseGradient ${EXEC_LIST}) set(EXEC_LIST reg_test_regr_getDeformationField ${EXEC_LIST}) set(EXEC_LIST reg_test_voxelCentricToNodeCentric ${EXEC_LIST}) ``` -------------------------------- ### Configure Code Coverage (Unix) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-test/CMakeLists.txt Sets up C/C++ compiler flags for debug builds to enable coverage testing using LCOV and genhtml. It also defines custom targets for gathering coverage data and cleaning counters. ```cmake if(WITH_COVERAGE) if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") message(FATAL_ERROR "Coverage testing aborted. Reconfigure with -DCMAKE_BUILD_TYPE=Debug") endif() set(BUILD_ALL_DEP ON CACHE BOOL "All the dependencies are build" FORCE) set(CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE TRUE) if(UNIX) # Check prerequisites find_program(LCOV lcov REQUIRED) find_program(GENHTML genhtml REQUIRED) if(NOT LCOV) message(FATAL_ERROR "lcov not found! Aborting...") endif() if(NOT GENHTML) message(FATAL_ERROR "genhtml not found! Aborting...") endif() # Set the flags for coverage set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -coverage" CACHE STRING "Force the debug CXX flags for the coverage test" FORCE) set(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} CACHE STRING "Force the debug C flags for the coverage test" FORCE) # Add the coverage target add_custom_target(coverage # Gather data only for the reg-lib directory COMMAND ${LCOV} --directory . --capture --output-file coverage.info --include '*/reg-lib/*' # Generate report COMMAND ${GENHTML} --demangle-cpp -o coverage coverage.info WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) # Add the clean target add_custom_target(clean_coverage COMMAND ${LCOV} --directory . --zerocounters WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) else(UNIX) # Check prerequisites find_program(OPENCPPCOVERAGE OpenCppCoverage REQUIRED) if(NOT OPENCPPCOVERAGE) message(FATAL_ERROR "OpenCppCoverage not found! Aborting...") endif() # Only include the reg-lib directory as coverage source string(REPLACE "/" "\\" COVERAGE_SOURCE "${CMAKE_SOURCE_DIR}/reg-lib") # Add the coverage target add_custom_target(coverage # Gather data only for the reg-lib directory COMMAND ${OPENCPPCOVERAGE} --sources=${COVERAGE_SOURCE} --cover_children -- ctest -C Debug WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) endif(UNIX) endif(WITH_COVERAGE) ``` -------------------------------- ### Direct Affine Optimization Source: https://github.com/kcl-bmeis/niftyreg/wiki/executable Use the -affDirect flag to directly optimize a 12 DoF affine transformation. By default, a rigid step is optimized prior to running an affine transformation. ```bash reg_aladin -ref -flo -affDirect ``` -------------------------------- ### reg_tools Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Provides a collection of image processing utilities including arithmetic operations, smoothing, thresholding, resampling, and format conversions. ```APIDOC ## reg_tools — Image Utility Operations `reg_tools` provides a collection of image processing utilities: arithmetic operations, smoothing, thresholding, resampling, and format conversions. ### Usage Examples: # Convert image to float precision reg_tools -in image.nii.gz -out image_float.nii.gz -float # Arithmetic operations with another image or scalar reg_tools -in image.nii.gz -out result.nii.gz -add other_image.nii.gz reg_tools -in image.nii.gz -out result.nii.gz -sub 100.0 reg_tools -in image.nii.gz -out result.nii.gz -mul mask.nii.gz reg_tools -in image.nii.gz -out result.nii.gz -div 2.0 # Gaussian smoothing (σ in mm along x, y, z axes) reg_tools -in image.nii.gz -out smoothed.nii.gz -smoG 2.0 2.0 2.0 # Cubic B-spline smoothing reg_tools -in image.nii.gz -out smoothed_spline.nii.gz -smoS 2.0 2.0 2.0 # Label image smoothing (Gaussian) reg_tools -in labels.nii.gz -out smoothed_labels.nii.gz -smoL 1.0 1.0 1.0 # Downsample image by factor of 2 reg_tools -in image.nii.gz -out downsampled.nii.gz -down # Binarise image (non-zero -> 1) reg_tools -in image.nii.gz -out binary_mask.nii.gz -bin # Threshold image (val < thr -> 0, else 1) reg_tools -in image.nii.gz -out thresholded.nii.gz -thr 500.0 # Apply NaN mask (voxels outside mask set to NaN) reg_tools -in image.nii.gz -out masked.nii.gz -nan brain_mask.nii.gz # Make image isotropic reg_tools -in anisotropic.nii.gz -out isotropic.nii.gz -iso # Resample to specified resolution (in mm) reg_tools -in image.nii.gz -out resampled_1mm.nii.gz -chgres 1.0 1.0 1.0 # Remove NaN and Inf values (replace with specified value) reg_tools -in noisy.nii.gz -out clean.nii.gz -rmNanInf 0.0 # Compute RMS difference between two images reg_tools -in image1.nii.gz -rms image2.nii.gz # Generate MIND descriptor image reg_tools -in image.nii.gz -out mind_descriptor.nii.gz -mind # Visualise active blocks for reg_aladin (block variance map) reg_tools -in image.nii.gz -out active_blocks.nii.gz -testActiveBlocks ``` -------------------------------- ### Minimal reg_aladin Usage Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Performs basic rigid or affine registration between a floating and reference image. Outputs an affine transformation matrix and the warped floating image. ```bash # Minimal usage: align floating.nii to reference.nii reg_aladin -ref reference.nii.gz -flo floating.nii.gz ``` -------------------------------- ### Conditional GPU Info Executable (reg_gpuinfo) Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-apps/CMakeLists.txt Conditionally adds the 'reg_gpuinfo' executable if CUDA or OpenCL is enabled. It links against the appropriate GPU info library. ```cmake if(USE_CUDA OR USE_OPENCL) set(gpuinfo_libraries "") if(USE_CUDA) set(gpuinfo_libraries ${gpuinfo_libraries} _reg_cudainfo) endif(USE_CUDA) if(USE_OPENCL) set(gpuinfo_libraries ${gpuinfo_libraries} _reg_openclinfo) endif(USE_OPENCL) add_executable(reg_gpuinfo reg_gpuinfo.cpp) target_link_libraries(reg_gpuinfo ${gpuinfo_libraries}) set(MODULE_LIST ${MODULE_LIST} reg_gpuinfo) endif(USE_CUDA OR USE_OPENCL) ``` -------------------------------- ### reg_gpuinfo Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Displays information about available GPU devices when the package is compiled with CUDA or OpenCL support. ```APIDOC ## reg_gpuinfo — GPU Platform Information `reg_gpuinfo` displays information about available GPU devices when the package is compiled with CUDA or OpenCL support. ### Usage Examples: # List all available GPU platforms and device IDs reg_gpuinfo # Example output: # Platform 0: NVIDIA CUDA # Device 0: NVIDIA A100-SXM4-40GB (compute 8.0, 40536 MB) # Device 1: NVIDIA GeForce RTX 3090 (compute 8.6, 24268 MB) # Platform 2: OpenCL # Device 0: Intel(R) UHD Graphics 630 # Use identified GPU with reg_aladin or reg_f3d reg_aladin -ref ref.nii.gz -flo flo.nii.gz -platf 1 -gpuid 0 -aff out.txt reg_f3d -ref ref.nii.gz -flo flo.nii.gz -platf 1 -gpuid 1 -cpp cpp.nii.gz ``` -------------------------------- ### Compute Jacobian Determinant and Log-Determinant Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Computes both the Jacobian determinant and its logarithm from a control point grid. The '-omp 8' flag enables multi-threading for faster computation. ```bash reg_jacobian \ -trans cpp_output.nii.gz \ -ref reference.nii.gz \ -jac jac_det.nii.gz \ -jacL log_jac_det.nii.gz \ -omp 8 ``` -------------------------------- ### Configure NrrdIO Header Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-io/nrrd/CMakeLists.txt Configures the NrrdConfigure.h header file using a template. This ensures that build-specific settings are correctly embedded for the NrrdIO library. ```cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/NrrdIO/NrrdConfigure.h.in ${CMAKE_BINARY_DIR}/NrrdConfigure.h) include_directories(${CMAKE_BINARY_DIR}) ``` -------------------------------- ### Define Test Executables Source: https://github.com/kcl-bmeis/niftyreg/blob/master/reg-test/CMakeLists.txt Defines a list of executable targets that are part of the NiftyReg test suite. ```cmake set(EXEC_LIST reg_test_affineDeformationField) set(EXEC_LIST reg_test_be ${EXEC_LIST}) set(EXEC_LIST reg_test_blockMatching ${EXEC_LIST}) set(EXEC_LIST reg_test_conjugateGradient ${EXEC_LIST}) ``` -------------------------------- ### Fine-tuned Non-Linear Registration with reg_f3d Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Advanced non-linear registration allowing fine-tuning of control-point spacing, regularisation weights (bending energy, linear elasticity), and iteration parameters. Supports various similarity metrics like NMI. ```bash reg_f3d \ -ref reference.nii.gz \ -flo floating.nii.gz \ -aff affine_transform.txt \ -cpp cpp_output.nii.gz \ -res result_output.nii.gz \ -sx 5.0 \ -sy 5.0 \ -sz 5.0 \ -be 0.005 \ -le 0.01 \ -jl 0.0 \ -ln 3 \ -lp 3 \ -maxit 150 \ --rbn 64 \ --fbn 64 ``` -------------------------------- ### PSF-Aware Resampling to Lower Resolution Source: https://context7.com/kcl-bmeis/niftyreg/llms.txt Performs PSF-aware resampling to a lower resolution image. The '-psf' flag enables PSF computation, and '-psf_alg 0' specifies the algorithm. ```bash reg_resample \ -ref lowres_reference.nii.gz \ -flo highres_floating.nii.gz \ -trans affine_transform.txt \ -res warped_lowres.nii.gz \ -psf \ -psf_alg 0 ```