-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathECGFile.java
More file actions
112 lines (92 loc) · 2.41 KB
/
Copy pathECGFile.java
File metadata and controls
112 lines (92 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import java.io.EOFException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
/**
* ECGFile - opens and reads a file with ECG data
* @author Dakota Williams
*/
public abstract class ECGFile {
public abstract int read(String fileName, double start, double length,
ArrayList<AbstractMap.SimpleEntry<Double, ArrayList<Double>>> points) throws IOException;
public abstract double getFileLength(String fileName) throws IOException;
public abstract double getSampleInterval();
public abstract int[][] getLayout();
public abstract String[] getTitles();
public abstract String getExtension();
public int getNorth(int index) {
int[][] leads = this.getLayout();
int currX = leads[index][1];
int currY = leads[index][0];
int ret = -1;
for(int i = 0; i < leads.length; i++) {
if(leads[i][1] == currX && leads[i][0] == currY-1) {
ret = i;
}
}
return ret;
}
public int getSouth(int index) {
int[][] leads = this.getLayout();
int currX = leads[index][1];
int currY = leads[index][0];
int ret = -1;
for(int i = 0; i < leads.length; i++) {
if(leads[i][1] == currX && leads[i][0] == currY+1) {
ret = i;
}
}
return ret;
}
public int getEast(int index) {
int[][] leads = this.getLayout();
int currX = leads[index][1];
int currY = leads[index][0];
int ret = -1;
int min = Integer.MAX_VALUE;
int max = -1;
int minInd = Integer.MAX_VALUE;
for(int i = 0; i < leads.length; i++) {
if(leads[i][0] == currY && leads[i][1] == currX+1) {
ret = i;
}
if(leads[i][0] == currY && leads[i][1] < min) {
min = leads[i][1];
minInd = i;
}
if(leads[i][0] == currY && leads[i][1] > max) {
max = leads[i][1];
}
}
if(currX == max) { //wrap around
return minInd;
}
return ret;
}
public int getWest(int index) {
int[][] leads = this.getLayout();
int currX = leads[index][1];
int currY = leads[index][0];
int ret = -1;
int max = -1;
int maxInd = -1;
for(int i = 0; i < leads.length; i++) {
if(leads[i][0] == currY && leads[i][1] == currX-1) {
ret = i;
}
if(leads[i][0] == currY && leads[i][1] > max) {
max = leads[i][1];
maxInd = i;
}
}
if(currX == 0) { //wrap around
return maxInd;
}
return ret;
}
}