init
This commit is contained in:
+78
@@ -0,0 +1,78 @@
|
||||
#######################################################################
|
||||
# Software License Agreement (AGPL-3 License)
|
||||
#
|
||||
# OpenViBE SDK Test Software
|
||||
# Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015
|
||||
# Copyright (C) Inria, 2015-2017,V1.0
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License version 3,
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program.
|
||||
# If not, see <http://www.gnu.org/licenses/>.
|
||||
#######################################################################
|
||||
import sys, os, re
|
||||
|
||||
#arg 1 repository of the openvibe logs
|
||||
#arg 2 keyword to search in the log file to get the line where the measure was
|
||||
#arg 3 Threshold, the measure should be lower
|
||||
if len(sys.argv) < 4 :
|
||||
print('incorrect args')
|
||||
sys.exit(101)
|
||||
openvibeLogs=sys.argv[1]
|
||||
keyWord=sys.argv[2]
|
||||
threshold=float(sys.argv[3])
|
||||
|
||||
def selectLineContainingWord (filename, searchingWord):
|
||||
""" Function to select the line containing the keyword
|
||||
the exception 103 is raised if file is missing
|
||||
"""
|
||||
try:
|
||||
spaced_word = ' %s ' % searchingWord
|
||||
with open(filename) as file :
|
||||
for line in file:
|
||||
if spaced_word in line :
|
||||
return line
|
||||
|
||||
#Exception raised if the log file wasn't created
|
||||
except FileNotFoundError:
|
||||
print('missing %s'%file)
|
||||
sys.exit(103)
|
||||
|
||||
try:
|
||||
#Call the selectLineContainingWord function with the input parameter
|
||||
workingLine=selectLineContainingWord(openvibeLogs,keyWord)
|
||||
|
||||
getPercentageValue = float(re.search('accuracy\s+is\s+(\d+(?:\.\d+))\%', workingLine).group(1))
|
||||
|
||||
#check if the measure is under the threshold excpected
|
||||
if getPercentageValue >= threshold:
|
||||
print ('%s higher or equal to threshold %s'%(getPercentageValue,threshold))
|
||||
|
||||
else:
|
||||
print ('%s lower to threshold %s'%(getPercentageValue,threshold))
|
||||
print ('reference line in the log %s' %workingLine)
|
||||
sys.exit(102)
|
||||
|
||||
#exception raised if the keyword wasn't in the log file
|
||||
except AttributeError:
|
||||
print ('Missing searching word: %s in the file'%keyWord)
|
||||
sys.exit(104)
|
||||
#exception raised if the word: is, wasn't in the log file
|
||||
except ValueError:
|
||||
print ('error missing word: is in the selected line')
|
||||
sys.exit(105)
|
||||
|
||||
except:
|
||||
raise
|
||||
|
||||
sys.exit()
|
||||
|
||||
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
#######################################################################
|
||||
# Software License Agreement (AGPL-3 License)
|
||||
#
|
||||
# OpenViBE SDK Test Software
|
||||
# Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015
|
||||
# Copyright (C) Inria, 2015-2017,V1.0
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License version 3,
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program.
|
||||
# If not, see <http://www.gnu.org/licenses/>.
|
||||
#######################################################################
|
||||
|
||||
#######################################################################
|
||||
# Script description
|
||||
# Goal: check if the number of stimuations present after classification
|
||||
# is identical to a reference result.
|
||||
#
|
||||
# Step 1: Define time windows between 2 stimulation id in the file before the classification,
|
||||
# the first stimulation ID will be the reference stimulation ID.
|
||||
# Step 2: Count how many time you get the reference stimulation ID in the time windows.
|
||||
# Step 3: Compute the number of success and provide a ratio.
|
||||
# Step 4: Compare the ratio to a reference value compute from previous test.
|
||||
#######################################################################
|
||||
|
||||
import csv
|
||||
import sys
|
||||
from itertools import islice
|
||||
|
||||
# assign arguments to variables
|
||||
#arg 1 csv file recorded from ov file before the classification
|
||||
#arg 2 csv file recorded after the classification
|
||||
#arg 3 reference classification result
|
||||
if len(sys.argv) < 4 :
|
||||
print('incorrect args')
|
||||
sys.exit(101)
|
||||
# open files associated with the varaibles
|
||||
with open(sys.argv[1], 'r') as fileReferenceData :
|
||||
readerReferenceData = csv.reader(fileReferenceData, delimiter=',')
|
||||
inputData = [rowReference for rowReference in readerReferenceData if rowReference[4] != ""]
|
||||
if len(inputData) == 0:
|
||||
print('The lenght of the file reference data: %s is equal to 0 or lower'%sys.argv[1])
|
||||
sys.exit(109)
|
||||
with open(sys.argv[2], 'r') as fileTestData :
|
||||
readerTestData = csv.reader(fileTestData, delimiter=',')
|
||||
next(readerTestData)
|
||||
outputData = [rowReference for rowReference in readerTestData if rowReference[3] != ""]
|
||||
if len(outputData) == 0:
|
||||
print('The lenght of the test data: %s is equal to 0 or lower'%sys.argv[2])
|
||||
sys.exit(109)
|
||||
with open(sys.argv[3], 'r') as fileClassificationReference :
|
||||
classificationReferenceData = [fileIndex for fileIndex in fileClassificationReference]
|
||||
|
||||
# Select into input data the signal with good stimulation marker
|
||||
referenceData = [rowReference for rowReference in inputData if rowReference[3] in ['33026', '33027', '33025']]
|
||||
referenceData.append(inputData[-1])
|
||||
|
||||
# Check in a time window define by two timestamp the number of stimuation
|
||||
for firstLineReference, secondLineReference, classificationLine in zip(referenceData, islice(referenceData, 1, None), classificationReferenceData) :
|
||||
# Create the first timestamp referenc
|
||||
stimulationReference = firstLineReference[3]
|
||||
firstTimeReference = float(firstLineReference[0])
|
||||
# Create the second timestamp reference
|
||||
secondTimeReference = float(secondLineReference[0])
|
||||
stimulationCount = 0
|
||||
numberOfStimulation = 0
|
||||
|
||||
# Create the time window between the first and second time stamp reference
|
||||
#Count the reference stimulation ID
|
||||
ref_list = [index.count(stimulationReference) for index in outputData if firstTimeReference < float(index[0]) < secondTimeReference]
|
||||
print(ref_list)
|
||||
#Compute the percentage of success
|
||||
classificationEvaluation = (sum(ref_list)/len(ref_list))*100
|
||||
|
||||
# Compare to the reference value
|
||||
if abs(classificationEvaluation - float(classificationLine)) > sys.float_info.epsilon:
|
||||
print('Classification reference value:%s'%classificationLine)
|
||||
print('Classification evaluation value:%s'%classificationEvaluation)
|
||||
sys.exit(108)
|
||||
|
||||
sys.exit()
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#######################################################################
|
||||
# Software License Agreement (AGPL-3 License)
|
||||
#
|
||||
# OpenViBE SDK Test Software
|
||||
# Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015
|
||||
# Copyright (C) Inria, 2015-2017,V1.0
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License version 3,
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program.
|
||||
# If not, see <http://www.gnu.org/licenses/>.
|
||||
#######################################################################
|
||||
|
||||
import csv
|
||||
import sys
|
||||
import re
|
||||
import numpy as np
|
||||
|
||||
# test script parameter arg1: reference file csv
|
||||
# test script parameter arg2: test file csv
|
||||
if len(sys.argv) < 3 :
|
||||
print('incorrect args')
|
||||
sys.exit(101)
|
||||
# assign arguments to variable
|
||||
ref_filename=sys.argv[1]
|
||||
test_filename=sys.argv[2]
|
||||
|
||||
#open files associated with the variables
|
||||
|
||||
with open(ref_filename, 'r') as fileReferenceData :
|
||||
ref_header = next(fileReferenceData)
|
||||
ref_data = np.loadtxt(fileReferenceData, delimiter=",", usecols=[0, 1, 2, 3, 4])
|
||||
|
||||
min_epoch = np.amax(ref_data[ref_data[:,0] <= 1], 0)[1] + 1
|
||||
start_index = np.where(ref_data[:,1] == min_epoch)[0][0]
|
||||
max_epoch = np.amax(ref_data[ref_data[:,0] <= 2], 0)[1]
|
||||
end_index = np.where(ref_data[:,1] == max_epoch)[0][-1] + 1
|
||||
|
||||
with open(test_filename, 'r') as fileTestData :
|
||||
test_header = next(fileTestData)
|
||||
test_data = np.loadtxt(fileTestData, delimiter=",", usecols=[0, 1, 2, 3, 4])
|
||||
|
||||
if test_header != ref_header or test_data.shape[0] != (end_index - start_index):
|
||||
print("Header or shape does not correspond")
|
||||
sys.exit(101)
|
||||
if not np.allclose(test_data[:,[0, 2, 3, 4]], ref_data[start_index:end_index,[0, 2, 3, 4]]) :
|
||||
print("Data is different")
|
||||
sys.exit(100)
|
||||
sys.exit()
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
#######################################################################
|
||||
# Software License Agreement (AGPL-3 License)
|
||||
#
|
||||
# OpenViBE SDK Test Software
|
||||
# Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015
|
||||
# Copyright (C) Inria, 2015-2017,V1.0
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License version 3,
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program.
|
||||
# If not, see <http://www.gnu.org/licenses/>.
|
||||
#######################################################################
|
||||
|
||||
import csv
|
||||
import sys
|
||||
|
||||
# test script parameter arg1: reference file csv
|
||||
# test script parameter arg2: test file csv
|
||||
|
||||
# assign arguments to variable
|
||||
if len(sys.argv) != 3 :
|
||||
print('incorrect args')
|
||||
sys.exit(101)
|
||||
referenceData=sys.argv[1]
|
||||
testData=sys.argv[2]
|
||||
|
||||
def compareCells (file1,file2):
|
||||
"""Compare values of cell from two list of lists"""
|
||||
# select the ligne for both csv file
|
||||
for line_index, (input_line, output_line) in enumerate(zip(file1, file2)) :
|
||||
#check line sizes
|
||||
if len(input_line) != len(output_line):
|
||||
print('input and output cells size are different on line %s' % (line_index + 2))
|
||||
print('input cells: %s' % len(input_line))
|
||||
print('output cells: %s' % len(output_line))
|
||||
sys.exit(107)
|
||||
|
||||
for col_index, (inputCell, outputCell) in enumerate(zip(input_line, output_line)):
|
||||
if inputCell != "" and abs(float(outputCell)-float(inputCell)) > sys.float_info.epsilon:
|
||||
print('error on line %s and column %s' % (line_index + 2, col_index+1))
|
||||
print( 'the input cell %s is different from output cell %s' % (inputCell, outputCell))
|
||||
sys.exit(107)
|
||||
|
||||
try:
|
||||
#open files associated with the variables
|
||||
with open(referenceData, 'r') as fileReferenceData :
|
||||
readerReferenceData = csv.reader(fileReferenceData, delimiter=';')
|
||||
inputData = [row for row in readerReferenceData]
|
||||
with open(testData, 'r') as fileTestData :
|
||||
readerTestData = csv.reader(fileTestData, delimiter=';')
|
||||
outputData = [row for row in readerTestData]
|
||||
except IOError as err:
|
||||
print('missing input or ouput file')
|
||||
print('missing file: %s'%(err.filename))
|
||||
sys.exit(106)
|
||||
|
||||
#check the file size of input and output files
|
||||
if len(inputData) != len(outputData) :
|
||||
print('Input (%s lines) and output (%s lines) files size are different :' % (len(inputData), len(outputData)))
|
||||
sys.exit(107)
|
||||
|
||||
# remove the headers and compare them
|
||||
if inputData.pop(0) != outputData.pop(0) :
|
||||
print('Header is different')
|
||||
sys.exit(108)
|
||||
|
||||
#perform the cell comparison
|
||||
compareCells(inputData, outputData)
|
||||
|
||||
print('All values are identiqual')
|
||||
|
||||
sys.exit()
|
||||
Reference in New Issue
Block a user