Ejemplo n.º 1
0
        public static void testSVMWrapperPackage() //rafal parsal
        {
            libSVM_Problem Problem = libSVM_Problem.Load("../../../LibSVMFull/testSvmWrapper/data/train.dat");

            GuiPreferences.Instance.setLog("trainnig data loaded");
            //GuiPreferences.Instance.setLog("trainnig data loaded";
            Problem.Save("../../../LibSVMFull/testSvmWrapper/data/train_saved");
            GuiPreferences.Instance.setLog("training data saved");
            libSVM_Parameter Parameter = new libSVM_Parameter();
            libSVM_Extension svm       = new libSVM_Extension();

            Parameter.svm_type    = SVM_TYPE.C_SVC;
            Parameter.kernel_type = KERNEL_TYPE.LINEAR;

            svm = new libSVM_Extension();
            svm.Train(Problem, Parameter);
            libSVM_Problem Test = libSVM_Problem.Load("../../../LibSVMFull/testSvmWrapper/data/test.dat");

            svm.GetAccuracyFromTest(Test);
            double accuracy = svm.output.accuracy;

            GuiPreferences.Instance.setLog("Predicted accuracy from testing set: " + accuracy.ToString());
            svm.Dispose();


            svm = new libSVM_Extension();
            //svm.TrainAuto(10, Problem, Parameter, libSVM_Grid.C(), libSVM_Grid.gamma(), libSVM_Grid.p(), libSVM_Grid.nu(), libSVM_Grid.coef0(), libSVM_Grid.degree());
            libSVM_Grid grid = new libSVM_Grid();

            accuracy = svm.TrainAuto(10, Problem, Parameter, grid, null, null, null, null, null);
            GuiPreferences.Instance.setLog("Predicted accuracy from 10 cross fold validation: " + accuracy.ToString());
            svm.Save("../../../LibSVMFull/testSvmWrapper/data/model_file");
            GuiPreferences.Instance.setLog("10 cfv best model saved");
            svm.Dispose();
        }
Ejemplo n.º 2
0
        /////////////////////////////////////////////////////////////////////////////////////////
        private void initVariables()
        {
            udp = new UDP();

            udpsim = new UDPSim();

            //holds min max values which prevents the min from being zeroed out after the threhold filter.
            MinMax    = new List <Dictionary <int, MinMax> >();
            BrainMean = new List <string>();                                                              //checking for global drift before and after IG filter
            TrainingEventStartLocationsPerTR = new Dictionary <int, Dictionary <string, List <int> > >(); //run, tr, list of indices
            validMaxBrainAverage             = 1000;
            corruptedVector = false;
            PipeServerName  = "OBL"; //in here the client uses OBL pipe to communicate to the server, if a communication is needed from server to client, i believe we should use another pipe - check this.
            PipeClientName  = "Unity";

            pipeServer = new NamedPipeServer(PipeServerName);
            pipeClient = new NamedPipeClient(PipeServerName);

            cumulativeTR        = 0;
            nextEvent           = 0;
            nextTRinEvent       = 0;
            currentRunningEvent = "";

            // DirMonitor variables
            //===========================
            masterPath        = "/My_Dropbox/VERE/MRI_data/Nir/";
            pathName          = masterPath + "NIR_run1_rtp/";
            dicomMasterPath   = masterPath + "NIR_run1_dcm_master/";
            dicomTbvWatchPath = masterPath + "NIR_run1_dcm_watch/";

            //configuration - 1b - protocol
            events         = new Events(new List <IntIntStr>());
            protocolLoaded = false;

            //configuration - 3 - import, radio buttons binary file types
            svmLoaded       = false;
            ProblemOriginal = new libSVM_ExtendedProblem();
            svmWrapper      = new libSVM_Extension();

            deleteFiles = new string[]
            {
                "TrainSet.libsvm",
                "TrainSet_3th_vectors.libsvm",
                "TrainSet_3th_vectors_scale_paramCS.libsvm",
                "TrainSet_3th_vectors_scaledCS.libsvm",
                "TrainSet_3th_vectors_scaledCS.libsvm.arff",
                "TrainSet_3th_vectors_scaledCS_filteredIG.arff",
                "TrainSet_3th_vectors_scaledCS_filteredIG.model",
                "TrainSet_3th_vectors_scaledCS_filteredIG_indices.xml",
                "TrainSet_4th_vectors.libsvm",
                "TrainSet_4th_vectors_scale_paramCS.libsvm",
                "TrainSet_4th_vectors_scaledCS.libsvm",
                "TrainSet_4th_vectors_scaledCS.libsvm.arff",
                "TrainSet_5th_vectors.libsvm",
                "TrainSet_5th_vectors_scale_paramCS.libsvm",
                "TrainSet_5th_vectors_scaledCS.libsvm",
                "TrainSet_5th_vectors_scaledCS.libsvm.arff",
                "TrainSet_6th_vectors.libsvm",
                "TrainSet_6th_vectors_scale_paramCS.libsvm",
                "TrainSet_6th_vectors_scaledCS.libsvm",
                "TrainSet_6th_vectors_scaledCS.libsvm.arff"
            };

            //memory capcity test, each array up to 2gb!!

            /*try
             * {
             *  int[] ar = new int[1];
             *  int[] ar2 = new int[1];
             *  for (int i = 1; i < 100000; i++)
             *  {
             *      Array.Resize(ref ar, ar.Length + 100000000);
             *      Array.Resize(ref ar2, ar.Length + 100000000);
             *      long l = PublicMethods.getRam();
             *  }
             * }
             * catch (Exception e)
             * {
             *  long l = PublicMethods.getRam();
             *  string s = e.ToString();
             * }*/


            classification = new List <string[]>();

            //7-plots
            try
            {
                //caused problems in mri's pc
                //glm = new MatlabGLM();
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    "Warning: Matlab Initialization failed, please install matlab 2011a 64bit! (it is SAFE to CONTINUE!)" + e.ToString(),
                    "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information,
                    MessageBoxDefaultButton.Button2);
            }
        }