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) { slf4jlogger.error("",e); }
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 and Description |
---|
SCPECG(BinaryInputStream i,
boolean verbose)
Read an SCP-ECG object from an input stream.
|
Modifier and Type | Method and Description |
---|---|
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 . |
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.
i
- the input stream (should have been opened as little endian)verbose
- if true, then the progress of the read is describedjava.io.IOException
public short[][] getDecompressedReferenceBeatData()
Get the decompressed reference beat data.
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.
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.
public java.lang.String[] getLeadNames()
Get the names of the leads from Section 3.
public int[] getLeadNumbers()
Get the numbers of the leads from Section 3.
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
.
String
public int getNumberOfLeads()
Get the number of leads.
public long[] getNumbersOfSamples()
Get the number of samples for each lead.
public Section1 getSection1()
public Section10 getSection10()
public Section8Or11 getSection11()
public Section2 getSection2()
public Section3 getSection3()
public Section4 getSection4()
public Section5Or6 getSection5()
public Section5Or6 getSection6()
public Section7 getSection7()
public Section8Or11 getSection8()
public java.util.Iterator getSectionIterator()
Get an Iterator
over all the sections.
Section
public static void main(java.lang.String[] arg)
For testing.
arg
- one, two or three arguments, the input filename, optionally a output raw data filename, and optionally a text dump filenamepublic java.lang.String toString()
Dump the object as a String
.
toString
in class java.lang.Object
String