示例#1
0
        int ang_techq    = TheUKI.angTechq_SC_HC;    //center to SC-HC
        public void exportFile(string fileName, string folderPrefix, Boolean posture_extraction, Boolean useGlobalMinMax, Boolean showDialog)
        {
            try
            {
                if (data_raw.Count() > 0)
                {
                    List <string> temp;
                    string        folderPath         = TheURL.url_saveFolder + folderPrefix + fileName;
                    string        folderPath_oth     = folderPath + @"\oth";
                    string        path_raw           = folderPath + @"\" + fileName + ".csv";
                    string        path_center_suffix = " (center" + TheUKI.getCenterTechqName(center_techq) + ")";
                    string        path_raw_centered  = folderPath + @"\" + fileName + path_center_suffix + ".csv";
                    string        path_bp            = folderPath + @"\" + fileName + " Atomic.csv";
                    string        path_log           = folderPath_oth + @"\" + fileName + " Log.csv";
                    string        path_plus          = folderPath_oth + @"\" + fileName + " Plus.csv";
                    string        path_movement      = folderPath_oth + @"\" + fileName + " Movement.csv";
                    string        path_GlobalMM      = TheURL.url_saveFolder + "[MinMax].csv";//in case Global
                    if (useGlobalMinMax == false)
                    {
                        path_GlobalMM = "";
                    }
                    TheTool.Folder_CreateIfMissing(folderPath);
                    TheTool.Folder_CreateIfMissing(folderPath_oth);
                    //--- RAW -------------------------------------------
                    TheUKI.saveData_Raw(path_raw, data_raw);
                    //--- RAW center to HipC ----------------------------
                    List <UKI_DataRaw> data_raw_centered = TheUKI.raw_centerBodyJoint(data_raw, center_techq);
                    TheUKI.saveData_Raw_centered(path_raw_centered, data_raw_centered, center_techq);
                    //--- Basic Posture ---------------------------------
                    List <string> data_bp_final = new List <string>();
                    data_bp_final.Add(TheUKI.data_bp_header());
                    data_bp_final.AddRange(TheUKI.getBasicPostureData(data_bp));
                    TheTool.exportCSV_orTXT(path_bp, data_bp_final, false);
                    //--- Log : Additional Data (Non-Analysis) ----------
                    List <string> data_log_final = new List <string>();
                    data_log_final.Add(TheUKI.data_log_header);
                    data_log_final.AddRange(data_log);
                    TheTool.exportCSV_orTXT(path_log, data_log_final, false);
                    //----- Movement Data ---------------------------
                    List <UKI_DataMovement> data_movement_adjusted = TheUKI.adjustMovementData(data_movement);
                    if (!posture_extraction)
                    {
                        TheUKI.exportData_Movement(data_movement_adjusted, path_movement, false);
                    }
                    //--- Additional Data For Analysis -----------------------
                    List <string> data_addition_full = TheUKI.createData_Additional(data_raw, data_raw_centered, data_add_01, center_techq);
                    temp = new List <string>();//data_addition_full with header
                    temp.Add(TheUKI.data_addition_full_header);
                    temp.AddRange(data_addition_full);
                    TheTool.exportCSV_orTXT(path_plus, temp, false);

                    //===================================================================
                    if (posture_extraction)
                    {
                        string folderPath_PE      = folderPath + @"\PosExtract";
                        string folderPath_Sparse  = folderPath + @"\Sparse";
                        string folderPath_Entropy = folderPath + @"\Entropy";
                        //
                        string path_note          = folderPath + @"\note.txt";
                        string path_plus_normal   = folderPath_oth + @"\" + fileName + " Plus Normal.csv";
                        string path_plus_discrete = folderPath_oth + @"\" + fileName + " Plus Descrete.csv";
                        string path_ang           = folderPath_oth + @"\" + fileName + " ANG(" + TheUKI.getAngTechqName(ang_techq) + ").csv";
                        //
                        string path_PE_raw_centered_extract = folderPath_PE + @"\" + fileName + " Extracted-01" + path_center_suffix + ".csv";
                        string path_PE_addition_extract     = folderPath_PE + @"\" + fileName + " Extracted-02 Plus.csv";
                        //
                        string path_raw_en           = folderPath_Entropy + @"\" + fileName + " Entropy-01 RAW.csv";
                        string path_raw_centered_en  = folderPath_Entropy + @"\" + fileName + " Entropy-02 RAW" + path_center_suffix + ".csv";
                        string path_plus_normal_en   = folderPath_Entropy + @"\" + fileName + " Entropy-03 Plus Normal.csv";
                        string path_plus_discrete_en = folderPath_Entropy + @"\" + fileName + " Entropy-04 Plus Discrete.csv";
                        string path_ang_en           = folderPath_Entropy + @"\" + fileName + " Entropy-11 ANG.csv";
                        string path_dist_en          = folderPath_Entropy + @"\" + fileName + " Entropy-12 Dist.csv";
                        //
                        TheTool.Folder_CreateIfMissing(folderPath_PE);
                        TheTool.Folder_CreateIfMissing(folderPath_Sparse);
                        TheTool.Folder_CreateIfMissing(folderPath_Entropy);
                        //--- Normalize & Discretize -------------------------
                        DataTable data_addition_normalized = ThePosExtract.getNormalizedTable(path_plus, path_GlobalMM, true);
                        TheTool.export_dataTable_to_CSV(path_plus_normal, data_addition_normalized);
                        DataTable data_discritized = TheTool.dataTable_discritize10Partition(data_addition_normalized);
                        TheTool.export_dataTable_to_CSV(path_plus_discrete, data_discritized);
                        //----- Angle Data ----------------------------------------
                        List <UKI_DataAngular> data_ang = TheUKI.calAngle_fromRaw(data_raw, ang_techq);
                        TheUKI.saveData_Ang(path_ang, data_ang);//save original
                        //----- (Prepare Key List) ----------------------
                        List <int[]> list_keyPose_Range = new List <int[]>();
                        list_keyPose_Range.AddRange(ThePosExtract.extractKeyPose_MyAlgo(data_movement_adjusted));
                        List <int> list_keyPose_ID = new List <int>();
                        list_keyPose_ID.AddRange(ThePosExtract.getKeyPose_ID_StartEnd(list_keyPose_Range));
                        //----- Movement Data ---------------------------
                        TheUKI.exportData_Movement(data_movement_adjusted, path_movement, true);//must be after "calMinimaMaxima"
                        //----- Basic Posture Analysis ------------------
                        List <UKI_Data_BasicPose> data_bp_selected = TheTool.list_SelectRow(data_bp, list_keyPose_ID);
                        ThePosExtract.BasicPostureAnalysis(data_bp_selected, true);
                        TheTool.exportFile(ThePosExtract.log_BasicPostureAnalysis, path_note, false);
                        TheSys.showError(ThePosExtract.log_BasicPostureAnalysis);
                        //----- Raw Extracted Data ----------------------------
                        List <UKI_DataRaw> data_raw_selected = TheTool.list_SelectRow(data_raw_centered, list_keyPose_ID);
                        TheUKI.saveData_Raw_centered(path_PE_raw_centered_extract, data_raw_selected, center_techq);
                        //----- Addition Extracted Data ----------------------------
                        List <String> data_addition_selected = TheTool.list_SelectRow(data_addition_full, list_keyPose_ID);
                        temp = new List <string>();//data_addition_full with header
                        temp.Add(TheUKI.data_addition_full_header);
                        temp.AddRange(data_addition_selected);
                        TheTool.exportCSV_orTXT(path_PE_addition_extract, temp, false);
                        //======= Feature Selecting Using Delta Analysis ==========================
                        ThePosExtract.ChangeAnalysis(path_PE_addition_extract, path_GlobalMM, folderPath_PE, fileName);
                        //======= Feature Selecting Using MI ======================================

                        //======= Entropy =========================================================
                        ThePosExtract.UKI_CalEntropy_Angle(path_ang_en, path_ang, list_keyPose_Range);
                        ThePosExtract.UKI_CalEntropy_Eu(path_dist_en, path_raw, list_keyPose_Range);
                        ThePosExtract.UKI_CalEntropy_1By1(path_raw_en, path_raw, list_keyPose_Range);
                        ThePosExtract.UKI_CalEntropy_1By1(path_raw_centered_en, path_raw_centered, list_keyPose_Range);
                        ThePosExtract.UKI_CalEntropy_1By1(path_plus_normal_en, path_plus_normal, list_keyPose_Range);
                        ThePosExtract.UKI_CalEntropy_1By1(path_plus_discrete_en, path_plus_discrete, list_keyPose_Range);
                        //======= Oth =========================================================
                        //---- Paper : Sparse ---------------------
                        CalSparse_XYZ.calSparse(data_raw_selected, folderPath_Sparse + @"\", fileName);//cal & export
                    }
                    if (showDialog)
                    {
                        System.Windows.MessageBox.Show(@"Save to '" + folderPath + "'", "Export Data");
                    }
                }
            }
            catch (Exception ex) { TheSys.showError("Export: " + ex); }
        }