Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab6;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Arrays;
- import java.util.Scanner;
- public class EEG {
- private double[][] data;
- private double[] avgData;
- private double amplitude;
- private double latency;
- private int width, height;
- public EEG(String filename) {
- readData(filename);
- }
- // delete sout firstLineData
- public void readData(String filename) {
- try{
- Scanner input = new Scanner(new File(filename));
- String firstLine = input.nextLine();
- String[] firstLineData = firstLine.split(",");
- System.out.println(firstLineData[0] + " " + firstLineData[1]);
- this.height = Integer.parseInt(firstLineData[1]); //transpose the data so its data[897][500]
- this.width = Integer.parseInt(firstLineData[0]);
- this.data = new double[width][height];
- for(int i=0; i<height; i++) {
- String nextLine = input.nextLine();
- String[] nextLineData = nextLine.split(",");
- for(int j=0; j<width; j++) {
- double temp = Double.parseDouble(nextLineData[j]);
- this.data[i][j] = temp;
- }
- }
- } catch (FileNotFoundException e) {
- System.out.println("File not found.");
- }
- }
- //not needed
- /*public void printData() {
- for(int i=0; i<width; i++) {
- for(int j=0; j<height; j++) {
- System.out.print(this.data[i][j] + " ");
- }
- System.out.println();
- }
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement