public override int LoadIndex(string FileName)
        {
            this.RawFileName = FileName;

            RawFile  = new MassSpecDataReader();
            MSReader = RawFile;
            MSReader.OpenDataFile(FileName);
            Spectra = (int)(MSReader.MSScanFileInformation.TotalScansPresent);

            bool PosMode = false, NegMode = false;

            if (Spectra <= 0)
            {
                return(0);
            }

            int i, LastFull = 0, Total = 0;

            //there will be fake [0] spectra with no data and fake last spectra with no data
            //it is made to make any chromatogram start and end with zero
            IndexDir   = new int[Spectra + 2];
            IndexRev   = new int[Spectra + 2];
            RawSpectra = new RawSpectrum[Spectra + 2];
            for (int j = 0; j <= Spectra + 1; j++)
            {
                RawSpectra[j] = new RawSpectrum();
            }
            TimeStamps = new double[Spectra + 2];
            TimeCoefs  = new double[Spectra + 2];

            LowRT  = 0.0;
            HighRT = 0.0;

            int Progress = 0;

            for (i = 1; i <= Spectra; i++)
            {
                if ((int)(100.0 * ((double)i / (double)Spectra)) > Progress)//report progress
                {
                    Progress = (int)(100.0 * ((double)i / (double)Spectra));
                    RepProgress?.Invoke(Progress);
                }

                IMSScanRecord ScanRecord = MSReader.GetScanRecord(i - 1);

                if (ScanRecord.MSScanType == MSScanType.Scan && ScanRecord.MSLevel == MSLevel.MS && ScanRecord.CollisionEnergy == 0.0)          //if spectra is a FULL MS

                {
                    PosMode |= ScanRecord.IonPolarity == IonPolarity.Positive;
                    NegMode |= ScanRecord.IonPolarity == IonPolarity.Negative;

                    RawSpectra[i].RT   = ScanRecord.RetentionTime;
                    TimeStamps[i]      = RawSpectra[i].RT - RawSpectra[LastFull].RT;
                    RawSpectra[i].Scan = i;

                    IndexDir[LastFull] = i;
                    IndexRev[i]        = LastFull;

                    LastFull = i;

                    Total++;
                }
            }
            IndexDir[LastFull]    = Spectra + 1;
            IndexDir[Spectra + 1] = -1;
            IndexRev[Spectra + 1] = LastFull;

            TotalRT          = RawSpectra[LastFull].RT;
            AverageTimeStamp = TotalRT / Total;

            //time interval bias coefficients
            for (i = IndexDir[0]; IndexDir[i] != -1; i = IndexDir[i])
            {
                TimeCoefs[i] = (TimeStamps[i] + TimeStamps[IndexDir[i]]) / (2.0 * AverageTimeStamp);
            }
            TimeCoefs[i] = 1.0;

            //Fake spectra number 0 has to have reasonable RT
            double FRT = RawSpectra[IndexDir[0]].RT;
            double SRT = RawSpectra[IndexDir[IndexDir[0]]].RT;

            RawSpectra[0].RT = Math.Max(0, FRT - (SRT - FRT));
            //Last spectra also has to have reasonable RT
            FRT = RawSpectra[LastFull].RT;
            SRT = RawSpectra[IndexRev[LastFull]].RT;
            RawSpectra[Spectra + 1].RT = FRT + (FRT - SRT);

            RawSpectra[0].Data           = new MZData[0];
            RawSpectra[Spectra + 1].Data = new MZData[0];

            PeakFilter = new MsdrPeakFilter();
            PeakFilter.AbsoluteThreshold = 5.0;

            if (PosMode && !NegMode)
            {
                Mode = 1;
            }
            if (!PosMode && NegMode)
            {
                Mode = -1;
            }

            return(Spectra);
        }
        public MSFileReader_XRawfile RawFile; //instance of LC-MS run

        public override int LoadIndex(string FileName)
        {
            this.RawFileName = FileName;

            RawFile = new MSFileReader_XRawfile();
            RawFile.Open(FileName);
            RawFile.SetCurrentController(0, 1);
            Spectra = 0;
            RawFile.GetNumSpectra(ref Spectra);

            if (Spectra <= 0) //if there are no spectra available
            {
                return(0);
            }

            int i, LastFull = 0, Total = 0;

            //there will be fake [0] spectra with no data and fake last spectra with no data
            //it is made to make any chromatogram start and end with zero
            IndexDir   = new int[Spectra + 2];
            IndexRev   = new int[Spectra + 2];
            RawSpectra = new RawSpectrum[Spectra + 2];
            for (int j = 0; j <= Spectra + 1; j++)
            {
                RawSpectra[j] = new RawSpectrum();
            }

            TimeStamps = new double[Spectra + 2];
            TimeCoefs  = new double[Spectra + 2];

            string Filter = null;
            bool   PosMode = false, NegMode = false;

            LowRT  = 0.0;
            HighRT = 0.0;

            int Progress = 0;

            for (i = 1; i <= Spectra; i++)
            {
                if ((int)(100.0 * ((double)i / (double)Spectra)) > Progress) //report progress
                {
                    Progress = (int)(100.0 * ((double)i / (double)Spectra));
                    RepProgress?.Invoke(Progress);
                }

                RawFile.GetFilterForScanNum(i, ref Filter);                                          //to reveal spectra properties we parse filter string

                if (Filter.Contains(" Full ") && Filter.Contains(" ms ") && Filter.Contains("FTMS")) //is a FULL MS

                {
                    PosMode |= Filter.Contains(" + ");
                    NegMode |= Filter.Contains(" - ");

                    RawFile.RTFromScanNum(i, ref RawSpectra[i].RT);
                    RawSpectra[i].Scan = i;
                    TimeStamps[i]      = RawSpectra[i].RT - RawSpectra[LastFull].RT;

                    IndexDir[LastFull] = i;
                    IndexRev[i]        = LastFull;

                    LastFull = i;

                    Total++;
                }
                Filter = null;
            }
            IndexDir[LastFull]    = Spectra + 1; //boundaries of navigation arrays
            IndexDir[Spectra + 1] = -1;
            IndexRev[Spectra + 1] = LastFull;

            TotalRT          = RawSpectra[LastFull].RT;
            AverageTimeStamp = TotalRT / Total;

            //time interval bias coefficients
            for (i = IndexDir[0]; IndexDir[i] != -1; i = IndexDir[i])
            {
                TimeCoefs[i] = (TimeStamps[i] + TimeStamps[IndexDir[i]]) / (2.0 * AverageTimeStamp);
            }
            TimeCoefs[i] = 1.0;
            //Fake spectra number 0 has to have reasonable RT
            double FRT = RawSpectra[IndexDir[0]].RT;            //First full spectra RT
            double SRT = RawSpectra[IndexDir[IndexDir[0]]].RT;  //Second full spectra RT

            RawSpectra[0].RT = Math.Max(0, FRT - (SRT - FRT));  // 0 or make the same distance like between 1-st and 2-nd spectra
            //Last spectra also has to have reasonable RT
            FRT = RawSpectra[LastFull].RT;                      //the same for last spectra
            SRT = RawSpectra[IndexRev[LastFull]].RT;
            RawSpectra[Spectra + 1].RT   = FRT + (FRT - SRT);
            RawSpectra[Spectra + 1].Scan = RawSpectra[Spectra].Scan + 1;

            RawSpectra[0].Data           = new MZData[0];
            RawSpectra[Spectra + 1].Data = new MZData[0];

            if (PosMode && !NegMode)
            {
                Mode = 1;
            }
            if (!PosMode && NegMode)
            {
                Mode = -1;
            }

            return(Spectra);
        }