-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from MariePoirierGit/dirichlet_distribution
A dedicated library for statistical distributions
- Loading branch information
Showing
41 changed files
with
1,623 additions
and
486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Anima/diffusion/mcm_tools/mcm_merge_anisotropic_weights/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
if(BUILD_TOOLS) | ||
|
||
project(animaMCMMergeAnisotropicWeights) | ||
|
||
## ############################################################################# | ||
## List Sources | ||
## ############################################################################# | ||
|
||
list_source_files(${PROJECT_NAME} | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
## ############################################################################# | ||
## add executable | ||
## ############################################################################# | ||
|
||
add_executable(${PROJECT_NAME} | ||
${${PROJECT_NAME}_CFILES} | ||
) | ||
|
||
|
||
## ############################################################################# | ||
## Link | ||
## ############################################################################# | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
${ITKIO_LIBRARIES} | ||
AnimaMCM | ||
) | ||
|
||
## ############################################################################# | ||
## install | ||
## ############################################################################# | ||
|
||
set_exe_install_rules(${PROJECT_NAME}) | ||
|
||
endif() |
106 changes: 106 additions & 0 deletions
106
Anima/diffusion/mcm_tools/mcm_merge_anisotropic_weights/animaMCMMergeAnisotropicWeights.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#include <animaMCMFileReader.h> | ||
#include <animaMCMImage.h> | ||
#include <animaMultiCompartmentModel.h> | ||
#include <animaReadWriteFunctions.h> | ||
#include <itkImageRegionConstIterator.h> | ||
#include <itkImageRegionIterator.h> | ||
|
||
#include <tclap/CmdLine.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
TCLAP::CmdLine cmd("INRIA / IRISA - VisAGeS/Empenn Team", ' ', ANIMA_VERSION); | ||
|
||
TCLAP::ValueArg<std::string> inArg("i", "inputfile", "Input MCM image", true, "", "input mcm image", cmd); | ||
TCLAP::ValueArg<std::string> outArg("o", "outputfile", "Output image with combined anisotropic weights", true, "", "output conbined weight image", cmd); | ||
|
||
try | ||
{ | ||
cmd.parse(argc,argv); | ||
} | ||
catch (TCLAP::ArgException& e) | ||
{ | ||
std::cerr << "Error: " << e.error() << "for argument " << e.argId() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
using InputImageType = anima::MCMImage <double, 3>; | ||
using OutputImageType = itk::VectorImage <double, 3>; | ||
using InputPixelType = InputImageType::PixelType; | ||
using OutputPixelType = OutputImageType::PixelType; | ||
using MCModelType = anima::MultiCompartmentModel; | ||
using MCModelPointer = MCModelType::Pointer; | ||
|
||
// Read input sample | ||
anima::MCMFileReader <double, 3> mcmReader; | ||
mcmReader.SetFileName(inArg.getValue()); | ||
mcmReader.Update(); | ||
InputImageType::Pointer mcmImage = mcmReader.GetModelVectorImage(); | ||
MCModelPointer mcmPtr = mcmImage->GetDescriptionModel()->Clone(); | ||
InputPixelType mcmValue; | ||
unsigned int numCompartments = mcmPtr->GetNumberOfCompartments(); | ||
unsigned int numIsoCompartments = mcmPtr->GetNumberOfIsotropicCompartments(); | ||
|
||
using InputImageIteratorType = itk::ImageRegionConstIterator <InputImageType>; | ||
using OutputImageIteratorType = itk::ImageRegionIterator <OutputImageType>; | ||
InputImageIteratorType inItr(mcmImage, mcmImage->GetLargestPossibleRegion()); | ||
|
||
// Initialize output image | ||
unsigned int nbOutputComponents = numIsoCompartments + 1; | ||
OutputImageType::Pointer outputImage = OutputImageType::New(); | ||
outputImage->SetRegions(mcmImage->GetLargestPossibleRegion()); | ||
outputImage->CopyInformation(mcmImage); | ||
outputImage->SetVectorLength(nbOutputComponents); | ||
outputImage->Allocate(); | ||
|
||
OutputPixelType outputValue(nbOutputComponents); | ||
outputValue.Fill(0.0); | ||
outputImage->FillBuffer(outputValue); | ||
|
||
std::cout << "- Number of compartments in input image: " << numCompartments << std::endl; | ||
std::cout << "- Number of compartments in output image: " << nbOutputComponents << std::endl; | ||
|
||
OutputImageIteratorType outItr(outputImage, outputImage->GetLargestPossibleRegion()); | ||
|
||
while (!outItr.IsAtEnd()) | ||
{ | ||
mcmValue = inItr.Get(); | ||
|
||
bool backgroundVoxel = true; | ||
for (unsigned int i = 0;i < mcmValue.GetNumberOfElements();++i) | ||
{ | ||
if (mcmValue[i] != 0.0) | ||
{ | ||
backgroundVoxel = false; | ||
break; | ||
} | ||
} | ||
|
||
if (backgroundVoxel) | ||
{ | ||
++inItr; | ||
++outItr; | ||
continue; | ||
} | ||
|
||
mcmPtr->SetModelVector(mcmValue); | ||
|
||
for (unsigned int i = 0;i < numIsoCompartments;++i) | ||
outputValue[i] = mcmPtr->GetCompartmentWeight(i); | ||
|
||
double anisoWeight = 0.0; | ||
for (unsigned int i = numIsoCompartments;i < numCompartments;++i) | ||
anisoWeight += mcmPtr->GetCompartmentWeight(i); | ||
|
||
outputValue[numIsoCompartments] = anisoWeight; | ||
|
||
outItr.Set(outputValue); | ||
|
||
++inItr; | ||
++outItr; | ||
} | ||
|
||
anima::writeImage <OutputImageType> (outArg.getValue(), outputImage); | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.