1 Introduction

An electroencephalogram (EEG) is the brain activity acquired from the electrodes placed on the brain surface. By analyzing these signals, meaningful results can be extracted from the electric activities performed in the brain. EEG signals have been widely used in the diagnosis and treatment of some special brain and neurological diseases [1, 2]. Some EEG experiments have been performed against visual, auditory or somatosensory stimuli in the literature. Thus, communications between people and their surroundings have been explored, and some brain activations have been observed. The evoked potential (EP) obtained from the brain is a superposition of various electrical activities. EP is the wave found in the EEG and arises in the brain as a result of neural activities in response to a stimulus. Visual evoked potentials (VEPs) are employed in experimental studies for the determination of the visual functions [3]. When a visual expression is used as a stimulus, some descriptive information can be reached by classifying the EP [4, 5].

Some medical EEG devices may not be sufficient for organizing stimuli experiments. Moreover, although synchronizing EEG devices with stimuli presentation software is crucial, existing devices may not have the capability to provide this feature [6]. Furthermore, timing accuracy is important in the stimuli presentation [7]. In some scientific EEG studies, researchers are still using unprofessional software like PowerPoint. Such types of presentation software cannot synchronize with existing EEG devices and cannot mark on signals in EEG experiments. There are lots of commercial software for EEG studies, and researchers are obliged to purchase such commercial software due to the inadequacies of unprofessional software. However, these types of software are not preferred because of high prices and incompatibility with existing EEG devices.

In some previous studies, non-specialized presentation software was necessarily used due to scarce project budget resources while performing EEG experiments. In some of these studies, automated and PC-based systems were designed for performing EEG experiments [3, 8]. And in an experiment, visual evoked potentials were recorded using a special hardware system [9]. In another study, researchers investigated fixation differences between familiar and unfamiliar face stimuli using non-specialized presentation software [10]. In another EEG experiment [11], similar-sized, high-quality shoe photographs were presented using PowerPoint. Furthermore, familiar and unfamiliar faces were displayed to subjects using non-specialized presentation software in an EEG study [12]. In another study in which animal and non-animal natural scenes were shown, PowerPoint was employed as stimuli presentation software [13]. Apart from these, non-free and commercial stimuli presentation software like E-Prime [14,15,16] and STIM2 [17, 18] can be used in EEG experiments. Moreover, free but complicated software like PsychoPy [19] and OpenSeSame [20] can be preferred for building and running stimuli experiments in neurophysiology studies [21]. Because of their cost and complexity, these types of software may not be preferred.

As an alternative to the aforementioned software, a novel, simple and free stimuli presentation software STIPRESOFT was developed in this study. The motivation behind the study was to set up suitable, practical EEG experiments in which visual stimuli were used without the need for any additional budget. Furthermore, the developed software momentarily synchronized the EEG acquisition system with the stimuli presentation software. Besides, the mechanism of the software had good timing accuracy. In the software, small time shifts between displaying and recorded times of a stimulus were eliminated thanks to the API functions. The software was entirely free, easy to use, and had support for existing hardware. The software could make direct calls to the Windows Application Processing Interface (API) libraries. This software was simple to run on an extremely wide range of hardware like Nicolet v32/v44, Nihon Kohden EEG 1100 and NeuroFax EEG Systems. The developed software aimed to contribute to similar studies for facilitating EEG experiments and to reduce software costs.

2 Materials and methods

In this study, STIPRESOFT software was developed. This software could synchronize the existing EEG device with a stimuli presentation software. The developed software was experienced on the EEG device registered on the inventory of the Adiyaman University Training and Research Hospital Neurology service.

2.1 Hardware specifications

The EEG device was a seamless, reliable and flexible system that recorded brain wave activities and electroencephalogram signals without compromising quality. The EEG system combined photic stimulation, counting for hyperventilation, re-organization of data, reporting and many other features in one system. Furthermore, this system supported optional add-on packages such as digital video, sharp wave detection, seizure detection and sleep analysis. The device had an integrated impedance interface, a SpO2 port, an Ethernet amplifier interface, nine AC and DC ports, one high-level DC input port and a patient response button. This response button was not used in the study.

2.2 EEG recording software

The recording software (Studyroom) managed the job of obtaining the EEG signals. Various controls related to EEG experiments could be adjusted by this software. Furthermore, the recording process could be started by pressing the RECORD button or CTRL + R key combination in the software. This software was synchronized with STIPRESOFT during the experiment. STIPRESOFT provided the synchronization by sending CTRL + R key combination to the Studyroom software at the onset and end of the experiment.

2.3 Experimental conditions

The software randomly reflected the stimuli to the monitor in each run. Display sequences and display times for stimuli and experiment duration were recorded in a text file (behavioral). The experimental procedure was organized according to the method tried in [22]. A total of 100 cycles were processed on each run. The recording time was 9 min and 10 s for each run. The developed software in the study is convenient to be run under different experimental conditions.

2.4 Windows application processing interface (windows API)

Operating systems service their sub-processes, and this software is interrupted with Windows APIs. To develop software with APIs, the basic features and the functions served by the operating system must be known to the developer. Interactions among Windows forms, like sending a button click event from a form to another form, are possible using Windows API functions. API functions benefit from DLL files. To use these functions in another project, the corresponding DLL files have to be initially included. In this study, the form control properties of Windows API functions were employed.

2.5 Timer object

The timer object is a precise function. However, the processes defined by a timer object may cause time shifts in the more exacting time-dependent operations. Namely, when a timer object is employed in an image-processing application, values such as physical sizes, components of images and writing to a screen may cause time delays. In case there is a need for advanced precision time measurements, Query-Performance-Frequency and Query-Performance-Counter components can be benefited. The sensitivities of time-oriented functions used in the programming languages are shown in Table 1.

Table 1 Time-oriented functions used in programming

2.6 Query-performance-counter (QPC)

The total number of ticks is returned by Query-Performance-Counter (QPC) in the Windows operating system. QPC is independent of any external time references. Time stamps and time interval calculations are an integral part of a computer system. In computer systems, the performance calculations include the computation of response time, throughput and latency. These operations involve the calculation of processes executed throughout a time interval that is defined by a start event and an end event. Consequently, QPC calculates the small-time intervals in a computer system.

2.7 Query-performance-frequency (QPF)

Query-Performance-Frequency (QPF) is a function dependent on QPC. This function gives the frequency of the performance counter in a computer system. The frequency of the performance counter is set when the system boots and is stable at all processor times. Hence, the frequency amount is queried at the instant of the initialization of applications, and the results obtained are cached by the computer. In a computer system, the period and resolution are equal to the reciprocal of the frequency value. The performance counter frequency is determined at system initialization and does not change while the system is running.

3 Results

In the study, the software enabling synchronization between the stimuli presentation software and the EEG recording system was developed using Windows API functions. The developed software can be accessed from the address given in [23]. The visual results obtained, and software codes developed in the study are given in the following.

3.1 Graphical user interfaces (GUI)

Two graphical user interfaces (GUI) were developed through the study. One of them was the synchronization test program. In this GUI, a button aims to list the names on the Windows forms belonging to the applications running in the background. Another button sends a CTRL + R key combination to the EEG recording software. A screenshot belonging to this GUI is given in Fig. 1.

Fig. 1
figure 1

A screenshot belongs to GUI providing synchronization

Another GUI was the main stimuli presentation software. Synchronization was provided by this GUI. Furthermore, this software sent the CTRL + R key combination through API to Studyroom software (EEG acquisition system) to start and stop the recording of EEG signals. In the first, send of the key combination started the EEG recording, and in the second, send stopped the EEG recording. Time stamps for the events occurring in the presentation were saved in a text file in each run. The decomposition of EEG signals according to the events was possible through the help of the text file. Moreover, event-related potential (ERP) could be obtained according to the instantaneous stimuli displays recorded in this file. A screenshot related to this GUI and the graphical abstract belonging to the experimental procedure are given in Fig. 2a, b, respectively.

Fig. 2
figure 2

Developed GUI (a), experimental procedure (b)

3.2 Source codes

In the STIPRESOFT software, there are three sub-functions and one main function. The names of the sub-functions are WindowFormLists, FormSynchronization and PressCTRLwithKey, respectively. These sub-functions are introduced under the headings of code snippet 1, code snippet 2 and code snippet 3 in this section. And finally, the main function is introduced under the heading of code snippet 4. The source codes of these functions are given in “Appendix” section, and their flowcharts are given in Figs. 3, 4, 5 and 6. The codes can be followed up from the line numbers in “Appendix” section.

Fig. 3
figure 3

The function listing the names of Windows forms in the application

Fig. 4
figure 4

The function that sends shortcut key combination to another window forms for assuring EEG signals recording

Fig. 5
figure 5

The function for sending key combination to synchronized form

Fig. 6
figure 6

The main function of the presentation software

The first procedure and the related flowchart of the developed software are given in code snippet 1 and Fig. 3. In the code snippet 1, the WindowFormLists procedure lists the form names of applications running at that moment in the background. The IsWindowVisible command examines the forms if they are running in the background of the operating system. The GetWindowText function copies the text of the specified window’s title bar into a buffer. The GetClassName retrieves the name of the class to which the specified window belongs, and the GetnextWindow retrieves a handle to the next or previous window in the Z-Order.

In code snippet 2, the FormSynchronization function sends the CTRL + R key combination to the EEG recording interface. This interface is handled by the WindowFormLists procedure given in code snippet 1. The FormSynchronization function serves to press the RECORD button job. A Window API function, FindWindow, retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search for child windows and does not perform a case-sensitive search. The function uses two parameters. The first parameter is the name on the contact form, and the second parameter specifies the window class name. Another Window API function, SetForegroundWindow, brings the thread that created the specified window in the foreground and activates the window. Keyboard input is directed through the window, and various visual cues are changed for the user. The system assigns a slightly higher priority to the thread that created the foreground window than it does to other threads. In the application, handled window form is activated by this procedure. The flowchart belonging to code snippet 2 is given in Fig. 4.

The PressCTRLwithKey function behaves as the CTRL  +  ANY KEY shortcut combination. The source codes related to this function are given in code snippet 3. The flowchart belonging to code snippet 3 is given in Fig. 5.

The main function in STIPRESOFT is given in code snippet 4. In the first paragraph (the first 19 lines), in code snippet 4, a text file is initially generated to record the presentation times of the stimuli images. This text file makes it possible for the decomposed EEG signals to be related to the stimuli images. Between 10 and 12 lines, QPF and QPC functions record the times related to these events. The FormSynchronization function given in line 17 sends the CTRL + R key combination to the window form belonging to the EEG acquisition system to start synchronization between the two forms. In the last paragraph (lines between 20 and 59), in code snippet 4, cycles are repeated, and event times are recorded into the text file for each while loop. The flowchart designed for the main function is given in Fig. 6.

In the software development process, the study was confronted by a problem related to the use of the timer object. The timer object did not act consistently in the study. Namely, the Sleep function inherited from the timer object was employed to maintain images on a screen for the desired time. However, this function could not maintain the images on the screen for the wanted time during the presentation. Time shifts were also confronted in this application. For instance, it was observed that the screen retention times for stimuli images might be 798 or 814 ms instead of 800 ms in some trials. Since this negativity affected the synchronization between windows forms, Windows API functions (QPF, QPC) were employed instead of the Sleep function. These functions achieved precise timing adjustments for the presentation.

Time stamps recorded during an experiment are given in Fig. 7. Response times (GrayFix, Gray and Picture) are shown for only three stimuli presentation time in the figure. The high-resolution timing functions (QPF and QPC) are employed from the beginning of the while loop. The loop continues through the end of the experiment. During the loop, cycles are displayed one after another. One loop includes a fixation providing focusing. Throughout the loop, all events in time are recorded for each repetition.

Fig. 7
figure 7

A screenshot of a sample text file. Time stamps of displayed stimuli images are saved in the file

The iFirst and iSecond variables keep the total number of ticks that have occurred since the Windows operating system was started. The API Overhead, which is the delay between two consecutive queries, is calculated with the iDifference variable, and the iFrequency variable is defined to get the frequency value for microprocessors. The dResult is a variable that gives the time value in milliseconds. The Application.ProcessMessages command allows a program to become operational and perform other applications when a long loop like this is active in the software. The loop ends after all visual stimulus images have been displayed to the subjects. At the end of the given codes, the FormSynchronization function is recalled to terminate the synchronization between two software programs.

In the study, the quantitative time latencies were measured over 120 stimuli. According to the data obtained in three sessions, time latencies were measured as 0.0098, 0.0106 and 0.0085 ms averagely. And standard deviations of time latencies were 0.0082, 0.0106 and 0.0073, respectively, in each session. The results related to measured time latency are given in Table 2 and Fig. 8.

Table 2 Statistics about time latencies for 120 stimuli presentation
Fig. 8
figure 8

Mean square errors (MSE) for time latencies of 120 stimuli in different sessions

4 Discussions

In a lot of EEG researches, synchronization between stimuli presentation and EEG acquisition systems has always been a major concern when analyzing EEG signals, and for this reason, the extraction process for the EP is difficult. Therefore, experiments have to be well designed in EEG studies. In the published literature, while some EEG experiments are designed using non-specialized applications [10,11,12,13], some [14,15,16,17, 20, 24] are designed to use commercial and non-free software to meet stimuli presentation requirement. In this study, alternative software was developed to present stimuli. Moreover, this software enabled synchronization between stimuli presentation software and EEG recording software in the EEG experiments. While it was observed that the average time between the stimulus presentation and marking process is 2.27 ms, and the standard deviation was 0.70 ms in the commercial software, these values were 0.028 and 0.026 ms in the developed software, respectively. It was seen that the average time latency between stimuli presentation and the time for a marker was more precise in the proposed software. From this point of view, the study brought innovation to the field. Moreover, comparisons of the proposed software with the other competitors are given in Table 3. The features in the table are prepared using the web page of other competitors.

Table 3 Comparisons of STIPRESOFT software with the other competitors

In the experimental design, two main problems were confronted. One of them was the time accuracy problem occurring during the screening of stimuli, and the other was the time synchronization problem between stimuli presentation and EEG acquisition system. In previous studies, these problems were overcome either by using commercial software and devices or by some non-specialized methods. While commercial software was a burden to project budgets, non-specialized methods cause a lot of additional tiring works. In our study, these problems were overcome with the Windows API functions. The time accuracy problem was that the stimuli images could not be shown for the desired times on a screen. Because of this problem, time shifts occurred in the signals. The time accuracy problem was overcome using two Windows API functions (QPF, QPC). These functions enabled the time duration to be set in the frequency band. Thereby, more precise timing procedures were performed in the experiments. The second problem was the synchronization of the reaction times of stimuli presentation and EEG recording software. This problem was overcome with a newly developed function (PressCTRLwithKey) as a result of this study. Such that CTRL + R key combination was sent from STIPRESOFT to the EEG signal acquisition software at the start and the stop time of the experiment, and display times for stimuli images were saved to a text file for each run in the experiment.

Hardware and stimuli dependencies are crucial for the software used in neuroscience and psychology studies. Therefore, the developed software in the study has been designed as flexible in terms of hardware and stimuli types. Investigators can use other stimuli types instead of visual stimuli with this software. Moreover, STIPRESOFT can be integrated with EEG devices, which can be used for other projects. Accessing an input/output device from the developed software can be allowed. In our experimental procedure, the software has been used for sending the CTRL + R key combination between two computer systems. The software is also flexible enough to send other key combinations to the acquisition system. In neuroscience studies, timing is a critical issue for many experiments. Temporal precision is required to within a few milliseconds, or even in the sub-millisecond range [19]. The developed software presents a robust method to achieve very precise timing of events and to synchronize with other devices.

5 Conclusions

The developed synchronization-based stimuli presentation software (STIPRESOFT) in the study can be accessed from [23] for EEG studies, including stimuli presentations. This software can be integrated into the existing EEG devices in hand freely. Furthermore, when the developed software is employed, there is no need to use extra equipment in the EEG experiment. This software aims either to reflect the visual stimuli on the screen in random order or to synchronize the presentation times of stimuli with the times of signal recordings during the experiment. Through the software, signals can be easily decomposed according to the time stamps recorded in a behavioral file. Moreover, the developed software is novel and simple in terms of complexity compared to software that are provided free of charge [21] in the literature, and it is unpaid compared to commercial ones. And the proposed software is outperformed in terms of time latencies according to the competitors.

Consequently, the proposed software in this study is a comprehensive stimuli presentation software that can employ the Windows API library’s functions for neuropsychological experimental tasks. It is a modern tool providing well-defined paradigms that may be widely used, integrating with the existing acquisition system fully and providing synchronized trigger pulses.