-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from TheD2Lab/testing
Analysis DGM tests and more
- Loading branch information
Showing
9 changed files
with
128 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/test/java/com/github/thed2lab/analysis/AnalysisTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.github.thed2lab.analysis; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.util.Iterator; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import com.opencsv.CSVReader; | ||
|
||
public class AnalysisTest { | ||
|
||
private final double PRECISION = 0.000000001; // allowable floating point error | ||
private final String ALL_GAZE_PATH = "./src/test/resources/test_all_gaze.csv"; | ||
private final DataEntry ALL_GAZE = FileHandler.buildDataEntry(new File(ALL_GAZE_PATH)); | ||
private final String ALL_FIXATION_PATH = "./src/test/resources/filtered_by_fixation.csv"; | ||
private final DataEntry ALL_FIXATION = FileHandler.buildDataEntry(new File(ALL_FIXATION_PATH)); | ||
|
||
@Test | ||
public void testGenerateResults_wholeScreenData() { | ||
List<String[]> expected = new LinkedList<>(); | ||
try ( | ||
FileReader fileReader = new FileReader("./src/test/resources/test_DGMs.csv"); | ||
CSVReader csvReader = new CSVReader(fileReader); | ||
) { | ||
expected.add(csvReader.readNext()); | ||
expected.add(csvReader.readNext()); | ||
} catch (Exception e) { | ||
fail("Could not read file"); | ||
} | ||
|
||
List<List<String>> actual = Analysis.generateResults(ALL_GAZE, ALL_FIXATION); | ||
assertEquals(2, actual.size()); // headers and 1 row of data | ||
|
||
// check headers | ||
Iterator<String> actualIter = actual.get(0).iterator(); | ||
for (String expValue : expected.get(0)) { | ||
assertEquals(expValue.trim(), actualIter.next()); | ||
} | ||
|
||
// check values | ||
actualIter = actual.get(1).iterator(); | ||
for (String expValue : expected.get(1)) { | ||
var bloop = actualIter.next(); | ||
if (!isEqual(expValue, bloop)) { | ||
fail(); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Checks if two numbers saved as strings are equal, within an allowable amount of floating point error. | ||
* @param double1 first number to compare | ||
* @param double2 second number to compare | ||
* @return if the two numbers are equal | ||
*/ | ||
private boolean isEqual(String double1, String double2) { | ||
return Math.abs(Double.parseDouble(double1) - Double.parseDouble(double2)) < PRECISION; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
total_number_of_fixations,sum_of_all_fixation_duration_s,mean_fixation_duration_s,median_fixation_duration_s,stdev_of_fixation_durations_s,min_fixation_duration_s,max_fixation_duration_s,total_number_of_saccades,sum_of_all_saccade_lengths,mean_saccade_length,median_saccade_length,stdev_of_saccade_lengths,min_saccade_length,max_saccade_length,sum_of_all_saccade_durations,mean_saccade_duration,median_saccade_duration,stdev_of_saccade_durations,min_saccade_duration,max_saccade_duration,scanpath_duration,fixation_to_saccade_ratio,average_peak_saccade_velocity,sum_of_all_absolute_degrees,mean_absolute_degree,median_absolute_degree,stdev_of_absolute_degrees,min_absolute_degree,max_absolute_degree,sum_of_all_relative_degrees,mean_relative_degree,median_relative_degree,stdev_of_relative_degrees,min_relative_degree,max_relative_degree,convex_hull_area,stationary_entropy,transition_entropy,total_number_of_blinks,average_blink_rate_per_minute,total_number_of_valid_recordings,average_pupil_size_of_left_eye,average_pupil_size_of_right_eye,average_pupil_size_of_both_eyes,total_number_of_l_mouse_clicks | ||
20,4.76282,0.238141,0.16748,0.152435548482145,0.08044,0.66125,16,2530.86608142828,158.179130089267,119.346748844631,106.3517507880460,20.7083517064975,349.414837212159,0.19091,0.011931875,0.00671,0.0094964149156,0.00598,0.03028,4.95373,24.9479859619718,179.969192732729,395.580356733446,24.7237722958404,15.4757613889113,22.7925364835493,2.9677710724739,81.4803527675405,1618.85106640278,124.527005107906,123.297847178851,26.0218488445123,79.5855258680609,163.151086040417,168928.54539264,0.3482253728572,0.2295311788752,3,27.5902238640109,822,4.5235607299270,4.3886963746959,4.4561285523114,2 |