Example #1
0
        void analyze_combined()
        {
            try
            {
                TheSys.showError("=================================");
                string fileName        = DateTime.Now.ToString("MMdd_HHmmss");
                string path_saveFolder = path_root + "Combine " + fileName + (" (FS)");
                //
                double partition_range = TheTool.getDouble(txtPartitionRange);
                path_saveFolder += "(p=" + partition_range + ")";
                //
                TheTool.Folder_CreateIfMissing(path_saveFolder); path_saveFolder = path_saveFolder + @"\";
                //-----------------
                motionModel_reset();
                summary_total.Clear();
                summary_total.Add(fileName + " Combination");
                if (checkSegment.IsChecked == false)
                {
                    string             path_raw_centered = path_saveFolder + "Combine " + fileName + " (center" + TheUKI.getCenterTechqName(centerTechnique) + ").csv";
                    List <UKI_DataRaw> list_raw_concat   = new List <UKI_DataRaw>();
                    foreach (Instance inst in container.list_inst)
                    {
                        list_raw_concat.AddRange(inst.getDataRaw(true));
                        summary_total.Add("- " + inst.name);
                    }
                    //----- Load Data >> Build Centered Data ---------------------------------------
                    DataTable dt_raw_center = UKI_ThePreprocessor.getDatatable_centered(list_raw_concat, checkExtraFeature.IsChecked.Value);//raw
                    TheTool.export_dataTable_to_CSV(path_raw_centered, dt_raw_center);
                    //----- Process  ---------------------------------------
                    //DataTable dt_raw = CSVReader.ReadCSVFile(path_raw_centered, true);//raw
                    //
                    DataTable dt_threshold_pose1 = dt_raw_center.Clone();
                    dt_threshold_pose1.Rows.Add(dt_raw_center.Rows[0].ItemArray);
                    DataTable dt_threshold_pose2 = dt_raw_center.Clone();
                    dt_threshold_pose2.Rows.Add(dt_raw_center.Rows[dt_raw_center.Rows.Count - 1].ItemArray);

                    analyze_Table(dt_raw_center, path_saveFolder, dt_threshold_pose1, dt_threshold_pose2);
                    motionModel_exportAll(path_saveFolder, "");
                    motionModel_evaluationAll();
                    TheSys.showError(summary_total);
                    TheTool.exportFile(summary_total, path_saveFolder + "result (combined).txt", false);
                }
                else
                {
                    //Assumption: all given Instance has same class
                    List <DataTable> dt_centered_concat_list = new List <DataTable>();
                    List <DataTable> dt_threshold            = new List <DataTable>();
                    UKI_ThePreprocessor.preprocess_CombinedSegmented(container.list_inst, checkExtraFeature.IsChecked.Value, ref dt_centered_concat_list, ref dt_threshold);
                    //-----
                    summary_total.AddRange(UKI_ThePreprocessor.temp_summary);
                    int[] mode  = UKI_ThePreprocessor.temp_mode;
                    int   p_key = 0;
                    foreach (DataTable dt_1pose in dt_centered_concat_list)
                    {
                        //1 Posture of Motion
                        int    p_id                = p_key + 1;
                        string subFolder           = "Pose " + p_id;
                        string path_saveFolder_sub = path_saveFolder + @"\" + subFolder;
                        TheTool.Folder_CreateIfMissing(path_saveFolder_sub);
                        path_saveFolder_sub += @"\";
                        string path_raw_centered = path_saveFolder_sub + " Combine " + fileName + " (center" + TheUKI.getCenterTechqName(centerTechnique) + ").csv";
                        TheTool.export_dataTable_to_CSV(path_raw_centered, dt_1pose);
                        //----------
                        summary_total.Add("");
                        summary_total.Add("Pose" + p_id + ":");
                        foreach (Instance inst in container.list_inst)
                        {
                            if (inst.keyPose.Count() == mode[0])
                            {
                                summary_total.Add("- " + inst.keyPose[p_key][0]
                                                  + "-" + inst.keyPose[p_key][1]
                                                  + " of " + inst.name);
                            }
                        }
                        analyze_Table(dt_1pose, path_saveFolder_sub, dt_threshold[0], dt_threshold[p_id]);
                        p_key++;
                    }
                    motionModel_exportAll(path_saveFolder, " (segmented combined)");
                    motionModel_evaluationAll();
                    summary_total.Add("");
                    //
                    List <string> threshold_data = TheTool.dataTable_CombineShuffle_getListString(dt_threshold);
                    TheTool.exportFile(threshold_data, path_saveFolder + "threshold.csv", false);
                    //
                    TheTool.exportFile(summary_total, path_saveFolder + "result (segmented combined).txt", false);
                    TheSys.showError(summary_total);
                }
            }
            catch (Exception ex)
            {
                TheSys.showError("Combined Analysis : " + ex.ToString());
            }
        }