Esempio n. 1
0
 //path_data : row are selected, 2 columns to be cropped ("time,id")
 //path_minmax : minmax, no crop is needed, leave "" for local MM
 //path_folder & filename : path to save
 //Auto Crop Column Name
 public static void ChangeAnalysis(string path_data_selected, string path_GlobalMM, string path_folder, string filename)
 {
     try
     {
         path_PE_localMM        = path_folder + @"\[MinMax(local)].csv";//in case Local
         path_PE_vRank          = path_folder + @"\" + filename + " F-Rank.csv";
         path_PE_normal_extract = path_folder + @"\" + filename + " Extracted-03 Normalized.csv";
         DataTable dt_temp = CSVReader.ReadCSVFile(path_data_selected, true); //have 2 unused col
         DataTable dt_data = TheTool.dataTable_cropCol(dt_temp, 2, 0);        //only analyzed column
         DataTable dt_mm   = null;                                            //Datatable of MinMax
         //--- Prepare MinMax Table
         Boolean useGlobalMM = true;
         if (path_GlobalMM == "" || File.Exists(path_GlobalMM) == false)
         {
             useGlobalMM = false;
         }
         else
         {
             try { dt_mm = CSVReader.ReadCSVFile(path_GlobalMM, true); }
             catch (Exception ex) { TheSys.showError(ex); useGlobalMM = false; }
         }
         if (useGlobalMM == false)
         {
             //build MM table by local data
             dt_mm = TheTool.dataTable_getMaxMinTable(dt_data);//generate MM table
             TheTool.export_dataTable_to_CSV(path_PE_localMM, dt_mm);
         }
         try
         {
             DataTable dt_normal = TheTool.dataTable_MinMaxNormalization(dt_data, dt_mm);
             //--- Cal Change -------------------------------------
             List <String> data_raw_change     = ThePosExtract.process_calChange(dt_data, false, false);
             List <String> data_normal_change  = ThePosExtract.process_calChange(dt_normal, true, true);
             List <String> data_ChangeAnalysis = new List <String>();
             data_ChangeAnalysis.Add("RAW");
             data_ChangeAnalysis.AddRange(data_raw_change);
             data_ChangeAnalysis.Add("");
             data_ChangeAnalysis.Add("");
             data_ChangeAnalysis.Add("NORMALIZED F-RANKING");
             data_ChangeAnalysis.AddRange(data_normal_change);
             TheTool.exportCSV_orTXT(path_PE_vRank, data_ChangeAnalysis, false);
             //--- Normalize Table : re-added column before save
             dt_normal.Columns.Add("time", typeof(string)).SetOrdinal(0);
             dt_normal.Columns.Add("id", typeof(string)).SetOrdinal(0);
             int r = 0;
             foreach (DataRow row in dt_normal.Rows)
             {
                 row[0] = dt_temp.Rows[r][0].ToString();
                 row[1] = dt_temp.Rows[r][1].ToString();
                 r++;
             }
             TheTool.export_dataTable_to_CSV(path_PE_normal_extract, dt_normal);
         }
         catch (Exception ex) { TheSys.showError("Normalize: " + ex.ToString()); }
     }
     catch (Exception ex) { TheSys.showError("Change Analysis: " + ex.ToString()); }
 }
Esempio n. 2
0
 //Data contain "time,id"
 public static DataTable getNormalizedTable(string path_data_selected, string path_GlobalMM, Boolean Crop2Col)
 {
     try
     {
         DataTable dt_temp = CSVReader.ReadCSVFile(path_data_selected, true);//have 2 unused col
         DataTable dt_data = dt_temp;
         if (Crop2Col)
         {
             dt_data = TheTool.dataTable_cropCol(dt_temp, 2, 0); //only analyzed column
         }
         DataTable dt_mm = null;                                 //Datatable of MinMax
         //--- Prepare MinMax Table
         Boolean useGlobalMM = true;
         if (path_GlobalMM == "" || File.Exists(path_GlobalMM) == false)
         {
             useGlobalMM = false;
         }
         else
         {
             try { dt_mm = CSVReader.ReadCSVFile(path_GlobalMM, true); }
             catch (Exception ex) { TheSys.showError(ex); useGlobalMM = false; }
         }
         if (useGlobalMM == false)
         {
             //build MM table by local data
             dt_mm = TheTool.dataTable_getMaxMinTable(dt_data);//generate MM table
         }
         DataTable dt_normal = TheTool.dataTable_MinMaxNormalization(dt_data, dt_mm);
         //--- Normalize Table : re-added column before save
         if (Crop2Col)
         {
             dt_normal.Columns.Add("time", typeof(string)).SetOrdinal(0);
             dt_normal.Columns.Add("id", typeof(string)).SetOrdinal(0);
             int r = 0;
             foreach (DataRow row in dt_normal.Rows)
             {
                 row[0] = dt_temp.Rows[r][0].ToString();
                 row[1] = dt_temp.Rows[r][1].ToString();
                 r++;
             }
         }
         return(dt_normal);
     }
     catch (Exception ex) { TheSys.showError(ex); return(new DataTable()); }
 }
Esempio n. 3
0
        //****************************************************************************************

        public static List <string> calEntropy_MotionData(String path_loadFrom, List <int[]> keyPostureRange
                                                          , int degit, int col_combine_range)
        {
            List <string> final_output = new List <string>();//Data

            try
            {
                DataTable dt = CSVReader.ReadCSVFile(path_loadFrom, true); //prepare Data
                dt = TheTool.dataTable_cropCol(dt, 2, 0);                  //del first 2 Col
                TheTool.dataTable_roundValue(dt, degit);                   // eliminate decimal
                int start = -1; int end = 0;
                foreach (int[] keyPose in keyPostureRange)
                {
                    DataTable dt_sub = TheTool.dataTable_selectRow_byIndex(dt, start, end);
                    final_output.Add(start + " to " + end + "," + calEntrophy_1Action(dt_sub, col_combine_range));
                }
            }
            catch (Exception ex) { TheSys.showError(ex); }
            return(final_output);
        }