code/vexptoolbox/replay.py
def loadRecording(self, sample_file=None, sep='\t'):
        """ Load a SampleRecorder sample file for replay
        
        Args:
            sample_file (str): Filename of CSV file to load. If no 
                file is specified, show Vizard file selection dialog.
            sep (str): Field separator in CSV input file
        """
        s = []

        if sample_file is None:
            sample_file = vizinput.fileOpen(filter=[('Samples files', '*.csv;*.tsv;*.dat;*.txt')])

        with open(sample_file, 'r') as sf:
            reader = csv.DictReader(sf, delimiter=sep)
            if len(reader.fieldnames) == 1:
                m = 'Warning: Only a single column read from recording file. Is the field separator set correctly (e.g., sep=";")?\n'
                print(m)

            HEADER = reader.fieldnames
            for row in reader:
                sample = {}
                for field in reader.fieldnames:

                    # Convert numeric values
                    data = row[field]
                    try:
                        sample[field] = int(data)
                    except ValueError:
                        try:
                            sample[field] = float(data)
                        except ValueError:
                            sample[field] = data
                s.append(sample)

        self._samples = s
        self._sample_time_offset = s[0]['time']

        # Only enable gaze data present in the recording
        for eye_pos in list(self._gaze.keys()):
            self._gaze[eye_pos]['data'] = False
        if 'gaze_posX' in HEADER and 'gaze_dirX' in HEADER:
            self._gaze['']['data'] = True
        if 'gazeL_posX' in HEADER and 'gazeL_dirX' in HEADER:
            self._gaze['L']['data'] = True
        if 'gazeR_posX' in HEADER and 'gazeR_dirX' in HEADER:
            self._gaze['R']['data'] = True

        # Find tracked nodes
        _nodes_builtin = ['gaze', 'gazeL', 'gazeR', 'tracker', 'trackerL', 'trackerR']
        for field in HEADER:
            if field[-5:] == '_posX' and field[0:-5] not in _nodes_builtin:
                self.replay_nodes.append(field[0:-5])
        self._update_nodes()
        self._set_ui()
        print('* Loaded {:d} replay samples from {:s}.'.format(len(s), sample_file))
        if len(self.replay_nodes) > 1:
            print('* Replay contains {:d} tracked nodes: {:s}.'.format(len(self.replay_nodes), ', '.join(self.replay_nodes)))
 Load a SampleRecorder sample file for replay
        
        Args:
            sample_file (str): Filename of CSV file to load. If no 
                file is specified, show Vizard file selection dialog.
            sep (str): Field separator in CSV input file
        
Load a SampleRecorder sample file for replay
Load a SampleRecorder sample file for replay
def loadRecording(self, sample_file=None, sep='\t'):
        s = []
        if sample_file is None:
            sample_file = vizinput.fileOpen(filter=[('Samples files', '*.csv;*.tsv;*.dat;*.txt')])
        with open(sample_file, 'r') as sf:
            reader = csv.DictReader(sf, delimiter=sep)
            if len(reader.fieldnames) == 1:
                m = 'Warning: Only a single column read from recording file. Is the field separator set correctly (e.g., sep=";")?\n'
                print(m)
            HEADER = reader.fieldnames
            for row in reader:
                sample = {}
                for field in reader.fieldnames:
                    data = row[field]
                    try:
                        sample[field] = int(data)
                    except ValueError:
                        try:
                            sample[field] = float(data)
                        except ValueError:
                            sample[field] = data
                s.append(sample)
        self._samples = s
        self._sample_time_offset = s[0]['time']
        for eye_pos in list(self._gaze.keys()):
            self._gaze[eye_pos]['data'] = False
        if 'gaze_posX' in HEADER and 'gaze_dirX' in HEADER:
            self._gaze['']['data'] = True
        if 'gazeL_posX' in HEADER and 'gazeL_dirX' in HEADER:
            self._gaze['L']['data'] = True
        if 'gazeR_posX' in HEADER and 'gazeR_dirX' in HEADER:
            self._gaze['R']['data'] = True
        _nodes_builtin = ['gaze', 'gazeL', 'gazeR', 'tracker', 'trackerL', 'trackerR']
        for field in HEADER:
            if field[-5:] == '_posX' and field[0:-5] not in _nodes_builtin:
                self.replay_nodes.append(field[0:-5])
        self._update_nodes()
        self._set_ui()
        print('* Loaded {:d} replay samples from {:s}.'.format(len(s), sample_file))
        if len(self.replay_nodes) > 1:
            print('* Replay contains {:d} tracked nodes: {:s}.'.format(len(self.replay_nodes), ', '.join(self.replay_nodes)))
def loadRecording ( self , sample_file = None , sep = '\t' ) : s = [ ] if sample_file is None : sample_file = vizinput . fileOpen ( filter = [ ( 'Samples files' , '*.csv;*.tsv;*.dat;*.txt' ) ] ) with open ( sample_file , 'r' ) as sf : reader = csv . DictReader ( sf , delimiter = sep ) if len ( reader . fieldnames ) == 1 : m = 'Warning: Only a single column read from recording file. Is the field separator set correctly (e.g., sep=";")?\n' print ( m ) HEADER = reader . fieldnames for row in reader : sample = { } for field in reader . fieldnames : data = row [ field ] try : sample [ field ] = int ( data ) except ValueError : try : sample [ field ] = float ( data ) except ValueError : sample [ field ] = data s . append ( sample ) self . _samples = s self . _sample_time_offset = s [ 0 ] [ 'time' ] for eye_pos in list ( self . _gaze . keys ( ) ) : self . _gaze [ eye_pos ] [ 'data' ] = False if 'gaze_posX' in HEADER and 'gaze_dirX' in HEADER : self . _gaze [ '' ] [ 'data' ] = True if 'gazeL_posX' in HEADER and 'gazeL_dirX' in HEADER : self . _gaze [ 'L' ] [ 'data' ] = True if 'gazeR_posX' in HEADER and 'gazeR_dirX' in HEADER : self . _gaze [ 'R' ] [ 'data' ] = True _nodes_builtin = [ 'gaze' , 'gazeL' , 'gazeR' , 'tracker' , 'trackerL' , 'trackerR' ] for field in HEADER : if field [ - 5 : ] == '_posX' and field [ 0 : - 5 ] not in _nodes_builtin : self . replay_nodes . append ( field [ 0 : - 5 ] ) self . _update_nodes ( ) self . _set_ui ( ) print ( '* Loaded {:d} replay samples from {:s}.' . format ( len ( s ) , sample_file ) ) if len ( self . replay_nodes ) > 1 : print ( '* Replay contains {:d} tracked nodes: {:s}.' . format ( len ( self . replay_nodes ) , ', ' . join ( self . replay_nodes ) ) )
Load a SampleRecorder sample file for replay
Load a SampleRecorder sample file for replay
""" Load a SampleRecorder sample file for replay
        
        Args:
            sample_file (str): Filename of CSV file to load. If no 
                file is specified, show Vizard file selection dialog.
            sep (str): Field separator in CSV input file
        """ # Convert numeric values # Only enable gaze data present in the recording # Find tracked nodes
self
sample_file
Filename of CSV file to load. If no
file is specified, show Vizard file selection dialog.
Filename of CSV file to load . If no file is specified show Vizard file selection dialog .
sep
Field separator in CSV input file
Field separator in CSV input file