parsers/DataReader.py
def readTobiiGaze(self, settingsReader:object, multiData:object) -> None:
        """Reads Tobii Glasses 2 gaze data from .tsv file.
        
        :param settingsReader: same as everywhere
        :param multiData: same
        :return:
        """
        for fileElem in settingsReader.genTypeFile('gaze'):
            filePath = settingsReader.getPathAttrById('gaze', fileElem.get('id'), absolute=True)
            fileExt = os.path.splitext(filePath)[1]
            self.main.printToOut('Reading gaze data ({0})...'.format(os.path.basename(filePath)))
            if fileExt.lower()=='.tsv':
                self.main.printToOut('Parsing {0} file.'.format(fileExt))
                # узнаем какие столбцы присутствуют
                headers = pd.read_table(filePath, nrows=1, encoding='UTF-16')
                availColumns = [i for i in list(headers.columns) if re.match('Recording timestamp|Gaze point|Gaze 3D position|Gaze direction|Pupil diameter|Eye movement type|Gaze event duration|Fixation point|Gyro|Accelerometer',i)]
                multiData.setNode('availColumns', fileElem.get('id'), availColumns)

                gazeData = pd.read_table(filePath, decimal=",", encoding='UTF-16', usecols=availColumns)
                # переводим в секунды
                gazeData['Recording timestamp'] /= 1000
                #gazeData['Gaze event duration'] /= 1000

                if multiData.hasAllColumns(['Gyro X','Gyro Y','Gyro Z','Accelerometer X','Accelerometer Y','Accelerometer Z'],fileElem.get('id')):
                    gazeData.drop(['Gyro X', 'Gyro Y', 'Gyro Z', 'Accelerometer X', 'Accelerometer Y', 'Accelerometer Z'], axis=1, inplace=True)

                # убираем пустые строки, которые могли образоваться после удаления строк гироскопа
                gazeData = gazeData[(gazeData['Gaze point X'].notnull()) & (gazeData['Gaze point Y'].notnull()) | \
                                    (gazeData['Eye movement type'] == 'EyesNotFound')]

                if multiData.hasColumn('Eye movement type', fileElem.get('id')):
                    gazeData.drop(['Eye movement type', 'Gaze event duration', 'Eye movement type index',
                                   'Fixation point X', 'Fixation point Y'],
                                   axis=1, inplace=True)

                #TODO translation to degrees, velocity profile

            elif fileExt.lower() == '.json':
                self.main.printToOut('ERROR: parsing .json files not implemented.')
                raise NotImplementedError
            elif fileExt.lower()=='.csv':
                self.main.printToOut('Parsing {0} file.'.format(fileExt))
                gazeData = pd.read_csv(filePath, sep='\t')
            else:
                self.main.printToOut('Unknown file format.')


            multiData.setNode('gaze', fileElem.get('id'), gazeData)
Reads Tobii Glasses 2 gaze data from .tsv file.
        
        :param settingsReader: same as everywhere
        :param multiData: same
        :return:
        
Reads Tobii Glasses 2 gaze data from .tsv file.
Reads Tobii Glasses 2 gaze data from . tsv file .
def readTobiiGaze(self, settingsReader:object, multiData:object) -> None:
        for fileElem in settingsReader.genTypeFile('gaze'):
            filePath = settingsReader.getPathAttrById('gaze', fileElem.get('id'), absolute=True)
            fileExt = os.path.splitext(filePath)[1]
            self.main.printToOut('Reading gaze data ({0})...'.format(os.path.basename(filePath)))
            if fileExt.lower()=='.tsv':
                self.main.printToOut('Parsing {0} file.'.format(fileExt))
                headers = pd.read_table(filePath, nrows=1, encoding='UTF-16')
                availColumns = [i for i in list(headers.columns) if re.match('Recording timestamp|Gaze point|Gaze 3D position|Gaze direction|Pupil diameter|Eye movement type|Gaze event duration|Fixation point|Gyro|Accelerometer',i)]
                multiData.setNode('availColumns', fileElem.get('id'), availColumns)
                gazeData = pd.read_table(filePath, decimal=",", encoding='UTF-16', usecols=availColumns)
                gazeData['Recording timestamp'] /= 1000
                if multiData.hasAllColumns(['Gyro X','Gyro Y','Gyro Z','Accelerometer X','Accelerometer Y','Accelerometer Z'],fileElem.get('id')):
                    gazeData.drop(['Gyro X', 'Gyro Y', 'Gyro Z', 'Accelerometer X', 'Accelerometer Y', 'Accelerometer Z'], axis=1, inplace=True)
                gazeData = gazeData[(gazeData['Gaze point X'].notnull()) & (gazeData['Gaze point Y'].notnull()) | \
                                    (gazeData['Eye movement type'] == 'EyesNotFound')]
                if multiData.hasColumn('Eye movement type', fileElem.get('id')):
                    gazeData.drop(['Eye movement type', 'Gaze event duration', 'Eye movement type index',
                                   'Fixation point X', 'Fixation point Y'],
                                   axis=1, inplace=True)
            elif fileExt.lower() == '.json':
                self.main.printToOut('ERROR: parsing .json files not implemented.')
                raise NotImplementedError
            elif fileExt.lower()=='.csv':
                self.main.printToOut('Parsing {0} file.'.format(fileExt))
                gazeData = pd.read_csv(filePath, sep='\t')
            else:
                self.main.printToOut('Unknown file format.')
            multiData.setNode('gaze', fileElem.get('id'), gazeData)
def readTobiiGaze ( self , settingsReader : object , multiData : object ) -> None : for fileElem in settingsReader . genTypeFile ( 'gaze' ) : filePath = settingsReader . getPathAttrById ( 'gaze' , fileElem . get ( 'id' ) , absolute = True ) fileExt = os . path . splitext ( filePath ) [ 1 ] self . main . printToOut ( 'Reading gaze data ({0})...' . format ( os . path . basename ( filePath ) ) ) if fileExt . lower ( ) == '.tsv' : self . main . printToOut ( 'Parsing {0} file.' . format ( fileExt ) ) headers = pd . read_table ( filePath , nrows = 1 , encoding = 'UTF-16' ) availColumns = [ i for i in list ( headers . columns ) if re . match ( 'Recording timestamp|Gaze point|Gaze 3D position|Gaze direction|Pupil diameter|Eye movement type|Gaze event duration|Fixation point|Gyro|Accelerometer' , i ) ] multiData . setNode ( 'availColumns' , fileElem . get ( 'id' ) , availColumns ) gazeData = pd . read_table ( filePath , decimal = "," , encoding = 'UTF-16' , usecols = availColumns ) gazeData [ 'Recording timestamp' ] /= 1000 if multiData . hasAllColumns ( [ 'Gyro X' , 'Gyro Y' , 'Gyro Z' , 'Accelerometer X' , 'Accelerometer Y' , 'Accelerometer Z' ] , fileElem . get ( 'id' ) ) : gazeData . drop ( [ 'Gyro X' , 'Gyro Y' , 'Gyro Z' , 'Accelerometer X' , 'Accelerometer Y' , 'Accelerometer Z' ] , axis = 1 , inplace = True ) gazeData = gazeData [ ( gazeData [ 'Gaze point X' ] . notnull ( ) ) & ( gazeData [ 'Gaze point Y' ] . notnull ( ) ) | ( gazeData [ 'Eye movement type' ] == 'EyesNotFound' ) ] if multiData . hasColumn ( 'Eye movement type' , fileElem . get ( 'id' ) ) : gazeData . drop ( [ 'Eye movement type' , 'Gaze event duration' , 'Eye movement type index' , 'Fixation point X' , 'Fixation point Y' ] , axis = 1 , inplace = True ) elif fileExt . lower ( ) == '.json' : self . main . printToOut ( 'ERROR: parsing .json files not implemented.' ) raise NotImplementedError elif fileExt . lower ( ) == '.csv' : self . main . printToOut ( 'Parsing {0} file.' . format ( fileExt ) ) gazeData = pd . read_csv ( filePath , sep = '\t' ) else : self . main . printToOut ( 'Unknown file format.' ) multiData . setNode ( 'gaze' , fileElem . get ( 'id' ) , gazeData )
Reads Tobii Glasses 2 gaze data from .tsv file.
Reads Tobii Glasses 2 gaze data from . tsv file .
"""Reads Tobii Glasses 2 gaze data from .tsv file.
        
        :param settingsReader: same as everywhere
        :param multiData: same
        :return:
        """ # узнаем какие столбцы присутствуют # переводим в секунды #gazeData['Gaze event duration'] /= 1000 # убираем пустые строки, которые могли образоваться после удаления строк гироскопа #TODO translation to degrees, velocity profile
None
self
settingsReader
object
same as everywhere
same as everywhere
multiData
object
None