Skip to content

Commit

Permalink
Eliminate dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
onurulgen committed Feb 22, 2024
1 parent f5e227f commit 1c99a7a
Show file tree
Hide file tree
Showing 48 changed files with 236 additions and 5,745 deletions.
2 changes: 1 addition & 1 deletion niftyreg_build_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
414
415
13 changes: 0 additions & 13 deletions reg-apps/reg_average.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@ void usage(char *exec)
NR_INFO("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
}

void average_norm_intensity(nifti_image *image)
{
PrecisionType *rankedIntensities = (PrecisionType *)malloc(image->nvox*sizeof(PrecisionType));
memcpy(rankedIntensities,image->data,image->nvox*sizeof(PrecisionType));
reg_heapSort(rankedIntensities,static_cast<int>(image->nvox));
PrecisionType lowerValue=rankedIntensities[static_cast<unsigned>(static_cast<float>(image->nvox)*0.03f)];
PrecisionType higherValue=rankedIntensities[static_cast<unsigned>(static_cast<float>(image->nvox)*0.97f)];
reg_tools_subtractValueFromImage(image,image,lowerValue);
reg_tools_multiplyValueToImage(image,image,255.f/(higherValue-lowerValue));
free(rankedIntensities);
return;
}

int remove_nan_and_add(nifti_image *averageImage,
nifti_image *toAddImage,
nifti_image *definedNumImage)
Expand Down
1 change: 0 additions & 1 deletion reg-apps/reg_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "_reg_globalTrans.h"
#include "_reg_localTrans.h"
#include "_reg_tools.h"
#include "_reg_thinPlateSpline.h"
#include "_reg_maths_eigen.h"

#include "reg_transform.h"
Expand Down
53 changes: 0 additions & 53 deletions reg-io/_reg_ReadWriteImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,56 +158,3 @@ void reg_io_WriteImageFile(nifti_image *image, const char *filename) {
}
}
/* *************************************************************** */
template <class DataType>
void reg_io_displayImageData1(nifti_image *image) {
NR_DEBUG("Image values:");
const DataType *data = static_cast<DataType*>(image->data);
const size_t nVoxelsPerVolume = NiftiImage::calcVoxelNumber(image, 3);

size_t voxelIndex = 0;
for (int z = 0; z < image->nz; z++) {
for (int y = 0; y < image->ny; y++) {
for (int x = 0; x < image->nx; x++) {
std::string text = "[" + std::to_string(x) + " - " + std::to_string(y) + " - " + std::to_string(z) + "] = [";
for (int tu = 0; tu < image->nt * image->nu; ++tu)
text += std::to_string(static_cast<double>(data[voxelIndex + tu * nVoxelsPerVolume])) + " ";
if (text.back() == ' ')
text.pop_back();
text += "]";
NR_DEBUG(text);
}
}
}
}
/* *************************************************************** */
void reg_io_displayImageData(nifti_image *image) {
switch (image->datatype) {
case NIFTI_TYPE_UINT8:
reg_io_displayImageData1<unsigned char>(image);
break;
case NIFTI_TYPE_INT8:
reg_io_displayImageData1<char>(image);
break;
case NIFTI_TYPE_UINT16:
reg_io_displayImageData1<unsigned short>(image);
break;
case NIFTI_TYPE_INT16:
reg_io_displayImageData1<short>(image);
break;
case NIFTI_TYPE_UINT32:
reg_io_displayImageData1<unsigned>(image);
break;
case NIFTI_TYPE_INT32:
reg_io_displayImageData1<int>(image);
break;
case NIFTI_TYPE_FLOAT32:
reg_io_displayImageData1<float>(image);
break;
case NIFTI_TYPE_FLOAT64:
reg_io_displayImageData1<double>(image);
break;
default:
NR_FATAL_ERROR("Unsupported datatype");
}
}
/* *************************************************************** */
6 changes: 0 additions & 6 deletions reg-io/_reg_ReadWriteImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,3 @@ nifti_image *reg_io_ReadImageHeader(const char *filename);
*/
void reg_io_WriteImageFile(nifti_image *image, const char *filename);
/* *************************************************************** */
/** The function expects a nifti_image structure
* The image will be displayed on the standard output
* @param Nifti image to be displayed
*/
void reg_io_displayImageData(nifti_image *image);
/* *************************************************************** */
27 changes: 0 additions & 27 deletions reg-io/_reg_ReadWriteMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,30 +201,3 @@ T** reg_tool_ReadMatrixFile(char *filename, size_t nbLine, size_t nbColumn) {
template float** reg_tool_ReadMatrixFile<float>(char *filename, size_t nbLine, size_t nbColumn);
template double** reg_tool_ReadMatrixFile<double>(char *filename, size_t nbLine, size_t nbColumn);
/* *************************************************************** */
mat44* reg_tool_ReadMat44File(char *fileName) {
mat44 *mat = (mat44 *)malloc(sizeof(mat44));
std::ifstream matrixFile;
matrixFile.open(fileName);
if (matrixFile.is_open()) {
int i = 0;
double value1, value2, value3, value4;
while (!matrixFile.eof()) {
matrixFile >> value1 >> value2 >> value3 >> value4;

mat->m[i][0] = (float)value1;
mat->m[i][1] = (float)value2;
mat->m[i][2] = (float)value3;
mat->m[i][3] = (float)value4;
i++;
if (i > 3) break;
}
} else {
NR_FATAL_ERROR("The mat44 file can not be read: "s + fileName);
}
matrixFile.close();

NR_MAT44_DEBUG(*mat, "mat44 matrix");

return mat;
}
/* *************************************************************** */
8 changes: 0 additions & 8 deletions reg-io/_reg_ReadWriteMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ void reg_tool_ReadAffineFile(mat44 *mat,
void reg_tool_ReadAffineFile(mat44 *mat,
char *filename);

/**
* @brief Read a file that contains a 4-by-4 matrix and store it into
* a mat44 structure
* @param filename Filename of the text file that contains the matrix to read
* @return mat44 structure that store the matrix
**/
mat44* reg_tool_ReadMat44File(char *fileName);

/** @brief This function save a 4-by-4 matrix to the disk as a text file
* @param mat Matrix to be saved on the disk
* @param filename Name of the text file to save on the disk
Expand Down
39 changes: 0 additions & 39 deletions reg-lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ install(TARGETS _reg_blockMatching
)
set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_blockMatching")
#-----------------------------------------------------------------------------
add_library(_reg_femTrans ${NIFTYREG_LIBRARY_TYPE} cpu/_reg_femTrans.cpp)
target_link_libraries(_reg_femTrans _reg_globalTrans)
install(TARGETS _reg_femTrans
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_femTrans")
#-----------------------------------------------------------------------------
add_library(_reg_compute ${NIFTYREG_LIBRARY_TYPE}
Compute.cpp
AladinContent.cpp
Expand Down Expand Up @@ -191,34 +182,4 @@ install(TARGETS _reg_f3d
set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES};_reg_f3d")
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# BUILD THE TPS LIBRARY
#set(NAME _reg_thinPlateSpline)
#if(APPLE)
# add_library(${NAME} SHARED cpu/${NAME}.cpp)
#else(APPLE)
# add_library(${NAME} ${NIFTYREG_LIBRARY_TYPE} cpu/${NAME}.cpp)
#endif(APPLE)
#target_link_libraries(${NAME} _reg_tools _reg_ReadWriteImage)
#install(TARGETS ${NAME}
# RUNTIME DESTINATION bin
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib
# )
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
## BUILD THE POLYAFFINE LIBRARY
#set(NAME _reg_polyAffine)
#if(APPLE)
# add_library(${NAME} SHARED _reg_base.cpp ${NAME}.cpp)
#else(APPLE)
# add_library(${NAME} ${NIFTYREG_LIBRARY_TYPE} _reg_base.cpp ${NAME}.cpp)
#endif(APPLE)
#target_link_libraries(${NAME} _reg_tools _reg_ReadWriteImage)
#install(TARGETS ${NAME}
# RUNTIME DESTINATION bin
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib
# )
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
set(NIFTYREG_LIBRARIES "${NIFTYREG_LIBRARIES}" PARENT_SCOPE)
6 changes: 0 additions & 6 deletions reg-lib/Debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,12 @@ inline std::string StripFunctionName(const std::string& funcName) {
#define NR_INFO(msg) NR_COUT << "[NiftyReg INFO] " << msg << std::endl
/* *************************************************************** */
#ifndef NDEBUG
#define NR_MAT33(mat, title) reg_mat33_disp(mat, "[NiftyReg DEBUG] "s + (title))
#define NR_MAT44(mat, title) reg_mat44_disp(mat, "[NiftyReg DEBUG] "s + (title))
#define NR_MAT33_DEBUG(mat, title) NR_MAT33(mat, title)
#define NR_MAT44_DEBUG(mat, title) NR_MAT44(mat, title)
#define NR_MAT33_VERBOSE(mat, title) NR_MAT33(mat, title)
#define NR_MAT44_VERBOSE(mat, title) NR_MAT44(mat, title)
#else
#define NR_MAT33(mat, title) reg_mat33_disp(mat, title)
#define NR_MAT44(mat, title) reg_mat44_disp(mat, title)
#define NR_MAT33_DEBUG(mat, title)
#define NR_MAT44_DEBUG(mat, title)
#define NR_MAT33_VERBOSE(mat, title) if (this->verbose) NR_MAT33(mat, "[NiftyReg INFO] "s + (title))
#define NR_MAT44_VERBOSE(mat, title) if (this->verbose) NR_MAT44(mat, "[NiftyReg INFO] "s + (title))
#endif
/* *************************************************************** */
80 changes: 0 additions & 80 deletions reg-lib/Optimiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,85 +331,5 @@ void ConjugateGradient<T>::Perturbation(float length) {
template class ConjugateGradient<float>;
template class ConjugateGradient<double>;
/* *************************************************************** */
template <class T>
Lbfgs<T>::Lbfgs(): Optimiser<T>::Optimiser() {
this->stepToKeep = 5;
this->oldDof = nullptr;
this->oldGrad = nullptr;
this->diffDof = nullptr;
this->diffGrad = nullptr;
}
/* *************************************************************** */
template <class T>
Lbfgs<T>::~Lbfgs() {
if (this->oldDof) {
free(this->oldDof);
this->oldDof = nullptr;
}
if (this->oldGrad) {
free(this->oldGrad);
this->oldGrad = nullptr;
}
for (size_t i = 0; i < this->stepToKeep; ++i) {
if (this->diffDof[i]) {
free(this->diffDof[i]);
this->diffDof[i] = nullptr;
}
if (this->diffGrad[i]) {
free(this->diffGrad[i]);
this->diffGrad[i] = nullptr;
}
}
if (this->diffDof) {
free(this->diffDof);
this->diffDof = nullptr;
}
if (this->diffGrad) {
free(this->diffGrad);
this->diffGrad = nullptr;
}
}
/* *************************************************************** */
template <class T>
void Lbfgs<T>::Initialise(size_t nvox,
int ndim,
bool optX,
bool optY,
bool optZ,
size_t maxIt,
size_t startIt,
InterfaceOptimiser *intOpt,
T *cppData,
T *gradData,
size_t nvoxBw,
T *cppDataBw,
T *gradDataBw) {
Optimiser<T>::Initialise(nvox, ndim, optX, optY, optZ, maxIt, startIt, intOpt, cppData, gradData, nvoxBw, cppDataBw, gradDataBw);
this->stepToKeep = 5;
this->diffDof = (T**)malloc(this->stepToKeep * sizeof(T*));
this->diffGrad = (T**)malloc(this->stepToKeep * sizeof(T*));
for (size_t i = 0; i < this->stepToKeep; ++i) {
this->diffDof[i] = (T*)malloc(this->dofNumber * sizeof(T));
this->diffGrad[i] = (T*)malloc(this->dofNumber * sizeof(T));
if (this->diffDof[i] == nullptr || this->diffGrad[i] == nullptr)
NR_FATAL_ERROR("Out of memory");
}
this->oldDof = (T*)malloc(this->dofNumber * sizeof(T));
this->oldGrad = (T*)malloc(this->dofNumber * sizeof(T));
if (this->oldDof == nullptr || this->oldGrad == nullptr)
NR_FATAL_ERROR("Out of memory");
}
/* *************************************************************** */
template <class T>
void Lbfgs<T>::UpdateGradientValues() {
NR_FATAL_ERROR("Not implemented");
}
/* *************************************************************** */
template <class T>
void Lbfgs<T>::Optimise(T maxLength, T smallLength, T& startLength) {
this->UpdateGradientValues();
Optimiser<T>::Optimise(maxLength, smallLength, startLength);
}
/* *************************************************************** */
} // namespace NiftyReg
/* *************************************************************** */
38 changes: 0 additions & 38 deletions reg-lib/Optimiser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,43 +179,5 @@ class ConjugateGradient: public Optimiser<T> {
virtual void Perturbation(float length) override;
};
/* *************************************************************** */
/** @class Global optimisation class
* @brief
*/
template <class T>
class Lbfgs: public Optimiser<T> {
protected:
size_t stepToKeep;
T *oldDof;
T *oldGrad;
T **diffDof;
T **diffGrad;

#ifdef NR_TESTING
public:
#endif
virtual void UpdateGradientValues() override;

public:
Lbfgs();
virtual ~Lbfgs();
virtual void Initialise(size_t nvox,
int ndim,
bool optX,
bool optY,
bool optZ,
size_t maxIt,
size_t startIt,
InterfaceOptimiser *intOpt,
T *cppData,
T *gradData,
size_t nvoxBw,
T *cppDataBw,
T *gradDataBw) override;
virtual void Optimise(T maxLength,
T smallLength,
T& startLength) override;
};
/* *************************************************************** */
} // namespace NiftyReg
/* *************************************************************** */
4 changes: 0 additions & 4 deletions reg-lib/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ PlatformType Platform::GetPlatformType() const {
return platformType;
}
/* *************************************************************** */
unsigned Platform::GetGpuIdx() const {
return gpuIdx;
}
/* *************************************************************** */
void Platform::SetGpuIdx(unsigned gpuIdxIn) {
if (platformType == PlatformType::Cpu) {
gpuIdx = 999;
Expand Down
1 change: 0 additions & 1 deletion reg-lib/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Platform {

std::string GetName() const;
PlatformType GetPlatformType() const;
unsigned GetGpuIdx() const;
void SetGpuIdx(unsigned gpuIdxIn);

Compute* CreateCompute(Content& con) const;
Expand Down
Loading

0 comments on commit 1c99a7a

Please sign in to comment.