Skip to content

Commit e4b4113

Browse files
committed
Adding labels to CSV header
1 parent c49aafc commit e4b4113

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

java/br/unb/biologiaanimal/edf/EDF.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public HashMap getRecords()
7575

7676
/**
7777
* Get the labels contained in this EDF file.
78+
* @return the trimmed labels from the header
7879
*/
7980
public String[] getLabels()
8081
{
@@ -178,14 +179,13 @@ public void toCsv(String filePath)
178179
HashMap header = reader.getHeader();
179180
int limit = 0;
180181

181-
// TODO Generate header
182182
writer.write("title:" + (String) header.get("recording") + ";");
183183
writer.write("recorded:" + (String) header.get("startdate") + " " +
184184
(String) header.get("starttime") + ";");
185-
// TODO Get sampling
186185
writer.write("sampling:" + Integer.toString(getSamplingRate()) + ";");
187186
writer.write("subject:" + (String) header.get("patient") + ";");
188187
// TODO Get labels
188+
writer.write("labels:" + EDFUtil.joinStrings(getLabels(), "\t") + ";");
189189
writer.write("chan:" + (String) header.get("numbersignals") + ";");
190190
// TODO Get units
191191
writer.write("units:uV\n");

java/br/unb/biologiaanimal/edf/EDFUtil.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ public static String[] separateString(String inlet, int numChops)
2424
return outlet;
2525
}
2626

27+
/**
28+
* Creates a new string uniting strings with a separator in the middle
29+
* @param inlet the String array to be united
30+
* @param sep the String that will appear in the middle of the other strings
31+
* @return the united string
32+
*/
33+
public static String joinStrings(String[] inlet, String sep)
34+
{
35+
String outlet = inlet[0];
36+
37+
for (int i = 1; i < inlet.length; i++)
38+
{
39+
outlet += sep + inlet[i];
40+
}
41+
42+
return outlet;
43+
}
44+
2745
/**
2846
* Inserts a byte in a byte array
2947
* @param box the array to contain the new byte

target/edf.jar

187 Bytes
Binary file not shown.

test/br/unb/biologiaanimal/test/Run.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public static void main(String[] args) {
1414
{
1515
System.out.println("- " + chopped[i]);
1616
}
17+
System.out.println("Can unite string? " + (randomString.equals(EDFUtil.joinStrings(chopped, ""))));
1718
System.out.println("25 celsius to fahrenheit:");
1819
System.out.println(" Ans: " + EDFUtil.map(25, 100, 0, 212, 32) + "F");
1920
System.out.println("--- # Reading EDF file");

0 commit comments

Comments
 (0)