private List <string> GetFile(bool titleType, ref string path, ref string dataFile, int outputs)
        {
            //Reset paths.
            path = null; dataFile = null;

            if (outputs == 0)
            {
                MessageBox.Show("You must have at least 1 output", "Output Error.");
                return(null);
            }

            //Get csv path.
            openFileDialog1.Filter = "csv files (*.csv)|*.csv";
            DialogResult dialogResult = openFileDialog1.ShowDialog();

            //Exit function if file selection was cancelled.
            if (dialogResult == DialogResult.Cancel)
            {
                output.Text += "Cancelling File Selection. . .\n";
                return(null);
            }

            //Check the file is .csv format.
            if (!openFileDialog1.SafeFileName.EndsWith(".csv"))
            {
                MessageBox.Show("The file you have selected is not in the correct format (.csv)", "File Access Error");
                return(null);
            }

            //Setup paths from file.
            dataFile = openFileDialog1.SafeFileName;
            path     = openFileDialog1.FileName.Replace(openFileDialog1.SafeFileName, "");
            var sourceFile = new FileInfo(openFileDialog1.FileName);

            if (!Directory.Exists(openFileDialog1.FileName.Replace(openFileDialog1.SafeFileName, "normal")))
            {
                Directory.CreateDirectory(openFileDialog1.FileName.Replace(openFileDialog1.SafeFileName, "normal"));
            }

            var normalFile = new FileInfo(openFileDialog1.FileName.Replace(openFileDialog1.SafeFileName, @"normal\" + openFileDialog1.SafeFileName.Replace(".csv", "Normal.csv")));

            output.Text += "Loading File: " + dataFile + ". . .\n";

            return(Data.Normalise(sourceFile, normalFile, path, dataFile, outputs, titleType));
        }
        /// <summary> Predict network outputs. </summary>
        private void NetworkBtn_Click(object sender, EventArgs e)
        {
            if (networkSaveDataList.Count == 0)
            {
                MessageBox.Show("You must select a network file first. If you do not have one you can create one in the network creater window", "No Network File Error");
                return;
            }

            notIncluded.Clear();

            //Setup network.
            NeuralNetwork network;

            //Switch to set network type based on type stored in json file.
            switch (networkSaveDataList[selectedNetwork].NetworkType)
            {
            case "EncogNeuralNetwork":
            {
                network = new EncogNeuralNetwork();
                break;
            }

            case "EncogDeepNeuralNetwork":
            {
                network = new EncogDeepNeuralNetwork();
                break;
            }

            case "AccordNeuralNetwork":
            {
                network = new AccordNeuralNetwork();
                break;
            }

            default:
            {
                network = new AccordDeepNeuralNetwork();
                break;
            }
            }

            //Initialize variables
            info = new Data();
            string dataFile = networkSaveDataList[selectedNetwork].CsvFile;
            string path     = networkSaveDataList[selectedNetwork].Path;

            double[][] answers;

            if (!Directory.Exists(path + "normal"))
            {
                MessageBox.Show("You have no \"normal\" folder, please ensure that you are selecting the same csv as the one used in network creation. It may also be the case that you have moved the working directory of the csv file without also moving its dependant folders.", "File Access Error");
                return;
            }

            if (!Directory.Exists(path + "networks"))
            {
                MessageBox.Show("You have no \"networks\" folder, please ensure that you have created at least one network. It may also be the case that you have moved the working directory of the csv file without also moving its dependant folders.", "File Access Error");
                return;
            }

            //Load analyst from earlier.
            analyst = new EncogAnalyst();
            analyst.Load(new FileInfo(path + @"normal\normalizationData" + dataFile.Replace(".csv", ".ega")));

            FileInfo sourcefile = new FileInfo(path + dataFile);

            AnalystNormalizeCSV norm = new AnalystNormalizeCSV();

            //norm.InputHeadings = networkSaveDataList[selectedNetwork].Headings.ToArray();
            network.Load(networkSaveDataList[selectedNetwork].NetworkFile);

            List <bool> vb = new List <bool>();

            foreach (string heading in networkSaveDataList[selectedNetwork].InputHeadings)
            {
                vb.Add(false);
            }

            notIncluded.Add(vb);

            if (!csvBox.Checked)
            {
                string outString = "";

                for (int i = 0; i < items[selectedNetwork].Count; i++)
                {
                    notIncluded[0][i] = string.IsNullOrWhiteSpace(items[selectedNetwork][i]);

                    outString += items[selectedNetwork][i] + ",";
                }

                outString += ",";

                outString.Remove(outString.Length - 1);

                if (File.Exists(path + dataFile.Replace(".csv", "Temp.csv")))
                {
                    File.Delete(path + dataFile.Replace(".csv", "Temp.csv"));
                }

                using (var sw = new StreamWriter(path + dataFile.Replace(".csv", "Temp.csv"), true))
                {
                    for (int i = 0; i < networkSaveDataList[selectedNetwork].InputHeadings.Count; i++)
                    {
                        sw.Write(networkSaveDataList[selectedNetwork].InputHeadings[i] + ",");
                    }

                    for (int i = 0; i < networkSaveDataList[selectedNetwork].OutputHeadings.Count; i++)
                    {
                        if (i != networkSaveDataList[selectedNetwork].OutputHeadings.Count - 1)
                        {
                            sw.Write(networkSaveDataList[selectedNetwork].OutputHeadings[i] + ",");
                        }
                        else
                        {
                            sw.Write(networkSaveDataList[selectedNetwork].OutputHeadings[i]);
                        }
                    }

                    sw.WriteLine();
                    sw.WriteLine(outString);
                }

                var inputFile     = new FileInfo(path + dataFile.Replace(".csv", "Temp.csv"));
                var inputFileNorm = new FileInfo(path + @"normal\" + dataFile.Replace(".csv", "TempNormal.csv"));
                norm.Analyze(inputFile, true, CSVFormat.English, analyst);

                try
                {
                    norm.Normalize(inputFileNorm);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n\nThe inputs you have entered do not correctly follow the current normalisation data. This may because you " +
                                    "have entered values above or below the currently stored highs and lows for numbers. It is also possible you have " +
                                    "entered a textual word that has not been used before. Finally it is possible that you are have not used the correct " +
                                    "case for a word as they are case sensitive.", "Normalisation Failure");
                    return;
                }

                info    = info.ReturnInfo(path + @"normal\" + dataFile.Replace(".csv", "TempNormal.csv"), networkSaveDataList[selectedNetwork].OutputHeadings, 0, true);
                answers = Data.CreateArray <double>(1, info.OutputNumber);
            }
            else
            {
                //Reset paths.
                path = null; dataFile = null;

                //Get csv path.
                openFileDialog1.Filter = "csv files (*.csv)|*.csv";
                DialogResult dialogResult = openFileDialog1.ShowDialog();

                //Exit function if file selection was cancelled.
                if (dialogResult == DialogResult.Cancel)
                {
                    output.Text += "Cancelling File Selection. . .\n";
                    return;
                }

                //Check the file is .csv format.
                if (!openFileDialog1.SafeFileName.EndsWith(".csv"))
                {
                    MessageBox.Show("The file you have selected is not in the correct format (.csv)", "File Access Error");
                    return;
                }

                //Setup paths from file.
                dataFile = openFileDialog1.SafeFileName;
                path     = openFileDialog1.FileName.Replace(openFileDialog1.SafeFileName, "");
                var sourceFile = new FileInfo(openFileDialog1.FileName);
                var normalFile = new FileInfo(openFileDialog1.FileName.Replace(openFileDialog1.SafeFileName, @"normal\" + openFileDialog1.SafeFileName.Replace(".csv", "Normal.csv")));

                output.Text += "Loading File: " + dataFile + ". . .\n";

                Data.Normalise(sourceFile, normalFile, path, dataFile, networkSaveDataList[selectedNetwork].OutputHeadings.Count, false);

                norm.Analyze(sourceFile, true, CSVFormat.English, analyst);

                try
                {
                    norm.Normalize(normalFile);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n\nThe inputs you have entered do not correctly follow the current normalisation data. This may because you " +
                                    "have entered values above or below the currently stored highs and lows for numbers. It is also possible you have " +
                                    "entered a textual word that has not been used before. Finally it is possible that you are have not used the correct" +
                                    "case for a word as they are case sensitive.", "Normalisation Failure");
                    return;
                }

                info = info.ReturnInfo(path + @"normal\" + dataFile.Replace(".csv", "Normal.csv"), networkSaveDataList[selectedNetwork].OutputHeadings, 0, true);

                answers = Data.CreateArray <double>(info.InputData.Length, networkSaveDataList[selectedNetwork].OutputHeadings.Count);

                //Get length of CSV, Inputs and Outputs.
                using (var reader = new StreamReader(openFileDialog1.FileName))
                {
                    reader.ReadLine();
                    int lineNo = 0;

                    while (!reader.EndOfStream)
                    {
                        var line   = reader.ReadLine();
                        var values = line.Split(',');

                        if (lineNo > 0)
                        {
                            notIncluded.Add(new List <bool>(vb));
                        }

                        for (int i = 0; i < notIncluded[0].Count; i++)
                        {
                            notIncluded[lineNo][i] = string.IsNullOrWhiteSpace(values[i]);
                        }

                        lineNo++;
                    }
                }
            }

            //Compute network predictions.
            for (int i = 0; i < answers.Length; i++)
            {
                //Switch to set network type based on type stored in json file.
                switch (networkSaveDataList[selectedNetwork].NetworkType)
                {
                case "AccordNeuralNetwork":
                {
                    answers[i] = network.AccordNetwork.Compute(info.InputData[i]);
                    break;
                }

                case "AccordDeepNeuralNetwork":
                {
                    answers[i] = network.DeepAccordNetwork.Compute(info.InputData[i]);
                    break;
                }

                default:
                {
                    network.EncogNetwork.Compute(info.InputData[i], answers[i]);
                    break;
                }
                }
            }

            info.Prediction = answers;

            //Output answers to text box.
            output.Text += network.Display(answers, analyst, networkSaveDataList[selectedNetwork].OutputHeadings, path + @"normal\" + dataFile.Replace(".csv", "Normal.csv"));
        }