/// <summary>
        /// Read and parse data from a .mat file.
        /// </summary>
        /// <param name="stream">Input stream.</param>
        /// <returns>Parsed contents of the file.</returns>
        protected override IMatFile ReadDataFromStream(Stream stream)
        {
            var matFileReader = new MatFileReader(stream);
            var matFile       = matFileReader.Read();

            return(matFile);
        }
        public (List <double> time, List <double> gyrox, List <double> gyroy, List <double> gyroz, List <double> accx, List <double> accy, List <double> accz) Load()
        {
            IMatFile matFile;

            using (var fileStream = new System.IO.FileStream(_FileName, System.IO.FileMode.Open))
            {
                var reader = new MatFileReader(fileStream);
                matFile = reader.Read();
            }

            IArray itime = (((matFile["data"].Value as IStructureArray)["raw", 0] as IStructureArray)["imu0", 0] as IStructureArray)["time", 0];

            IArray igyrox = (((matFile["data"].Value as IStructureArray)["raw", 0] as IStructureArray)["imu0", 0] as IStructureArray)["gyrox", 0];
            IArray igyroy = (((matFile["data"].Value as IStructureArray)["raw", 0] as IStructureArray)["imu0", 0] as IStructureArray)["gyroy", 0];
            IArray igyroz = (((matFile["data"].Value as IStructureArray)["raw", 0] as IStructureArray)["imu0", 0] as IStructureArray)["gyroz", 0];

            IArray iaccx = (((matFile["data"].Value as IStructureArray)["raw", 0] as IStructureArray)["imu0", 0] as IStructureArray)["accx", 0];
            IArray iaccy = (((matFile["data"].Value as IStructureArray)["raw", 0] as IStructureArray)["imu0", 0] as IStructureArray)["accy", 0];
            IArray iaccz = (((matFile["data"].Value as IStructureArray)["raw", 0] as IStructureArray)["imu0", 0] as IStructureArray)["accz", 0];

            List <double> time = itime.ConvertToDoubleArray().ToList();

            List <double> gyrox = igyrox.ConvertToDoubleArray().ToList();
            List <double> gyroy = igyroy.ConvertToDoubleArray().ToList();
            List <double> gyroz = igyroz.ConvertToDoubleArray().ToList();

            List <double> accx = iaccx.ConvertToDoubleArray().ToList();
            List <double> accy = iaccy.ConvertToDoubleArray().ToList();
            List <double> accz = iaccz.ConvertToDoubleArray().ToList();

            return(time, gyrox, gyroy, gyroz, accx, accy, accz);
        }
Esempio n. 3
0
 public void Open()
 {
     using (var fileStream = new FileStream(_FileName, FileMode.Open))
     {
         var reader = new MatFileReader(fileStream);
         _MatFile = reader.Read();
     }
 }
 private void CompareTestDataWithWritingOptions(
     IMatFile expected,
     IMatFile actual,
     MatFileWriterOptions?maybeOptions)
 {
     byte[] buffer;
     using (var stream = new MemoryStream())
     {
         var writer = maybeOptions is MatFileWriterOptions options
             ? new MatFileWriter(stream, options)
             : new MatFileWriter(stream);
         writer.Write(actual);
         buffer = stream.ToArray();
     }
     using (var stream = new MemoryStream(buffer))
     {
         var reader     = new MatFileReader(stream);
         var actualRead = reader.Read();
         CompareMatFiles(expected, actualRead);
     }
 }