psychopy.org | Reference | Downloads | Github

Iohub eye tracking: add datetime to edf filename

Hi All,

I used the run.py demo in psychopy 1.84.2 to create my own task. I’ve got everything working and eye tracking happening with SR Eyelink.

The only problem I’ve run into is that because the edf file gets saved as ‘et_data’, running the experiment again means that file gets rewritten. So how would I go about adjusting the code to add a datetime stamp on the filename so that they don’t get rewritten every time the experiment is run?

Thanks

Would I be right in thinking that I might need to edit

psychopy/iohub/devices/eyetracker/sr_research/eyelink/eyetracker.py where default_native_data_file_name is defined? If so, how can I make this populate current date/time in the edf filename to replace the ‘et_data’ in iohub_config.yaml

native data recording file

        default_native_data_file_name=tracker_config.get('default_native_data_file_name',None)
        if default_native_data_file_name:
            if isinstance(default_native_data_file_name,(str,unicode)):
                r=default_native_data_file_name.rfind('.')
                if default_native_data_file_name>0:
                    if default_native_data_file_name[r:] == 'edf'.lower():
                        default_native_data_file_name=default_native_data_file_name[:r]

                if len(default_native_data_file_name)>7:
                    EyeTracker._full_edf_name=default_native_data_file_name
                    twoDigitRand=np.random.randint(10,99)
                    EyeTracker._host_edf_name=self._full_edf_name[:3]+twoDigitRand+self._full_edf_name[5:7]
                else:
                    EyeTracker._full_edf_name=default_native_data_file_name
                    EyeTracker._host_edf_name=default_native_data_file_name
            else:
                print2err("ERROR: default_native_data_file_name must be a string or unicode value")

        if self._local_edf_dir and self._full_edf_name:
            EyeTracker._active_edf_file=self._full_edf_name+'.EDF'    
        self._eyelink.openDataFile(self._host_edf_name+'.EDF')

Hi, cross-posting the very same question at different places is not very nice, or should at least be pointed out explicitly. The reason is that it splits resources and people might end up spending time on an issue that was already resolved elsewhere. This question has been posted on Stack Overflow and already received responses:

http://stackoverflow.com/questions/41051058/add-current-date-time-to-default-filename

Hi Richard,

Yes, we’ve been looking for solutions for this issue and I’ve only just found out about this forum and joined. I asked here hoping to find answers from psychopy users who may also use iohub and have come across the same issues as the response from other post led to more errors rather than fixing the initial problem.

Forgive my ignorance, I’m still learning the etiquettes of such forums.

1 Like