GithubHelp home page GithubHelp logo

kcl-bmeis / niftyreg Goto Github PK

View Code? Open in Web Editor NEW
126.0 126.0 41.0 26.95 MB

This project contains command line tools to perform rigid, affine and non-linear registration of nifti or analyse images as well as utilities

License: BSD 3-Clause "New" or "Revised" License

CMake 1.06% Shell 0.43% C++ 43.37% C 48.39% Perl 0.10% Cuda 6.66%
medical-image-registration

niftyreg's People

Contributors

ammelbourne avatar casperdcl avatar davecash75 avatar imalone avatar jamie-mcclelland avatar jhipwell avatar kristhielemans avatar mattclarkson avatar mjorgecardoso avatar mmodat avatar zomboir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

niftyreg's Issues

reg_average not running in -avg mode

In gitlab by @imalone on Jan 25, 2017, 15:42

Running the diffusion pipeline with the updated niftyreg (1.5.13) is crashing at the averaging step, it looks like the command line to run is being generated with reg_average at the start. Nipype is attempting to run this:

/var/drc/scratch1/malone/nipype_deps_2017_01_17/bin/reg_average --cmd_file /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/ave_ims_b0/reg_average_cmd

And reg_average_cmd is this:

reg_average /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/ave_ims_b0/avg_out.nii.gz -avg /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/split_dwis/dwi_0000.nii.gz /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/split_dwis/dwi_0017.nii.gz /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/split_dwis/dwi_0033.nii.gz /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/split_dwis/dwi_0049.nii.gz /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/split_dwis/dwi_0068.nii.gz /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/split_dwis/dwi_0085.nii.gz /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/split_dwis/dwi_0101.nii.gz /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/split_dwis/dwi_0117.nii.gz /var/drc/research/emilyphd/yoad/modified_pipeline_jan2017A/01-003/dmri_workflow/split_dwis/dwi_0136.nii.gz

If I try that command directly it fails with:

[NiftyReg WARNING] Function: reg_io_checkFileFormat
[NiftyReg WARNING] No filename extension provided - the Nifti library is used by default
** ERROR (nifti_image_read): failed to find header file for ''
Segmentation fault (core dumped)

Apparently crashing at reg_average.cpp:710

       avg_output_image = reg_io_ReadImageFile(referenceImageName);

Because referenceImageName only gets set correctly if it was NULL, but isn't initialised to start with. Will push a fix.

Getting Error while running Groupwise_niftyreg_run.sh in ubuntu 16.04

yubraj@Liverpool:~/niftyreg_install/bin$ more exp.sh
#!/bin/sh

############################################################################
###################### PARAMETERS THAT CAN BE CHANGED ######################
############################################################################

Array that contains the input images to create the atlas

export IMG_INPUT=(ls ~/AAD/*.nii.gz)
export IMG_INPUT_MASK= # leave empty to not use floating masks

template image to use to initialise the atlas creation

export TEMPLATE=(ls ~/temp/MNI152T1.nii.gz)
export TEMPLATE_MASK= # leave empty to not use a reference mask

folder where the result images will be saved

export RES_FOLDER=pwd/groupwise_result

argument to use for the affine (reg_aladin)

export AFFINE_args="-omp 4"

argument to use for the non-rigid registration (reg_f3d)

export NRR_args="-omp 4"

number of affine loop to perform - Note that the first step is always rigid

export AFF_IT_NUM=5

number of non-rigid loop to perform

export NRR_IT_NUM=10

grid engine arguments

export QSUB_CMD="qsub -l h_rt=05:00:00 -l tmem=0.9G -l h_vmem=0.9G -l vf=0.9G -l s_stack=10240 -j y -S /bin/csh -b y -cwd
-V -R y -pe smp 4"
############################################################################
yubraj@Liverpool:/niftyreg_install/bin$ sh ./groupwise_niftyreg_run.sh ./params.sh
./groupwise_niftyreg_run.sh: 23: .: Can't open ./params.sh
yubraj@Liverpool:
/niftyreg_install/bin$ sh ./groupwise_niftyreg_run.sh ./exp.sh
./groupwise_niftyreg_run.sh: 7: ./exp.sh: Syntax error: "(" unexpected
yubraj@Liverpool:/niftyreg_install/bin$ sh groupwise_niftyreg_run.sh exp.sh
groupwise_niftyreg_run.sh: 7: /home/yubraj/niftyreg_install/bin/exp.sh: Syntax error: "(" unexpected
yubraj@Liverpool:
/niftyreg_install/bin$

And, is there any way to run reg_aladin in the loop, because it's tedious to load image every time.

CLIFlagUpdates

In gitlab by @rsparks on Sep 19, 2017, 09:57

Updating the CLI xml flags to ensure compatibility with niftyReg v 1.5.44

Updating tags with versions

Hi Mark,
Would it be possible to have the versions tagged here? https://github.com/KCL-BMEIS/niftyreg/releases
I'm asking our cluster manager to install NiftyReg, and they've installed the "latest version", 1.3.9. I've now asked them to use master, but it will be easier to manage in the future if they've been tagged.
Thanks very much,
Ash

sliding-regions

In gitlab by @jmcclelland on Aug 21, 2017, 15:26

FFD registration that allows for two sliding regions, defined in the source image
a distance map (in the source image) must be provided, giving the distance to the
sliding interface for all voxels, with voxels in region1 having negative values,
and voxels in region2 having positive values
The deformation in each region is represented by a separate B-spline transformation
and a penalty term is used to penalise gaps/overlaps between the two regions.

CUDA ERROR: too many resources requested for launch

Hi,

When I run this command with CUDA version reg_aladin -ref a.nii -flo b.nii -res c.nii -aff ref_template_flo_new_image_affine_matrix.txt -platf 1 -gpuid 0

I got this error:
NiftyReg CUDA ERROR] file '/home/qinwang/nifty/niftyreg-git/reg-lib/cuda/resampleKernel.cu' in line 443 : too many resources requested for launch. Grid [316x1x1] | Block [512x1x1] [NiftyReg] Exit here. File: /home/qinwang/nifty/niftyreg-git/reg-lib/cuda/resampleKernel.cu:443

Then I set CUDA_NVCC_FLAGS: --maxregcount=32 in the ccmake configure still got this error.
Thanks.

How to use scipy map_coordinates and generated warp deformation field to get the transformed image?

When I am using map_coordinates and generated warp deformation field to get the transformed image, I find the tranformed image and that by NiftyReg are different.

Could you please provide the implementation and the main framework of reg_resample -def? Could you please provide an example using map_coordinates to warp the image?

I have converted the control points (CPP) field to deformation field. But I still fail to convert the same transformed image.

Thank you!

lut_spline

In gitlab by @mmodat on Jan 16, 2017, 09:38

Re-instauring the use use of coefficient look-up-table when the spline spacing is equal to 5 voxels

bugs in reg_tools and reg_transform

In gitlab by @jmcclelland on Aug 2, 2017, 16:46

reg_tools is not adding 2 images together.
when inverting a NR transform with reg_transform, the result is (correctly) saved as a deformation field, but the intent code in the nifti header is still set to control point grid.
also, the description in the nifti header is not being set when composing or inverting transforms with reg_transform

reg_resample hang when resampling tensors

In gitlab by @imalone on Feb 15, 2017, 13:51

@mmodat I've found that reg_resample hangs when it encounters a non-invertible tensor as Eigen's assumptions for .log aren't satisfied and it can't converge. Adding a check on the determinant fixes the cases I've run across so far.

index e0802d1..3c87881 100644
--- a/reg-lib/cpu/_reg_maths_eigen.cpp
+++ b/reg-lib/cpu/_reg_maths_eigen.cpp
@@ -282,6 +282,7 @@ void reg_mat33_logm(mat33 *in_tensor)
 
    // Convert to Eigen format
    bool all_zeros = true;
+   double det = 0;
    for (sm = 0; sm < 3; sm++){
       for (sn = 0; sn < 3; sn++){
          float val=in_tensor->m[sm][sn];
@@ -290,7 +291,14 @@ void reg_mat33_logm(mat33 *in_tensor)
          tensor(sm, sn) = static_cast<double>(val);
       }
    }
-   if(all_zeros==true){
+   // Actually R case requires invertible and no negative real ev,
+   // but the only observed case so far was non-invertible.
+   // determinant is not a perfect check for invertibility and
+   // identity with zero not great either, but the alternative
+   // is a general eigensolver and the logarithm function should
+   // succeed unless convergence just isn't happening.
+   det = tensor.determinant();
+   if(all_zeros==true || det == 0){
       reg_mat33_to_nan(in_tensor);
       return;
    }

groupwise_niftyreg_run.sh fails after first rigid registration iteration

In gitlab by @svalette on Nov 15, 2017, 11:18

Hi,

the groupwise_niftyreg_run.sh script fails on my box. It correctly computes the first rigid registration iteration for all volumes, but computing the first average image fails. The volume list is:

[valette@desk reg-apps]$ ls ~/volumes
vol1.nii.gz  vol2.nii.gz  vol3.nii.gz

the config file is:

[valette@desk reg-apps]$ more params.sh 
#!/bin/sh

############################################################################
###################### PARAMETERS THAT CAN BE CHANGED ######################
############################################################################
# Array that contains the input images to create the atlas
export IMG_INPUT=(`ls ~/volumes/*.nii.gz`)
export IMG_INPUT_MASK= # leave empty to not use floating masks

# template image to use to initialise the atlas creation
export TEMPLATE=`echo ~/volumes/vol1.nii.gz`
export TEMPLATE_MASK= # leave empty to not use a reference mask

# folder where the result images will be saved
export RES_FOLDER=`pwd`/groupwise_result

# argument to use for the affine (reg_aladin)
export AFFINE_args="-omp 4"
# argument to use for the non-rigid registration (reg_f3d)
export NRR_args="-omp 4"

# number of affine loop to perform - Note that the first step is always rigid
export AFF_IT_NUM=5
# number of non-rigid loop to perform
export NRR_IT_NUM=10

# grid engine arguments
export QSUB_CMD="qsub -l h_rt=05:00:00 -l tmem=0.9G -l h_vmem=0.9G -l vf=0.9G -l s_stack=10240  -j y -S /bin/csh -b y -cwd -V -R y -pe smp 4"
############################################################################

and the output of the script is as bellow:

[valette@desk reg-apps]$ sh ./groupwise_niftyreg_run.sh ./params.sh 

************************************************************
>>> There are 3 input images to groupwise register <<<
>>> The template image to initialise the registration is /home/valette/volumes/vol1.nii.gz <<<
************************************************************

The output image folder (/home/valette/git/niftyreg/reg-apps/groupwise_result) does not exist
The output image folder (/home/valette/git/niftyreg/reg-apps/groupwise_result) has been created
** ERROR (nifti_image_write_hdr_img2): cannot open output file '/dev/null.nii'
** ERROR (nifti_image_write_hdr_img2): cannot open output file '/dev/null.nii'
** ERROR (nifti_image_write_hdr_img2): cannot open output file '/dev/null.nii'
[NiftyReg WARNING] Function: reg_io_checkFileFormat
[NiftyReg WARNING] No filename extension provided - the Nifti library is used by default
** ERROR (nifti_image_read): failed to find header file for '/home/valette/git/niftyreg/reg-apps/groupwise_result/aff_1/aff_mat_vol1_it1.txt'
./groupwise_niftyreg_run.sh : ligne 309 : 28166 Segmentation fault      (core dumped)reg_average ${RES_FOLDER}/aff_${CUR_IT}/average_affine_it_${CUR_IT}.nii.gz -demean1 ${averageImage} ${list_average}
Error when creating 						/home/valette/git/niftyreg/reg-apps/groupwise_result/aff_1/average_affine_it_1.nii.gz

after further debugging, it seems that the script stops when launching the reg_average program, with this command line:

reg_average /home/valette/git/niftyreg/reg-apps/groupwise_result/aff_1/average_affine_it_1.nii.gz -demean1 /home/valette/volumes/vol1.nii.gz /home/valette/git/niftyreg/reg-apps/groupwise_result/aff_1/aff_mat_vol1_it1.txt /home/valette/volumes/vol1.nii.gz /home/valette/git/niftyreg/reg-apps/groupwise_result/aff_1/aff_mat_vol2_it1.txt /home/valette/volumes/vol2.nii.gz /home/valette/git/niftyreg/reg-apps/groupwise_result/aff_1/aff_mat_vol3_it1.txt /home/valette/volumes/vol3.nii.gz

it seems that reg_average is confused and is trying to read /home/valette/git/niftyreg/reg-apps/groupwise_result/aff_1/aff_mat_vol1_it1.txt as an image file, but the file contains a rigid transform.

modifying linear energy weight between levels

In gitlab by @jmcclelland on Sep 3, 2017, 11:53

in reg_f3d_sym the linear energy weight is modified in InitialiseCurrentLevel method to account for using a refined CPG, in a similar way to how the bending energy weight is modified (but by a factor or 3 instead of 16)
however, in reg_f3d only the bending energy weight is modified, the linear energy weight is not modified

I think the linear energy weight should probably also be modified in reg_f3d as well - but not sure

Unit test error

In gitlab by @mmodat on Oct 13, 2016, 12:56

91 - reg_test_measure_SSD_2D (Failed)
93 - reg_test_measure_SSD_3D (Failed)
95 - reg_test_imageGradient_imageGradientDF_2D (Failed)
96 - reg_test_imageGradient_imageGradientDF_3D (Failed)
99 - reg_test_blockMatching_mrf_3D (Failed)
102 - reg_test_coherence_mrf_3D (SEGFAULT)

reg_aladin v1.3.9 and v1.5.58 discrepancy

In gitlab by @rmharbr on Apr 17, 2018, 16:34

Using the executable reg_aladin, I notice a large discrepancy between v1.3.9 & v.1.5.58 (most recent pull) in the registration of some head images. As I'm dealing with head images, I'm using the -rigOnly flag.

I'm experiencing this problem for multiple PET frames (longitudinal), as well as multimodal registration between an MR and PET image.

Strangely, v1.3.9 seems to perform the registration correctly (the output image is nicely superposed on the reference image in Slicer). With v1.5.58, although the output image moves closer to the reference image, it is still poorly aligned. The required rigid transformation is largely a translation in the z-direction, so it is easy to qualitatively say which one is better.

Is there anything I'm missing when upgrading the version of NiftyReg? I know that by default symmetric aladin is now used, but whether I use symmetric or non-symmetric, the old version seems to give better results.

Warped image intensity range larger than floating image intensity range with default reg_aladin parameter (linear resampling)

I am doing a rigid registration of an ADC map to a T2 MRI using reg_aladin. The only optional parameter I set is -rigOnly. The source code for reg_aladin appears to show the default resampling scheme is linear. However, my original ADC map has a minimum intensity of 0 while my registered ADC map has a minimum intensity of -154. My understanding of linear resampling is that the registered ADC map should not have intensities outside the range of the original ADC map.

Compiling with CUDA - unsupported GNU version

I am trying to compile NiftyReg with CUDA on Ubuntu 18.04.

I got this error after running make:

/usr/local/cuda-9.0/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
 #error -- unsupported GNU version! gcc versions later than 6 are not supported!

Is there a way to specify a different version of the compiler to be used in CMake? Maybe some of these?

 CMAKE_CXX_COMPILER               /usr/bin/c++                                                                                                         
 CMAKE_CXX_COMPILER_AR            /usr/bin/gcc-ar-7                                                                                                    
 CMAKE_CXX_COMPILER_RANLIB        /usr/bin/gcc-ranlib-7                                                                                                                                                                                           
 CMAKE_C_COMPILER                 /usr/bin/cc                                                                                                          
 CMAKE_C_COMPILER_AR              /usr/bin/gcc-ar-7                                                                                                    
 CMAKE_C_COMPILER_RANLIB          /usr/bin/gcc-ranlib-7     

This is the complete output:

 …/niftyreg/build   master ?  make                                                                                         ✔  13:24 Dur  12:12:48
Scanning dependencies of target z
[  1%] Building C object reg-io/zlib/CMakeFiles/z.dir/adler32.c.o
[  2%] Building C object reg-io/zlib/CMakeFiles/z.dir/compress.c.o
[  3%] Building C object reg-io/zlib/CMakeFiles/z.dir/crc32.c.o
[  4%] Building C object reg-io/zlib/CMakeFiles/z.dir/gzio.c.o
[  5%] Building C object reg-io/zlib/CMakeFiles/z.dir/uncompr.c.o
[  5%] Building C object reg-io/zlib/CMakeFiles/z.dir/deflate.c.o
[  6%] Building C object reg-io/zlib/CMakeFiles/z.dir/trees.c.o
[  7%] Building C object reg-io/zlib/CMakeFiles/z.dir/zutil.c.o
[  8%] Building C object reg-io/zlib/CMakeFiles/z.dir/inflate.c.o
[  9%] Building C object reg-io/zlib/CMakeFiles/z.dir/infback.c.o
[ 10%] Building C object reg-io/zlib/CMakeFiles/z.dir/inftrees.c.o
[ 11%] Building C object reg-io/zlib/CMakeFiles/z.dir/inffast.c.o
[ 12%] Linking C static library libz.a
[ 12%] Built target z
Scanning dependencies of target png
[ 13%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/png.c.o
[ 14%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngerror.c.o
[ 15%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngget.c.o
[ 16%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngmem.c.o
[ 17%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngpread.c.o
[ 18%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngread.c.o
[ 19%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngrio.c.o
[ 19%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngrtran.c.o
[ 20%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngrutil.c.o
[ 21%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngset.c.o
[ 22%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngtrans.c.o
[ 23%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngwio.c.o
[ 24%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngwrite.c.o
[ 25%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngwtran.c.o
[ 25%] Building C object reg-io/png/CMakeFiles/png.dir/lpng1510/pngwutil.c.o
[ 26%] Linking C static library libpng.a
[ 26%] Built target png
Scanning dependencies of target _reg_maths
[ 27%] Building CXX object reg-lib/CMakeFiles/_reg_maths.dir/cpu/_reg_maths.cpp.o
[ 28%] Building CXX object reg-lib/CMakeFiles/_reg_maths.dir/cpu/_reg_maths_eigen.cpp.o
[ 29%] Linking CXX static library lib_reg_maths.a
[ 29%] Built target _reg_maths
Scanning dependencies of target reg_nifti
[ 30%] Building C object reg-io/nifti/CMakeFiles/reg_nifti.dir/nifti1_io.c.o
[ 31%] Building C object reg-io/nifti/CMakeFiles/reg_nifti.dir/znzlib.c.o
[ 31%] Linking C static library libreg_nifti.a
[ 31%] Built target reg_nifti
Scanning dependencies of target _reg_tools
[ 32%] Building CXX object reg-lib/CMakeFiles/_reg_tools.dir/cpu/_reg_tools.cpp.o
/home/fernando/git/niftyreg/reg-lib/cpu/_reg_tools.cpp: In instantiation of ‘void reg_intensityRescale_core(nifti_image*, int, float, float) [with DTYPE = unsigned char]’:
/home/fernando/git/niftyreg/reg-lib/cpu/_reg_tools.cpp:203:80:   required from here
/home/fernando/git/niftyreg/reg-lib/cpu/_reg_tools.cpp:133:17: warning: large integer implicitly truncated to unsigned type [-Woverflow]
       currentMax=-(DTYPE)std::numeric_limits<short>::max();
       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fernando/git/niftyreg/reg-lib/cpu/_reg_tools.cpp:141:17: warning: large integer implicitly truncated to unsigned type [-Woverflow]
       currentMax=-(DTYPE)std::numeric_limits<int>::max();
       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fernando/git/niftyreg/reg-lib/cpu/_reg_tools.cpp: In instantiation of ‘void reg_intensityRescale_core(nifti_image*, int, float, float) [with DTYPE = short unsigned int]’:
/home/fernando/git/niftyreg/reg-lib/cpu/_reg_tools.cpp:209:81:   required from here
/home/fernando/git/niftyreg/reg-lib/cpu/_reg_tools.cpp:141:17: warning: large integer implicitly truncated to unsigned type [-Woverflow]
[ 32%] Linking CXX static library lib_reg_tools.a
[ 32%] Built target _reg_tools
Scanning dependencies of target reg_png
[ 33%] Building CXX object reg-io/png/CMakeFiles/reg_png.dir/reg_png.cpp.o
[ 34%] Building CXX object reg-io/png/CMakeFiles/reg_png.dir/readpng.cpp.o
[ 35%] Linking CXX static library libreg_png.a
[ 35%] Built target reg_png
Scanning dependencies of target _reg_ReadWriteImage
[ 35%] Building CXX object reg-io/CMakeFiles/_reg_ReadWriteImage.dir/_reg_ReadWriteImage.cpp.o
[ 36%] Building CXX object reg-io/CMakeFiles/_reg_ReadWriteImage.dir/_reg_ReadWriteMatrix.cpp.o
[ 37%] Building CXX object reg-io/CMakeFiles/_reg_ReadWriteImage.dir/_reg_ReadWriteBinary.cpp.o
/home/fernando/git/niftyreg/reg-io/_reg_ReadWriteBinary.cpp: In function ‘void readFloatBinaryArray(const char*, int, float*)’:
/home/fernando/git/niftyreg/reg-io/_reg_ReadWriteBinary.cpp:8:14: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
         fread((void*)(&currentValue), sizeof(currentValue), 1, infile);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fernando/git/niftyreg/reg-io/_reg_ReadWriteBinary.cpp: In function ‘void readIntBinaryArray(const char*, int, int*)’:
/home/fernando/git/niftyreg/reg-io/_reg_ReadWriteBinary.cpp:18:14: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
         fread((void*)(&currentValue), sizeof(currentValue), 1, infile);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 38%] Building CXX object reg-io/CMakeFiles/_reg_ReadWriteImage.dir/_reg_stringFormat.cpp.o
[ 39%] Linking CXX static library lib_reg_ReadWriteImage.a
[ 39%] Built target _reg_ReadWriteImage
[ 40%] Building NVCC (Device) object reg-lib/cuda/CMakeFiles/_reg_common_cuda.dir/_reg_common_cuda_generated__reg_common_cuda.cu.o
In file included from /usr/local/cuda-9.0/include/host_config.h:50:0,
                 from /usr/local/cuda-9.0/include/cuda_runtime.h:78,
                 from <command-line>:0:
/usr/local/cuda-9.0/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
 #error -- unsupported GNU version! gcc versions later than 6 are not supported!
  ^~~~~
CMake Error at _reg_common_cuda_generated__reg_common_cuda.cu.o.Release.cmake:219 (message):
  Error generating
  /home/fernando/git/niftyreg/build/reg-lib/cuda/CMakeFiles/_reg_common_cuda.dir//./_reg_common_cuda_generated__reg_common_cuda.cu.o


reg-lib/cuda/CMakeFiles/_reg_common_cuda.dir/build.make:63: recipe for target 'reg-lib/cuda/CMakeFiles/_reg_common_cuda.dir/_reg_common_cuda_generated__reg_common_cuda.cu.o' failed
make[2]: *** [reg-lib/cuda/CMakeFiles/_reg_common_cuda.dir/_reg_common_cuda_generated__reg_common_cuda.cu.o] Error 1
CMakeFiles/Makefile2:876: recipe for target 'reg-lib/cuda/CMakeFiles/_reg_common_cuda.dir/all' failed
make[1]: *** [reg-lib/cuda/CMakeFiles/_reg_common_cuda.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

Parameters

I am using nifty_reg-1.3.9 on linux and I was following the Segmentation Propagation tutorial described here http://cmictig.cs.ucl.ac.uk/wiki/index.php/NiftyReg_Segmentation_Propagation_Tutorial
In step 3 (non-linear transformation parametrisation, using the commmand:
reg_resample -ref mean_FA.nii.gz -flo jhu-labels_label_all.nii.gz -res propagated_labels.nii -trans JHU_FA_nrr_cpp.nii -inter 0

I came across some issues with the parameters - trans and - inter. The parameters are unknown. If I replace those with -cpp and -NN, I get a segmentation fault. What then is the correct command to use for this step?

Thanks for your help!

Error: unknown parameter in reg_f3d

According to the help, one can use reg_f3d with CUDA by specifying -platf 1. However, this parameter is not recognised.

$ reg_f3d -ref ../aylj_t1_post.nii.gz -flo mirror_image_left.nii.gz -res left_on_post_reg.nii.gz -platf 1
[reg_f3d] 
[reg_f3d] Command line:
[reg_f3d] 	 reg_f3d -ref ../aylj_t1_post.nii.gz -flo mirror_image_left.nii.gz -res left_on_post_reg.nii.gz -platf 1
[reg_f3d] 
[NiftyReg ERROR] 	Parameter unknown:
[NiftyReg ERROR] -platf

This parameter is captured by reg_aladin

else if(strcmp(argv[i], "-platf")==0 || strcmp(argv[i], "--platf")==0)

but not by reg_f3d, despite the help message
reg_print_info(exec, "*** Platform options:");
#if defined(_USE_CUDA) && defined(_USE_OPENCL)
reg_print_info(exec, "\t-platf <uint>\t\tChoose platform: CPU=0 | Cuda=1 | OpenCL=2 [0]");
#else
#ifdef _USE_CUDA
reg_print_info(exec, "\t-platf\t\t\tChoose platform: CPU=0 | Cuda=1 [0]");
#endif
#ifdef _USE_OPENCL
reg_print_info(exec, "\t-platf\t\t\tChoose platform: CPU=0 | OpenCL=2 [0]");
#endif

Can reg_f3d use CUDA?

Cleaning discrete code

In gitlab by @mmodat on Jul 18, 2017, 13:12

Will remove the discrete code for now since it won't evolve in the coming months and it is not used.
Will make my life easier when finishing porting to platform.

reg_average_interp_option

In gitlab by @rsparks on Mar 26, 2018, 13:43

Dear Esteemed Dr. Modat,

Would it be possible please to add an option for the interpolation order in reg_average?

Merci,
Rachel

reg_average_file_input

In gitlab by @mmodat on Dec 14, 2016, 10:19

When a large amount of images are required to be averaged, the command can be too long. We will add the possibility to parse a text file.

Copyright update

I am planning to update the copyright in NiftyReg from:

Copyright (c) 2009, University College London. All rights reserved.

to

Copyright (c) 2009-2018, University College London
Copyright (c) 2018, NiftyReg Developers.
All rights reserved.

This would, I believe, retain the initial copyright, as required by the BSD licence, while increasing generability by being more inclusive.

@MattClarkson Any chance you could comment on that one? E.g. is it appopriate?

For your information, the current LICENSE.txt file contains

Copyright (c) 2009, University College London, United-Kingdom
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

Neither the name of the University College London nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.

NiftyRegConfig.cmake

Would it be possible to create a NiftyRegConfig.cmake file during the configure phase? This would be useful for any packages that depend on NiftyReg, such as https://github.com/CCPPETMR/SIRF/, avoiding the use of a more complicated FindNiftyReg.cmake file.

I don't mind doing this if you agree it will be useful.

As a minimum, it only needs to contain:

  • path to source
  • path to binary
  • libraries
  • include dir
  • version number

It could also contain e.g., CUDA information. However, as I don't need these, I won't be putting them in.

KL-Divergence

Error spotted in the computation of the KL-Divergence computation and its gradient.

dense_le

In gitlab by @mmodat on Jan 25, 2017, 13:02

Adding function to compute the le regularisation measure and gradient from dense parametrisation.

@mranzini FYI

Setting CI

Set gitlab runners to locally run CI from a mirrored version of the code on gitlab.
Local runners are needed in order to use GPU.

refactoring nonlinear

In order to make the code easier to use, the base classes of NiftyReg will be re-factored.

The aim in to ease the integration of new transformation models and second to ease the use of third-party optimisation libraries.

@LucasFidon @atbenmurray @ddrobny

reg_f3d crash with long inputs

In gitlab by @imalone on Feb 14, 2017, 15:46

I hit a hard-to-trace crash with reg_f3d, which appeared to complete okay, but triggered a general protection fault on completion and reported large negative "Performed in" times. This would cause niftypipe to halt (in any case outputs would have been suspect). It turns out the buffer used for text to report the input command line was being overrun. Eventually tracked it down with -fsanitize=address.

I'd suggest using asprintf to fix this:

diff --git a/reg-apps/reg_f3d.cpp b/reg-apps/reg_f3d.cpp
index 42e9f59..787ff2e 100755
--- a/reg-apps/reg_f3d.cpp
+++ b/reg-apps/reg_f3d.cpp
@@ -173,7 +173,7 @@ int main(int argc, char **argv)
    omp_set_num_threads(defaultOpenMPValue);
 #endif
 
-   char text[1024];
+   char *text=0, *tmptext;
    //\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    // Check if any information is required
    for(int i=1; i<argc; i++)
@@ -218,11 +218,21 @@ int main(int argc, char **argv)
 #endif
       reg_print_info((argv[0]), "");
       reg_print_info((argv[0]), "Command line:");
-      sprintf(text, "\t");
-      for(int i=0; i<argc; i++)
-         sprintf(text+strlen(text), " %s", argv[i]);
+      if (asprintf(&text, "\t") < 0) {
+       reg_print_info((argv[0]), "Out of memory storing command line");
+       return EXIT_FAILURE;
+      }
+      for(int i=0; i<argc; i++) {
+       if (asprintf(&tmptext, "%s %s", text, argv[i]) < 0) {
+         reg_print_info((argv[0]), "Out of memory storing command line");
+         return EXIT_FAILURE;
+       }
+       free(text);
+       text=tmptext;
+      }
       reg_print_info((argv[0]), text);
       reg_print_info((argv[0]), "");
+      free(text); text=0;
 #ifdef NDEBUG
    }
 #endif
@@ -730,8 +740,9 @@ int main(int argc, char **argv)
    if(verbose)
    {
       int maxThreadNumber = omp_get_max_threads();
-      sprintf(text, "OpenMP is used with %i thread(s)", maxThreadNumber);
+      asprintf(&text, "OpenMP is used with %i thread(s)", maxThreadNumber);
       reg_print_info((argv[0]), text);
+      free(text); text=0;
    }
 #endif // _OPENMP
 
@@ -843,9 +854,10 @@ int main(int argc, char **argv)
       time(&end);
       int minutes=(int)floorf((end-start)/60.0f);
       int seconds=(int)(end-start - 60*minutes);
-      sprintf(text, "Registration performed in %i min %i sec", minutes, seconds);
+      asprintf(&text, "Registration performed in %i min %i sec", minutes, seconds);
       reg_print_info((argv[0]), text);
       reg_print_info((argv[0]), "Have a good day !");
+      free(text); text=0;
 #ifdef NDEBUG
    }
 #endif

Small problem in that asprintf is non-standard, GNU and BSD only, but implementation is trivial in C99 using vsnprintf, this is my version:

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>

#ifndef _GNU_SOURCE

int vasprintf(char **strp, const char *fmt, va_list ap) {
  va_list ap2;
  va_copy(ap2, ap);
  int str_len, need_len;
  str_len = vsnprintf(0, 0, fmt, ap);
  need_len = str_len + 1;
  *strp = malloc(need_len);
  if (*strp) {
    vsnprintf(*strp, need_len, fmt, ap2);
  } else {
    *strp = 0;
    str_len = -1;
  }
  va_end(ap2);
  return str_len;
}

int asprintf(char **strp, const char *fmt, ...) {
  va_list ap;
  va_start(ap, fmt);
  int ret_val = vasprintf(strp, fmt, ap);
  va_end(ap);
  return ret_val;
}

#endif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.