From: Grenier Thomas Date: Sun, 10 Dec 2017 12:58:00 +0000 (+0100) Subject: Merge branch 'master' of ssh://git.creatis.insa-lyon.fr/STMS X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=52d9a4ff6a971908206fcb9bed99942480de4ef8;hp=29f7ebaae72aa02beabb9f842816c275e297ffa9;p=STMS.git Merge branch 'master' of ssh://git.creatis.insa-lyon.fr/STMS # Conflicts: # Src/CMakeLists.txt --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..789f4f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Ignore user files +*.user diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user deleted file mode 100644 index e49be18..0000000 --- a/CMakeLists.txt.user +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - EnvironmentId - {0d0dac41-b5d4-48ba-8b55-2eef6c8f9c37} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - 1 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop - Desktop - {02771194-e57d-45d0-a1ce-cf0336f8bb4f} - 1 - 0 - 0 - - - CMAKE_BUILD_TYPE:STRING=Debug - - /opt/MasterGrenier/bin/Creatis_GIT/STMS/STMS-Debug - - - - - all - - true - Make - - CMakeProjectManager.MakeStep - - 1 - Build - - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - Make - - CMakeProjectManager.MakeStep - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Debug - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=Release - CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ - - /opt/MasterGrenier/bin/Creatis_GIT/STMS/STMS-Release - - - - - all - - true - Make - - CMakeProjectManager.MakeStep - - 1 - Build - - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - Make - - CMakeProjectManager.MakeStep - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Release - CMakeProjectManager.CMakeBuildConfiguration - - 2 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy locally - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - STMS_GrayLevelFiltering - - - /opt/MasterGrenier/bin/Creatis_GIT/STMS/STMS-Release/Src - 2 - - STMS_GrayLevelFiltering - - CMakeProjectManager.CMakeRunConfiguration.STMS_GrayLevelFiltering - 3768 - false - true - false - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 18 - - - Version - 18 - - diff --git a/Src/CMakeLists.txt b/Src/CMakeLists.txt index 8b1ae25..b5c695a 100755 --- a/Src/CMakeLists.txt +++ b/Src/CMakeLists.txt @@ -29,3 +29,6 @@ target_link_libraries(STMS_GrayLevelFiltering ${ITK_LIBRARIES}) install(TARGETS STMS_GrayLevelFiltering DESTINATION bin) +add_executable(STMS_generateClosestMap STMS_generateClosestMap.cxx) +target_link_libraries(STMS_generateClosestMap ${ITK_LIBRARIES}) +install(TARGETS STMS_generateClosestMap DESTINATION bin) diff --git a/Src/STMS_generateClosestMap.cxx b/Src/STMS_generateClosestMap.cxx new file mode 100644 index 0000000..a8b8eef --- /dev/null +++ b/Src/STMS_generateClosestMap.cxx @@ -0,0 +1,122 @@ +#include +#include +#include +#include +#include +#include + +#include + +typedef std::vector< float > TimeSerieType; +typedef std::pair< unsigned int , float> DistanceIndexType; + +#pragma omp declare simd +float distsq(float x, float y) +{ + return (x-y) * (x-y); +} + +#pragma omp declare simd +bool DistancePairComp (const DistanceIndexType &x, const DistanceIndexType &y) +{ + return x.second < y.second; +} + +float EuclidianDistanceTimeSerie( const TimeSerieType &a, const TimeSerieType &b) +{ + float dist = 0; + unsigned int n = a.size(); + #pragma omp parallel for simd reduction(+:dist) schedule(simd:static, 5) + for (unsigned int i=0; i ClassSeries; +std::vector< unsigned int > ClassLabels; +std::vector< unsigned int > ClassEffectif; + +unsigned int K = 5; +unsigned int N = 2; +std::cout << "argv[1] : csv filemane " << std::endl; +std::cout << "argv[2] : K the number of neigboors" << std::endl; +std::cout << "argv[3] : N the minimum effectif of classes "<< std::endl; + +/////////////////////////////////////////////////////////////// +/// \brief reading csv file +/////////////////////////////////////////////////////////////// +std::ifstream ifs; +ifs.open (argv[1], std::ifstream::in); +std::cout << "argv[1] : csv filemane = " << argv[1] << std::endl; + + +std::string ID_str, Effectif_str, Value_str; + +std::string::size_type sz = 0; // use to identify the endline +while( ifs.good() ) +{ + if(sz == 0) std::getline(ifs, ID_str, ','); +// std::cout << ID_str << " " ; + ClassLabels.push_back( std::stof(ID_str) ); + + std::getline(ifs, Effectif_str, ','); + // std::cout << Effectif_str << " " ; + ClassEffectif.push_back( std::stof(Effectif_str) ); + + TimeSerieType tmpSerie; + int a; + do + { + std::getline(ifs, Value_str, ','); +// std::cout << Value_str << " " ; + a= Value_str.find('\n'); + tmpSerie.push_back( std::stof(Value_str, &sz) ); + } while( a == -1 ); +// std::cout << std::endl; + ClassSeries.push_back( tmpSerie ); + ID_str = Value_str.substr(sz+1); // " 2\n12" -> "12" +} +ifs.close(); +/////////////////////////////////////////////////////////////// + + +std::cout << " starting analysis " << std::endl; +/////////////////////////////////////////////////////////////// +/// \brief compute k nearest neigboor of each entry (effectif > N) +/////////////////////////////////////////////////////////////// +for(unsigned int i=0; i N ) // if class's cardinal is > to N + { + std::vector< DistanceIndexType > DistanceToSeries(ClassSeries.size()) ; // we will use the current sample to validate (so sizes are the same) + unsigned int n= ClassSeries.size(); + #pragma omp parallel for shared(DistanceToSeries) + for(unsigned int j=0; j