Beispiel #1
0
        public EDFHeader ReadHeader()
        {
            EDFHeader h = new EDFHeader();

            this.BaseStream.Seek(0, SeekOrigin.Begin);

            //------ Fixed length header part --------
            h.Version.Value               = ReadAscii(HeaderItems.Version);
            h.PatientID.Value             = ReadAscii(HeaderItems.PatientID);
            h.RecordID.Value              = ReadAscii(HeaderItems.RecordID);
            h.StartDate.Value             = ReadAscii(HeaderItems.StartDate);
            h.StartTime.Value             = ReadAscii(HeaderItems.StartTime);
            h.NumberOfBytesInHeader.Value = ReadInt16(HeaderItems.NumberOfBytesInHeader);
            h.Reserved.Value              = ReadAscii(HeaderItems.Reserved);
            h.NumberOfDataRecords.Value   = ReadInt16(HeaderItems.NumberOfDataRecords);
            h.DurationOfDataRecord.Value  = ReadInt16(HeaderItems.DurationOfDataRecord);
            h.NumberOfSignals.Value       = ReadInt16(HeaderItems.NumberOfSignals);

            //------ Variable length header part --------
            int ns = h.NumberOfSignals.Value;

            h.Labels.Value                      = ReadMultipleAscii(HeaderItems.Label, ns);
            h.TransducerType.Value              = ReadMultipleAscii(HeaderItems.TransducerType, ns);
            h.PhysicalDimension.Value           = ReadMultipleAscii(HeaderItems.PhysicalDimension, ns);
            h.PhysicalMinimum.Value             = ReadMultipleDouble(HeaderItems.PhysicalMinimum, ns);
            h.PhysicalMaximum.Value             = ReadMultipleDouble(HeaderItems.PhysicalMaximum, ns);
            h.DigitalMinimum.Value              = ReadMultipleInt(HeaderItems.DigitalMinimum, ns);
            h.DigitalMaximum.Value              = ReadMultipleInt(HeaderItems.DigitalMaximum, ns);
            h.Prefiltering.Value                = ReadMultipleAscii(HeaderItems.Prefiltering, ns);
            h.NumberOfSamplesInDataRecord.Value = ReadMultipleInt(HeaderItems.NumberOfSamplesInDataRecord, ns);
            h.SignalsReserved.Value             = ReadMultipleAscii(HeaderItems.SignalsReserved, ns);

            return(h);
        }
Beispiel #2
0
        public EDFSignal[] ReadSignals()
        {
            EDFHeader header = ReadHeader();

            EDFSignal[] signals = new EDFSignal[header.NumberOfSignals.Value];

            for (int i = 0; i < signals.Length; i++)
            {
                signals[i]                       = new EDFSignal();
                signals[i].Label.Value           = header.Labels.Value[i];
                signals[i].NumberOfSamples.Value = header.NumberOfSamplesInDataRecord.Value[i];
            }

            //Read the signal sample values
            int readPosition = header.NumberOfBytesInHeader.Value;

            for (int i = 0; i < signals.Length; i++)
            {
                signals[i].Samples = ReadSignalSamples(readPosition, signals[i].NumberOfSamples.Value);
                readPosition      += signals[i].Samples.Length * 2; //2 bytes per integer.
            }

            return(signals);
        }