private void AppendSample(ElectrodeFrame[] samples, int length) { float[,] vReData = new float[length, samples[0].ComplexVoltageMatrix.Length]; float[,] vImData = new float[length, samples[0].ComplexVoltageMatrix.Length]; float[,] cReData = new float[length, samples[0].ComplexCurrentMatrix.Length]; float[,] cImData = new float[length, samples[0].ComplexCurrentMatrix.Length]; ulong[,] saturationData = new ulong[length, 1]; long[,] timestampData = new long[length, 1]; // Write packet id, kalpa clock only if exist => value != Uint64.MaxValue (default value) ulong[,] packetIdData = samples[0].PacketId == UInt64.MaxValue ? null : new ulong[length, 1]; ulong[,] kalpaClockData = samples[0].KalpaClock == UInt64.MaxValue ? null : new ulong[length, 1]; for (var i = 0; i < length; i++) { ElectrodeFrame electrodeFrame = samples[i]; for (int j = 0; j < electrodeFrame.ComplexVoltageMatrix.Length; j++) { vReData[i, j] = electrodeFrame.ComplexVoltageMatrix[j].Re; vImData[i, j] = electrodeFrame.ComplexVoltageMatrix[j].Im; } for (int j = 0; j < electrodeFrame.ComplexCurrentMatrix.Length; j++) { cReData[i, j] = electrodeFrame.ComplexCurrentMatrix[j].Re; cImData[i, j] = electrodeFrame.ComplexCurrentMatrix[j].Im; } saturationData[i, 0] = electrodeFrame.SaturationMask; timestampData[i, 0] = electrodeFrame.timestamp; if (packetIdData != null) { packetIdData[i, 0] = electrodeFrame.PacketId; } if (kalpaClockData != null) { kalpaClockData[i, 0] = electrodeFrame.KalpaClock; } } VoltagesReal.AppendOrCreateDataset(vReData); VoltagesIm.AppendOrCreateDataset(vImData); CurrentsReal.AppendOrCreateDataset(cReData); CurrentsIm.AppendOrCreateDataset(cImData); Saturation.AppendOrCreateDataset(saturationData); Timestamps.AppendOrCreateDataset(timestampData); if (packetIdData != null) { PacketIds.AppendOrCreateDataset(packetIdData); } if (kalpaClockData != null) { KalpaClocks.AppendOrCreateDataset(kalpaClockData); } }
private void AppendSample(ECGFrame[] samples, int length) { var sampleForSize = samples.First(); double[,] unFilteredData = new double[length * sampleForSize.FrameData.First().Count, sampleForSize.FrameData.Count]; double[,] filteredData = new double[length * sampleForSize.FilteredFrameData.First().Count, sampleForSize.FilteredFrameData.Count]; long[,] timestampData = new long[length * sampleForSize.FilteredFrameData.First().Count, 1]; ulong[,] packetIdData = samples[0].PacketId == UInt64.MaxValue ? null : new ulong[length, 1]; ulong[,] kalpaClockData = samples[0].KalpaClock == UInt64.MaxValue ? null : new ulong[length, 1]; for (var i = 0; i < length; i++) { var dataSample = samples[i]; var rows = dataSample.FrameData.First().Count; var columns = dataSample.FrameData.Count; for (int rowIndex = 0; rowIndex < rows; rowIndex++) { for (var columnIndex = 0; columnIndex < columns; columnIndex++) { unFilteredData[i * rows + rowIndex, columnIndex] = dataSample.FrameData[columnIndex][rowIndex]; } } rows = dataSample.FilteredFrameData.First().Count; columns = dataSample.FilteredFrameData.Count; for (int rowIndex = 0; rowIndex < rows; rowIndex++) { for (var columnIndex = 0; columnIndex < columns; columnIndex++) { filteredData[i * rows + rowIndex, columnIndex] = dataSample.FilteredFrameData[columnIndex][rowIndex]; } } int rowsTimestamps = dataSample.FilteredFrameData.First().Count; for (int k = 0; k < rowsTimestamps; k++) { var date = dataSample.Timestamp; if (SamplingRate > 0) { date = (long)(dataSample.Timestamp + k * 1000.0 / SamplingRate); } timestampData[i * rowsTimestamps + k, 0] = date; EndDateTime = date; } if (packetIdData != null) { packetIdData[i, 0] = dataSample.PacketId; } if (kalpaClockData != null) { kalpaClockData[i, 0] = dataSample.KalpaClock; } } UnFiltered.AppendOrCreateDataset(unFilteredData); Filtered.AppendOrCreateDataset(filteredData); Timestamps.AppendOrCreateDataset(timestampData); if (packetIdData != null) { PacketIds.AppendOrCreateDataset(packetIdData); } }