Skip to content

Commit

Permalink
Final switch to ITK 5. Requires C++17 for animaCropImage
Browse files Browse the repository at this point in the history
  • Loading branch information
ocommowi committed Jun 3, 2019
1 parent ba3552a commit ebdf6b5
Show file tree
Hide file tree
Showing 26 changed files with 189 additions and 166 deletions.
2 changes: 1 addition & 1 deletion Anima/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(ANIMA VERSION 3.3)

# On Macs, disable MACOSX_RPATH (cmake 3.x)
set(CMAKE_MACOSX_RPATH OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

# Define default build type if needed
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand Down
1 change: 1 addition & 0 deletions Anima/cmake/ITKLibs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(ITKIO_LIBRARIES
ITKIOGE
ITKIOHDF5
ITKIOJPEG
ITKIOJPEG2000
ITKIOLSM
ITKIOMeta
ITKIOMINC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <vtkSmartPointer.h>
#include <itkProcessObject.h>
#include <itkLinearInterpolateImageFunction.h>
#include <itkFastMutexLock.h>
#include <mutex>
#include <itkProgressReporter.h>

#include <vector>
Expand Down Expand Up @@ -173,7 +173,7 @@ class BaseProbabilisticTractographyImageFilter : public itk::ProcessObject
virtual ~BaseProbabilisticTractographyImageFilter();

//! Multithread util function
static ITK_THREAD_RETURN_TYPE ThreadTracker(void *arg);
static itk::ITK_THREAD_RETURN_TYPE ThreadTracker(void *arg);

//! Doing the thread work dispatch
void ThreadTrack(unsigned int numThread, FiberProcessVectorType &resultFibers, ListType &resultWeights);
Expand Down Expand Up @@ -273,7 +273,7 @@ class BaseProbabilisticTractographyImageFilter : public itk::ProcessObject

vtkSmartPointer<vtkPolyData> m_Output;

itk::SimpleFastMutexLock m_LockHighestProcessedSeed;
std::mutex m_LockHighestProcessedSeed;
int m_HighestProcessedSeed;
itk::ProgressReporter *m_ProgressReport;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ BaseProbabilisticTractographyImageFilter <TInputModelImageType>::GetModelInterpo
}

template <class TInputModelImageType>
ITK_THREAD_RETURN_TYPE
itk::ITK_THREAD_RETURN_TYPE
BaseProbabilisticTractographyImageFilter <TInputModelImageType>
::ThreadTracker(void *arg)
{
Expand Down Expand Up @@ -292,11 +292,11 @@ BaseProbabilisticTractographyImageFilter <TInputModelImageType>

while (continueLoop)
{
m_LockHighestProcessedSeed.Lock();
m_LockHighestProcessedSeed.lock();

if (m_HighestProcessedSeed >= highestToleratedSeedIndex)
{
m_LockHighestProcessedSeed.Unlock();
m_LockHighestProcessedSeed.unlock();
continueLoop = false;
continue;
}
Expand All @@ -308,13 +308,13 @@ BaseProbabilisticTractographyImageFilter <TInputModelImageType>

m_HighestProcessedSeed = endPoint;

m_LockHighestProcessedSeed.Unlock();
m_LockHighestProcessedSeed.unlock();

this->ThreadedTrackComputer(numThread,resultFibers,resultWeights,startPoint,endPoint);

m_LockHighestProcessedSeed.Lock();
m_LockHighestProcessedSeed.lock();
m_ProgressReport->CompletedPixel();
m_LockHighestProcessedSeed.Unlock();
m_LockHighestProcessedSeed.unlock();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void BaseTractographyImageFilter::PrepareTractography()
std::cout << "Generated " << m_PointsToProcess.size() << " seed points from ROI mask" << std::endl;
}

ITK_THREAD_RETURN_TYPE BaseTractographyImageFilter::ThreadTracker(void *arg)
itk::ITK_THREAD_RETURN_TYPE BaseTractographyImageFilter::ThreadTracker(void *arg)
{
itk::MultiThreaderBase::WorkUnitInfo *threadArgs = (itk::MultiThreaderBase::WorkUnitInfo *)arg;
unsigned int nbThread = threadArgs->WorkUnitID;
Expand All @@ -193,11 +193,11 @@ void BaseTractographyImageFilter::ThreadTrack(unsigned int numThread, std::vecto

while (continueLoop)
{
m_LockHighestProcessedSeed.Lock();
m_LockHighestProcessedSeed.lock();

if (m_HighestProcessedSeed >= highestToleratedSeedIndex)
{
m_LockHighestProcessedSeed.Unlock();
m_LockHighestProcessedSeed.unlock();
continueLoop = false;
continue;
}
Expand All @@ -209,13 +209,13 @@ void BaseTractographyImageFilter::ThreadTrack(unsigned int numThread, std::vecto

m_HighestProcessedSeed = endPoint;

m_LockHighestProcessedSeed.Unlock();
m_LockHighestProcessedSeed.unlock();

this->ThreadedTrackComputer(numThread,resultFibers,startPoint,endPoint);

m_LockHighestProcessedSeed.Lock();
m_LockHighestProcessedSeed.lock();
m_ProgressReport->CompletedPixel();
m_LockHighestProcessedSeed.Unlock();
m_LockHighestProcessedSeed.unlock();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <vtkSmartPointer.h>
#include <itkLinearInterpolateImageFunction.h>
#include <itkProcessObject.h>
#include <itkFastMutexLock.h>
#include <mutex>
#include <itkProgressReporter.h>

#include "AnimaTractographyExport.h"
Expand Down Expand Up @@ -83,7 +83,7 @@ class ANIMATRACTOGRAPHY_EXPORT BaseTractographyImageFilter : public itk::Process
BaseTractographyImageFilter();
virtual ~BaseTractographyImageFilter();

static ITK_THREAD_RETURN_TYPE ThreadTracker(void *arg);
static itk::ITK_THREAD_RETURN_TYPE ThreadTracker(void *arg);
void ThreadTrack(unsigned int numThread, std::vector <FiberType> &resultFibers);
void ThreadedTrackComputer(unsigned int numThread, std::vector <FiberType> &resultFibers,
unsigned int startSeedIndex, unsigned int endSeedIndex);
Expand Down Expand Up @@ -130,7 +130,7 @@ class ANIMATRACTOGRAPHY_EXPORT BaseTractographyImageFilter : public itk::Process
bool m_ComputeLocalColors;
vtkSmartPointer<vtkPolyData> m_Output;

itk::SimpleFastMutexLock m_LockHighestProcessedSeed;
std::mutex m_LockHighestProcessedSeed;
int m_HighestProcessedSeed;
itk::ProgressReporter *m_ProgressReport;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ typedef struct
std::vector <unsigned int> forbiddenLabels;
} ThreaderArguments;

ITK_THREAD_RETURN_TYPE ThreadFilterer(void *arg)
itk::ITK_THREAD_RETURN_TYPE ThreadFilterer(void *arg)
{
itk::MultiThreaderBase::WorkUnitInfo *threadArgs = (itk::MultiThreaderBase::WorkUnitInfo *)arg;
unsigned int nbThread = threadArgs->WorkUnitID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <itkImageToImageFilter.h>
#include <itkFastMutexLock.h>
#include <mutex>

namespace anima
{
Expand Down Expand Up @@ -51,10 +51,10 @@ class NumberedThreadImageToImageFilter :
private:
ITK_DISALLOW_COPY_AND_ASSIGN(NumberedThreadImageToImageFilter);

itk::SimpleFastMutexLock m_LockThreadIdNumber;
std::mutex m_LockThreadIdNumber;
std::vector <unsigned int> m_ThreadIdsVector;

itk::SimpleFastMutexLock m_LockProcessedPoints;
std::mutex m_LockProcessedPoints;
unsigned int m_NumberOfProcessedPoints;
unsigned int m_NumberOfPointsToProcess;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ void
NumberedThreadImageToImageFilter <TInputImage, TOutputImage>
::IncrementNumberOfProcessedPoints()
{
m_LockProcessedPoints.Lock();
m_LockProcessedPoints.lock();

++m_NumberOfProcessedPoints;

double ratio = static_cast <double> (m_NumberOfProcessedPoints) / m_NumberOfPointsToProcess;
this->UpdateProgress(ratio);

m_LockProcessedPoints.Unlock();
m_LockProcessedPoints.unlock();
}

template <typename TInputImage, typename TOutputImage>
unsigned int
NumberedThreadImageToImageFilter <TInputImage, TOutputImage>
::GetSafeThreadId()
{
m_LockThreadIdNumber.Lock();
m_LockThreadIdNumber.lock();

unsigned int threadId = 0;
bool presentInIdsVector = true;
Expand All @@ -92,7 +92,7 @@ NumberedThreadImageToImageFilter <TInputImage, TOutputImage>

m_ThreadIdsVector.push_back(threadId);

m_LockThreadIdNumber.Unlock();
m_LockThreadIdNumber.unlock();

return threadId;
}
Expand All @@ -102,7 +102,7 @@ void
NumberedThreadImageToImageFilter <TInputImage, TOutputImage>
::SafeReleaseThreadId(unsigned int threadId)
{
m_LockThreadIdNumber.Lock();
m_LockThreadIdNumber.lock();

unsigned int indexThreadId = 0;
for (unsigned int i = 0;i < m_ThreadIdsVector.size();++i)
Expand All @@ -116,7 +116,7 @@ NumberedThreadImageToImageFilter <TInputImage, TOutputImage>

m_ThreadIdsVector.erase(m_ThreadIdsVector.begin() + indexThreadId);

m_LockThreadIdNumber.Unlock();
m_LockThreadIdNumber.unlock();
}

} // end namespace anima
Loading

0 comments on commit ebdf6b5

Please sign in to comment.