Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. package lab6;
  2.  
  3.  
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.util.Arrays;
  7. import java.util.Scanner;
  8.  
  9. public class EEG {
  10. private double[][] data;
  11. private double[] avgData;
  12. private double amplitude;
  13. private double latency;
  14. private int width, height;
  15.  
  16.  
  17. public EEG(String filename) {
  18. readData(filename);
  19. }
  20. // delete sout firstLineData
  21. public void readData(String filename) {
  22. try{
  23. Scanner input = new Scanner(new File(filename));
  24. String firstLine = input.nextLine();
  25. String[] firstLineData = firstLine.split(",");
  26. System.out.println(firstLineData[0] + " " + firstLineData[1]);
  27. this.height = Integer.parseInt(firstLineData[1]); //transpose the data so its data[897][500]
  28. this.width = Integer.parseInt(firstLineData[0]);
  29. this.data = new double[width][height];
  30. for(int i=0; i<height; i++) {
  31. String nextLine = input.nextLine();
  32. String[] nextLineData = nextLine.split(",");
  33. for(int j=0; j<width; j++) {
  34. double temp = Double.parseDouble(nextLineData[j]);
  35. this.data[i][j] = temp;
  36. }
  37. }
  38. } catch (FileNotFoundException e) {
  39. System.out.println("File not found.");
  40.  
  41. }
  42.  
  43. }
  44. //not needed
  45. /*public void printData() {
  46. for(int i=0; i<width; i++) {
  47. for(int j=0; j<height; j++) {
  48. System.out.print(this.data[i][j] + " ");
  49. }
  50. System.out.println();
  51. }
  52. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement