-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add work of Thomas Durantel #102
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cf000cf
- Add an ODF average tool (Goh et al. 2011)
Florent2305 9b3562f
Merge pull request #3 from todurante/odf_avr
Florent2305 12dc4d6
Merge branch 'Inria-Empenn:master' into fusion
astamm 86a1306
Replace ANIMA_PRIVATE_VERSION with ANIMA_VERSION following fusion.
astamm 7dac8af
Clean up CMakeLists files to avoid duplicate library linkage.
astamm 3864fe7
Fix bug using not logical operation in wrong way.
astamm a7e707e
Remove useless library linkage and use naming convention from anima i…
astamm f7f8a70
Merge branch 'Inria-Empenn:master' into fusion
astamm d1a361a
Clean up TOD estimator.
astamm b790fd7
Clean ODF average tool.
astamm be8f478
Done simplifying ODF average tool.
astamm 1879d6e
Better document arguments in ODF average tool.
astamm d98f163
Suppress odd line of code.
astamm 35df1d1
Fix Flo comments.
astamm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
add_subdirectory(generalized_fa) | ||
add_subdirectory(odf_estimator) | ||
add_subdirectory(odf_estimator) | ||
add_subdirectory(tod_estimator) | ||
add_subdirectory(odf_average) |
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,29 @@ | ||
if(BUILD_TOOLS) | ||
|
||
project(animaODFAverage) | ||
|
||
# ############################################################################ | ||
# 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} AnimaSHTools) | ||
|
||
# ############################################################################ | ||
# install | ||
# ############################################################################ | ||
|
||
set_exe_install_rules(${PROJECT_NAME}) | ||
|
||
endif() |
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,136 @@ | ||
#include <animaODFAverageImageFilter.h> | ||
#include <animaReadWriteFunctions.h> | ||
|
||
#include <fstream> | ||
|
||
#include <itkTimeProbe.h> | ||
|
||
#include <tclap/CmdLine.h> | ||
|
||
// Update progression of the process | ||
void eventCallback(itk::Object *caller, const itk::EventObject &event, void *clientData) | ||
{ | ||
itk::ProcessObject *processObject = (itk::ProcessObject *)caller; | ||
std::cout << "\033[K\rProgression: " << (int)(processObject->GetProgress() * 100) << "%" << std::flush; | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
TCLAP::CmdLine cmd("INRIA / IRISA - VisAGeS/Empenn Team", ' ', ANIMA_VERSION); | ||
|
||
TCLAP::ValueArg<std::string> inArg( | ||
"i", "input-odf-file", | ||
"A path or file name specifying the text file in which the ODF images are listed.", | ||
true, "", "odf image list", cmd); | ||
TCLAP::ValueArg<std::string> weightArg( | ||
"w", "input-weight-file", | ||
"A path or file name specifying the text file in which the weight images are listed.", | ||
true, "", "weight image list", cmd); | ||
TCLAP::ValueArg<std::string> outArg( | ||
"o", "output-file", | ||
"A path or file name specifying the output average ODF image.", | ||
true, "", "output odf image", cmd); | ||
|
||
TCLAP::ValueArg<unsigned int> nbpArg( | ||
"T", "nb-threads", | ||
"An integer value specifying the number of threads to run on (default: all cores).", | ||
false, itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(), "number of threads", cmd); | ||
|
||
try | ||
{ | ||
cmd.parse(argc, argv); | ||
} | ||
catch (TCLAP::ArgException &e) | ||
{ | ||
std::cerr << "Error: " << e.error() << "for argument " << e.argId() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
itk::CStyleCommand::Pointer callback = itk::CStyleCommand::New(); | ||
callback->SetCallback(eventCallback); | ||
|
||
std::ifstream odfFile(inArg.getValue().c_str()); | ||
if (!odfFile.is_open()) | ||
{ | ||
std::cerr << "Please provide usable file with input ODFs" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
std::ifstream weightFile(weightArg.getValue().c_str()); | ||
if (!weightFile.is_open()) | ||
{ | ||
std::cerr << "Please provide usable file with input weight images" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
using FilterType = anima::ODFAverageImageFilter; | ||
using InputImageType = FilterType::InputImageType; | ||
using OutputImageType = FilterType::OutputImageType; | ||
using WeightImageType = FilterType::WeightImageType; | ||
|
||
FilterType::Pointer mainFilter = FilterType::New(); | ||
|
||
std::vector<std::string> inputFiles; | ||
std::vector<std::string> weightFiles; | ||
|
||
while (!odfFile.eof()) | ||
{ | ||
char tmpStr[2048], weightStr[2048]; | ||
|
||
odfFile.getline(tmpStr, 2048); | ||
if (odfFile.fail()) | ||
{ | ||
std::cerr << "Error: Failed to read an ODF image." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
weightFile.getline(weightStr, 2048); | ||
if (weightFile.fail()) | ||
{ | ||
std::cerr << "Error: Failed to read a weight image." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (strcmp(tmpStr, "") == 0 || strcmp(weightStr, "") == 0) | ||
continue; | ||
|
||
inputFiles.push_back(tmpStr); | ||
weightFiles.push_back(weightStr); | ||
} | ||
|
||
odfFile.close(); | ||
weightFile.close(); | ||
|
||
unsigned int numInputs = weightFiles.size(); | ||
|
||
for (unsigned int i = 0; i < numInputs; ++i) | ||
{ | ||
mainFilter->SetInput(i, anima::readImage<InputImageType>(inputFiles[i])); | ||
mainFilter->AddWeightImage(i, anima::readImage<WeightImageType>(weightFiles[i])); | ||
} | ||
|
||
mainFilter->AddObserver(itk::ProgressEvent(), callback); | ||
mainFilter->SetNumberOfWorkUnits(nbpArg.getValue()); | ||
|
||
itk::TimeProbe tmpTimer; | ||
|
||
tmpTimer.Start(); | ||
|
||
try | ||
{ | ||
mainFilter->Update(); | ||
} | ||
catch (itk::ExceptionObject &e) | ||
{ | ||
std::cerr << e << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
tmpTimer.Stop(); | ||
|
||
std::cout << "\nAveraging done in " << tmpTimer.GetTotal() << "s" << std::endl; | ||
|
||
anima::writeImage(outArg.getValue(), mainFilter->GetOutput()); | ||
|
||
return EXIT_SUCCESS; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.