From: Benoît Presles Date: Tue, 12 Nov 2013 09:30:52 +0000 (+0100) Subject: Merge branch 'master' of git.creatis.insa-lyon.fr:clitk X-Git-Tag: v1.4.0~150^2~2 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=22e282cf465b7f07cd17c4d615d726b079b84058;hp=5753311ba2368f89edfd7ba3d43a0186de1b16b5;p=clitk.git Merge branch 'master' of git.creatis.insa-lyon.fr:clitk --- diff --git a/cluster_tools/gate_merge_merges.sh b/cluster_tools/gate_merge_merges.sh new file mode 100755 index 0000000..72fcbcc --- /dev/null +++ b/cluster_tools/gate_merge_merges.sh @@ -0,0 +1,7 @@ +mkdir run.merge +for i in $(ls -d results.????) +do + ln -s ../$i run.merge/output_${i} +done +gate_power_merge.sh run.merge + diff --git a/cluster_tools/gate_power_merge.sh b/cluster_tools/gate_power_merge.sh index 3a9bba6..c35d67d 100755 --- a/cluster_tools/gate_power_merge.sh +++ b/cluster_tools/gate_power_merge.sh @@ -314,7 +314,7 @@ function merge_dispatcher { local outputfile="${1:?"provide output filename"}" echo "merging ${outputfile}" - local partialoutputfiles="$(find "${rundir}" -mindepth 2 -type f -name "${outputfile}")" + local partialoutputfiles="$(find -L "${rundir}" -mindepth 2 -type f -name "${outputfile}")" local nboutputfiles="$(echo "${partialoutputfiles}" | wc -l)" if test ${nboutputdirs} -ne ${nboutputfiles} then @@ -431,7 +431,7 @@ function merge_dispatcher_uncertainty { local indent=" ** " local outputfile="${1:?"provide output filename"}" - local partialoutputfiles="$(find "${rundir}" -mindepth 2 -type f -name "${outputfile}")" + local partialoutputfiles="$(find -L "${rundir}" -mindepth 2 -type f -name "${outputfile}")" local nboutputfiles="$(echo "${partialoutputfiles}" | wc -l)" if test ${nboutputdirs} -ne ${nboutputfiles} then @@ -466,7 +466,7 @@ function merge_dispatcher_uncertainty { echo "${indent}${squared_merged_file} found" ## search for NumberOfEvent totalEvents=0; - for outputfile in $(find "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq) + for outputfile in $(find -L "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq) do #echo $outputfile if grep -q 'NumberOfEvent' "${outputdir}/${outputfile}" @@ -496,7 +496,7 @@ echo "!!!! this is $0 v0.3k !!!!" rundir="${1?"provide run dir"}" rundir="$(echo "${rundir}" | sed 's|/*$||')" -nboutputdirs="$(find "${rundir}" -mindepth 1 -type d -name 'output*' | wc -l)" +nboutputdirs="$(find "${rundir}" -mindepth 1 -type d -o -type l -name 'output*' | wc -l)" test ${nboutputdirs} -gt 0 || error "no output dir found" echo "found ${nboutputdirs} partial output dirs" @@ -511,15 +511,15 @@ echo "output dir is ${outputdir}" test -d "${outputdir}" && rm -r "${outputdir}" mkdir "${outputdir}" - -for outputfile in $(find "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq) +ls ${rundir}/ +for outputfile in $(find -L "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq) do merge_dispatcher "${outputfile}" done echo "" echo "Merging done. Special case for statistical uncertainty" -for outputfile in $(find "${outputdir}" -regextype 'posix-extended' -type f -regex "${outputdir}/.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq) +for outputfile in $(find -L "${outputdir}" -regextype 'posix-extended' -type f -regex "${outputdir}/.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq) do merge_dispatcher_uncertainty "${outputfile}" done diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index a0e8846..478b817 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -120,6 +120,11 @@ IF (CLITK_BUILD_TOOLS) TARGET_LINK_LIBRARIES(clitkMatrixToElastixTransform clitkCommon ) SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixToElastixTransform) + WRAP_GGO(clitkMatrixMultiply_GGO_C clitkMatrixMultiply.ggo) + ADD_EXECUTABLE(clitkMatrixMultiply clitkMatrixMultiply.cxx ${clitkMatrixMultiply_GGO_C}) + TARGET_LINK_LIBRARIES(clitkMatrixMultiply clitkCommon ) + SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixMultiply) + WRAP_GGO(clitkMatrixInverse_GGO_C clitkMatrixInverse.ggo) ADD_EXECUTABLE(clitkMatrixInverse clitkMatrixInverse.cxx ${clitkMatrixInverse_GGO_C}) TARGET_LINK_LIBRARIES(clitkMatrixInverse clitkCommon ) diff --git a/tools/clitkImageConvert.cxx b/tools/clitkImageConvert.cxx index abedc61..3a9beaf 100644 --- a/tools/clitkImageConvert.cxx +++ b/tools/clitkImageConvert.cxx @@ -67,6 +67,7 @@ int main(int argc, char * argv[]) filter->SetInputFilenames(l); filter->SetIOVerbose(args_info.verbose_flag); filter->SetOutputFilename(output); + filter->SetVV(args_info.vv_flag); filter->EnableWriteCompression(args_info.compression_flag); if (args_info.type_given) filter->SetOutputPixelType(args_info.type_arg); diff --git a/tools/clitkImageConvert.ggo b/tools/clitkImageConvert.ggo index 837ee03..b6f003c 100644 --- a/tools/clitkImageConvert.ggo +++ b/tools/clitkImageConvert.ggo @@ -3,9 +3,10 @@ package "clitkImageConvert" version "1.0" purpose "Convert an image into another image.\n\tAllow to change the file format and/or the pixel type. \n\tKnown file formats 2D: jpeg png bmp tif mhd hdr vox dcm \n\tKnown file formats 3D: mhd vox hdr dcm\n\tKnown file formats 4D: mhd \n\tKnown images: 2D 3D or 4D, schar, uchar, short, ushort, int, float and double\n\nIf the -o option is not given, the last parameter of the command line is used as output." -option "config" - "Config file" string no -option "input" i "Input image filename" string no -option "output" o "Output image filename" string no -option "type" t "Output type (float, ushort ...)" string no -option "verbose" v "Verbose" flag off -option "compression" c "Compress output" flag off +option "config" - "Config file" string no +option "input" i "Input image filename" string no +option "output" o "Output image filename" string no +option "type" t "Output type (float, ushort ...)" string no +option "verbose" v "Verbose" flag off +option "compression" c "Compress output" flag off +option "vv" - "Read image as in vv and save transform in meta information" flag off diff --git a/tools/clitkImageConvertGenericFilter.cxx b/tools/clitkImageConvertGenericFilter.cxx index e8d8efb..2783053 100644 --- a/tools/clitkImageConvertGenericFilter.cxx +++ b/tools/clitkImageConvertGenericFilter.cxx @@ -19,6 +19,8 @@ #define CLITKIMAGECONVERTGENERICFILTER_CXX #include "clitkImageConvertGenericFilter.h" +#include "vvImageReader.h" +#include "vvImageWriter.h" //-------------------------------------------------------------------- clitk::ImageConvertGenericFilter::ImageConvertGenericFilter(): @@ -70,7 +72,24 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType() } } - if ((m_PixelTypeName == mOutputPixelTypeName) || (mOutputPixelTypeName == "NotSpecified")) { + if(mVV) { + if (mOutputPixelTypeName != "NotSpecified" || m_WriteCompression) { + std::cerr << "--vv is not compatible with --compression and --type options." << std::endl; + exit(-1); + } + + vvImageReader::Pointer reader = vvImageReader::New(); + reader->SetInputFilenames(m_InputFilenames); + reader->Update(vvImageReader::IMAGE); + + vvImageWriter::Pointer writer = vvImageWriter::New(); + writer->SetOutputFileName(m_OutputFilenames.front()); + writer->SetSaveTransform(true); + writer->SetInput(reader->GetOutput()); + writer->Update(); + return; + } + else if ((m_PixelTypeName == mOutputPixelTypeName) || (mOutputPixelTypeName == "NotSpecified")) { typename InputImageType::Pointer input = this->template GetInput(0); this->SetNextOutput(input); } else { diff --git a/tools/clitkImageConvertGenericFilter.h b/tools/clitkImageConvertGenericFilter.h index 2071714..8ffb360 100644 --- a/tools/clitkImageConvertGenericFilter.h +++ b/tools/clitkImageConvertGenericFilter.h @@ -73,6 +73,7 @@ namespace clitk { std::string GetInputPixelTypeName() { return m_PixelTypeName; } std::string GetOutputPixelTypeName() { return mOutputPixelTypeName; } void SetOutputPixelType(std::string p) { mOutputPixelTypeName = p; } + void SetVV(bool b) { mVV = b; } bool IsWarningOccur() { return mWarningOccur; } std::string & GetWarning() { return mWarning; } void EnableDisplayWarning(bool b) { mDisplayWarning = b; } @@ -92,6 +93,7 @@ namespace clitk { std::string mWarning; bool mWarningOccur; bool mDisplayWarning; + bool mVV; private: template diff --git a/tools/clitkMatrixMultiply.cxx b/tools/clitkMatrixMultiply.cxx new file mode 100644 index 0000000..95e1a40 --- /dev/null +++ b/tools/clitkMatrixMultiply.cxx @@ -0,0 +1,59 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ + +// clitk +#include "clitkMatrixMultiply_ggo.h" +#include "clitkTransformUtilities.h" +#include "clitkIO.h" +#include "clitkMatrix.h" + +//-------------------------------------------------------------------- +int main(int argc, char * argv[]) +{ + // Init command line + GGO(clitkMatrixMultiply, args_info); + CLITK_INIT; + + // Read matrix + itk::Matrix matrix1, matrix2; + try { + matrix1 = clitk::ReadMatrix3D(args_info.input1_arg); + matrix2 = clitk::ReadMatrix3D(args_info.input2_arg); + } + catch (itk::ExceptionObject & err) { + std::cerr << "Error reading " + << args_info.input1_arg + << " and " + << args_info.input2_arg + << std::endl; + std::cerr << err.GetDescription() << std::endl; + exit(-1); + } + + itk::Matrix matrix(matrix2.GetVnlMatrix() * matrix1.GetVnlMatrix()); + + // Print matrix + std::ofstream os; + clitk::openFileForWriting(os, args_info.output_arg); + os << clitk::Get4x4MatrixDoubleAsString(matrix, 16); + os.close(); + + return EXIT_SUCCESS; +}// end main + +//-------------------------------------------------------------------- diff --git a/tools/clitkMatrixMultiply.ggo b/tools/clitkMatrixMultiply.ggo new file mode 100644 index 0000000..5463bdd --- /dev/null +++ b/tools/clitkMatrixMultiply.ggo @@ -0,0 +1,8 @@ +package "clitkMatrixMultiply" +version "1.0" +purpose "Multiply two 4x4 matrices. In matrice notations, does input2*input" + +option "config" - "Config file" string optional +option "input1" i "Input matrix filename" string required +option "input2" j "Input matrix filename" string required +option "output" o "Output matrix filename" string required