com.pixelmed.scpecg

## Class SCPECG

- java.lang.Object
- - com.pixelmed.scpecg.SCPECG

    public class SCPECG
    extends java.lang.Object

A class to encapsulate an entire SCP-ECG object.

Typically this class would be used to read an SCP-ECG object from a file, and to do something with the decompressed waveform data values. For example:

    try {
            BinaryInputStream i = new BinaryInputStream(new BufferedInputStream(new FileInputStream(arg[0])),false);        // always little endian
            SCPECG scpecg = new SCPECG(i,verbose);
            short[][] data = scpecg.getDecompressedRhythmData();
            BinaryOutputStream o = new BinaryOutputStream(new BufferedOutputStream(new FileOutputStream(arg[1])),false);    // little endian
            // write interleaved raw little endian data
            int numberOfChannels = data.length;
            int nSamplesPerChannel = data[0].length;        // assume all the same
            for (int sample=0; sample<nSamplesPerChannel; ++sample) {
                    for (int lead=0;lead<numberOfChannels; ++lead) {
                            o.writeSigned16(data[lead][sample]);
                    }
            }
            o.close();
    }
    catch (Exception e) {
            e.printStackTrace(System.err);
    }

One might want to dump the entire contents of the instance as a string, as follows:

    System.err.print(scpecg);

or perhaps to display the contents as a JTree:

    ApplicationFrame af = new ApplicationFrame();
    JScrollPane scrollPane = new JScrollPane();
    SCPTreeBrowser browser = new SCPTreeBrowser(scpecg,scrollPane);
    af.getContentPane().add(scrollPane);
    af.pack();
    af.setVisible(true);

### Constructor Summary

Constructors
Constructor and Description
`SCPECG(BinaryInputStream i, boolean verbose)` Read an SCP-ECG object from an input stream.

### Method Summary

Methods
`short[][]` `getDecompressedReferenceBeatData()` Get the decompressed reference beat data.
`short[][]` `getDecompressedRhythmData()` Get the decompressed rhythm data.
`int` `getDecompressedRhythmDataSampleTimeInterval()` Get the sample time interval that will be applicable to the decompressed rhythm data.
`java.lang.String[]` `getLeadNames()` Get the names of the leads from Section 3.
`int[]` `getLeadNumbers()` Get the numbers of the leads from Section 3.
`java.lang.String` `getNamedField(java.lang.String fieldName)` Get the concatenated values of all the occurences of a named field from Section 1 as a `String`.
`int` `getNumberOfLeads()` Get the number of leads.
`long[]` `getNumbersOfSamples()` Get the number of samples for each lead.
`Section1` `getSection1()`
`Section10` `getSection10()`
`Section8Or11` `getSection11()`
`Section2` `getSection2()`
`Section3` `getSection3()`
`Section4` `getSection4()`
`Section5Or6` `getSection5()`
`Section5Or6` `getSection6()`
`Section7` `getSection7()`
`Section8Or11` `getSection8()`
`java.util.Iterator` `getSectionIterator()` Get an `Iterator` over all the sections.
`static void` `main(java.lang.String[] arg)` For testing.
`java.lang.String` `toString()` Dump the object as a `String`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### SCPECG

    public SCPECG(BinaryInputStream i,
          boolean verbose)
           throws java.io.IOException

Read an SCP-ECG object from an input stream.

As errors are encountered, they are described on `stderr`.

The sections are also validated as they are read, and Section 0 is validated against the other sections.

Parameters:
  `i` - the input stream (should have been opened as little endian)
  `verbose` - if true, then the progress of the read is described
Throws:
  `java.io.IOException`

### Method Detail

#### getDecompressedRhythmData

    public short[][] getDecompressedRhythmData()

Get the decompressed rhythm data.

This includes undecimating and adding in any reference beat.

Note that interpolation and filtering are NOT applied in the current implementation.

Returns:
  arrays of samples for each lead

#### getDecompressedReferenceBeatData

    public short[][] getDecompressedReferenceBeatData()

Get the decompressed reference beat data.

Returns:
  arrays of samples for each lead

#### toString

    public java.lang.String toString()

Dump the object as a `String`.

Overrides:
  `toString` in class `java.lang.Object`
Returns:
  the object as a `String`

#### getSection1

    public Section1 getSection1()

#### getSection2

    public Section2 getSection2()

#### getSection3

    public Section3 getSection3()

#### getSection4

    public Section4 getSection4()

#### getSection5

    public Section5Or6 getSection5()

#### getSection6

    public Section5Or6 getSection6()

#### getSection7

    public Section7 getSection7()

#### getSection8

    public Section8Or11 getSection8()

#### getSection10

    public Section10 getSection10()

#### getSection11

    public Section8Or11 getSection11()

#### getNumberOfLeads

    public int getNumberOfLeads()

Get the number of leads.

Returns:
  the number of leads

#### getNumbersOfSamples

    public long[] getNumbersOfSamples()

Get the number of samples for each lead.

Returns:
  an array of the number of samples for each lead

#### getDecompressedRhythmDataSampleTimeInterval

    public int getDecompressedRhythmDataSampleTimeInterval()

Get the sample time interval that will be applicable to the decompressed rhythm data.

Note that this is the value after undecimation if the rhythm data was decimated; specifically in such cases it will be the sample time interval of the reference beat.

Returns:
  the sample time interval in microSeconds

#### getNamedField

    public java.lang.String getNamedField(java.lang.String fieldName)

Get the concatenated values of all the occurences of a named field from Section 1 as a `String`.

Returns:
  the values as a `String`

#### getLeadNames

    public java.lang.String[] getLeadNames()

Get the names of the leads from Section 3.

Returns:
  the names of the leads

#### getLeadNumbers

    public int[] getLeadNumbers()

Get the numbers of the leads from Section 3.

Returns:
  the numbers of the leads (using the codes in the standard and encoded in the data)

#### getSectionIterator

    public java.util.Iterator getSectionIterator()

Get an `Iterator` over all the sections.

Returns:
  an iterator of objects of type `Section`

#### main

    public static void main(java.lang.String[] arg)

For testing.

Parameters:
  `arg` - one, two or three arguments, the input filename, optionally a output raw data filename, and optionally a text dump filename