AN ALGORITHM FOR AUTOMATED DETECTION OF DELAYED BRAIN ISCHEMIA INDICATOR FROM VIDEO-EEG MONITORING DATA

: In this work, we propose a new algorithm for detecting the indicator of delayed cerebral ischemia from video-EEG monitoring data. The proposed algorithm combines an algorithm for detecting the effect of interchannel time-frequency synchronization of wavelet spectrogram ridges of EEG signals and an algorithm for detecting motion artifacts in video recording frames. Using the EEG analysis algorithm, we identify an indicator that is used to predict the occurrence of ischemia. By analyzing the optical flow, we exclude time intervals in which erroneous fixation of ischemia indicators is possible. The developed algorithm was tested on the clinical data of video-EEG monitoring. The preliminary results obtained during testing confirm the fundamental possibility of detecting the ischemia indicators and the acceptable accuracy of detecting motion artifacts leading to an erroneous diagnosis.


INTRODUCTION
Diagnosis of vascular spasm and cerebral ischemia at its early stage is the most important step in the intensive treatment of patients with subarachnoid hemorrhage (SAH), since effective therapeutic and endovascular interventions are known to stop and reverse this process.One of the effective methods for early diagnosis of delayed cerebral ischemia in SAH is the analysis of electroencephalogram (EEG) signals (Sharbrough, 1975;Feigin, 2021).Changes in the EEG due to SAH are directly related to volumetric blood flow (Foreman, 2012).In the intensive care unit, using EEG, medical personnel can carry out continuous long-term monitoring of the functional state of the brain of a patient with SAH in order to diagnose and predict the development of delayed cerebral ischemia.In combination with periodic neuroimaging studies, EEG monitoring allows for early detection and prediction of the development of delayed ischemia, which makes it possible to start intensive treatment and stop its development.The main diagnostic and prognostic indicators of delayed ischemia on EEG monitoring are: (a) focal and regional slowing and decrease in the index and cessation of rapid activity; (b) decrease in alpha rhythm power variability; (c) decrease in the power ratio of alpha/delta rhythms; (d) epileptiform graphic patterns, including sporadic epileptiform discharges, lateralized rhythmic delta activity, lateralized periodic discharges, or generalized periodic discharges (Muniz, 2016;Rosenthal, 2018;Baang, 2022;Kim, 2022).
The analysis of the ridges of the spectrograms of wavelet transforms makes it possible to study the dynamics of the EEG, namely its amplitude, spectrum, and interchannel synchronization.Interchannel synchronization is typical for hyperrhythmic activity, which is pathological and can be considered as an analog of epileptiform activity in patients with severe brain damage.This indicator characterizes a focal impairment of the functional state of the brain, reflecting the occurrence of delayed cerebral ischemia (Obukhov, 2022).
Existing EEG monitoring systems provide real-time EEG recording with distortions caused by instrumental artifacts and artifacts of the patient's vital activity.To identify time intervals with artifacts caused by the patient's vital activity and the work of the medical staff (see Figures 1 and 2), it is advisable to analyze video recordings synchronous with the EEG (Wagley, 2020).This analysis requires an extremely large investment of time and labor of highly qualified neurophysiologists.In addition, the objectivity of such a diagnosis varies significantly between individual specialists.Therefore, for the widespread use of EEG, it is necessary to develop an automated system that can detect, classify, and predict in real time indicators of delayed ischemia after subarachnoid hemorrhage (Baang, 2022).However, due to artifacts, the development of automatic algorithms for the detection of delayed ischemia by EEG remains an unsolved problem.
There are a number of works in which, using the analysis of video recordings, the authors solve the problems of measuring the intensity of movement and motor activity of newborns, detecting clonic and myoclonic seizures in newborns, and recognizing respiratory arrest after an epileptic seizure (Cattani, 2017;Geertsema, 2020;van Westrhenen, 2020).In these works, the features necessary for event recognition are extracted by analyzing the optical flow.
In the works (Murashov 2019, Murashov 2019a), an algorithm was proposed for synchronous analysis of the EEG signal and video recording of patients with epilepsy for the detection and differentiation of epileptic seizures and chewing artifacts.The algorithm combines a threshold detector of brain activity based on wavelet spectrogram ridges and a threshold motion detector based on the magnitude of the optical flow.The results of the analysis of real clinical data showed the ability of this algorithm to distinguish reliably artifacts from epileptic seizures.
In this work, we propose a new algorithm for the automated detection of one of the indicators of delayed cerebral ischemia, namely, hyperrhythmic activity, from video-EEG monitoring data.The algorithm is based on a combination of an algorithm for detecting interchannel synchronization of EEG signals and an algorithm for detecting motion artifacts in video frames.

ALGORITHM FOR DETECTING THE DELAYED ISCHEMIA INDICATOR
As noted above, the delayed ischemia index detection algorithm combines an EEG signal analysis algorithm and an artifact detection algorithm.The EEG analysis algorithm reveals the effect of interchannel time-frequency synchronization of the ridges of wavelet spectrograms of EEG signals.The algorithm for detecting artifacts caused by the patient's vital activity and the work of medical personnel is based on an analysis of the optical flow value, which is calculated from video recordings.
Using the EEG analysis algorithm, we identify time intervals with interchannel synchronization, which are used in the diagnosis and prediction of ischemia.Analyzing the optical flow, we exclude time intervals in which erroneous fixation of time intervals with interchannel synchronization associated with ischemia is possible.

Analysis of EEG signals
As was noted in Section 1, interchannel synchronization reflects the occurrence of delayed cerebral ischemia (Obukhov, 2022).
In (Obukhov, 2022), the interchannel synchronization condition is formulated as follows: where The wavelet spectrogram of EEG signal ( , ) W t f is calculated using the Morlet complex mother function as The ridge of the wavelet spectrogram () Rt is defined as To identify time intervals in which the condition of interchannel synchronization is fulfilled, the following operations are performed: A detailed description of the method for detecting interchannel synchronization is given in (Obukhov, 2022).The interchannel synchronization detection algorithm can detect epileptiform graphic patterns, including sporadic epileptiform discharges, lateralized rhythmic delta activity, lateralized periodic discharges, and generalized periodic discharges.As mentioned in the introduction, these indicators are important both for the diagnosis and prognosis of the development of delayed cerebral ischemia after traumatic or non-traumatic subarachnoid hemorrhage.
In the next subsection, we will present an algorithm for detecting artifacts in video recording, which is necessary for the correct diagnosis of ischemia.

Video analysis
The applied motion artifact detection algorithm is a modification of the algorithm proposed in (Murashov, 2019) for diagnosing epileptic seizures.Artifacts are detected by the value of the indicator characterizing the degree of mobility of the region of interest.The region of interest is the part of the frame that includes the location of the patient.An indicator of the mobility of the region of interest is the total value of the optical flow calculated for each frame of the video sequence.The indicator measurement model is represented by the following relationship: .For smoothing, we use a discrete version of the Kalman-Bucy filtering algorithm, since it provides an optimal estimate in terms of the minimum error variance.The decision to detect an artifact is made according to the threshold rule: In the next subsection, we propose an algorithm for detecting delayed ischemia indicator, combining the algorithms described in subsections 2.1 and 2.2.

Algorithm for detecting the delayed ischemia indicator
Based on the algorithms described in subsections 2.1 and 2.2, we propose an algorithm for detecting hyperrhythmic activity, which is one of the diagnostic indicators of delayed ischemia.EEG signals and video recording are analyzed synchronously.
The algorithm includes the following steps:  3), (4) (see subsection 2.2); d) if conditions (1) and ( 3) are satisfied at time t , then a decision is made that an artifact caused by the patient's vital activity or the work of medical personnel has been found; e) if condition (1) is met and condition (3) is not met, then we make a decision that a feature of hyperrhythmic activity, which is an indicator of cerebral ischemia, is detected.
The block diagram of the algorithm is shown in Figure 3.
The next section will describe a computational experiment that confirms the efficiency of the proposed algorithm.

COMPUTATIONAL EXPERIMENT
In order to confirm the effectiveness of the proposed algorithm for detecting indicators of delayed cerebral ischemia, we conducted a computational experiment.The experiment consists of two parts.In the first part, we evaluated the effectiveness of detecting motion generated by the patient's vital activity and the work of medical personnel.In the second part of the experiment, we evaluated the possibility of reliably detecting hyperrhythmic activity, which is an indicator of cerebral ischemia.

Motion Detection
To evaluate the effectiveness of the motion detection algorithm, we analyzed 12 fragments of video recordings of two patients with a duration of up to 10 minutes each.The analyzed videos contain events related to the movement of patients and the work of medical personnel.These events can generate distortions in the EEG signals and lead to an erroneous assessment of the patient's condition.Examples of frames that capture these events are shown in Figures 1 and 2. Figure 1 shows a video frame in which the patient touches the bandage that covers the electrodes.Here the blue arrows show the vector field of the optical flow that characterizes the motion.Figure 2 shows the work of medical personnel with EEG electrodes.These types of events can cause signal distortion.
In the first part of the experiment, we obtained the following results.In the studied video recordings, experts identified 103 events associated with movement in the frame.Of the 103 events identified by the experts, the algorithm correctly detected 101 events, missed two events, and falsely detected 5 events.We calculated the following artifact detection quality indicators: precision, recall, accuracy, and F1 score.The results are shown in Table 1.According to medical experts, these results are acceptable for diagnosing cerebral ischemia by synchronous analysis of video recordings and EEG signals.

Detection of the delayed ischemia indicator
In the second part of the experiment, fragments of ten-day video-EEG monitoring data of two patients obtained in clinical conditions were used.Patients were in a state of wakefulness.We analyzed signals in the prefrontal leads Fp1 and F3 of the left hemisphere of the brain.The first patient was not diagnosed with ischemia, while the second patient was diagnosed with ischemia.At this stage of the experiment, the results of the work of the algorithm for detecting interchannel synchronization and the algorithm for detecting motion artifacts were combined.The duration of the analyzed video-EEG recordings of the first patient was 55 minutes (3300 seconds).In these recordings, 184 intervals were detected in which signal synchronization was observed in leads Fp1 and F3 at frequencies from 0.6 to 3.3 Hz in lead FP1 and from 0.5 to 3.3 Hz in lead F3.At the same time, 176 synchronization intervals fell into the intervals in which motion was detected, and conditions (1) and (3) of the algorithm for detecting the indicator of delayed ischemia were fulfilled.Accordingly, in this case, conditions (1) and (3) were not fulfilled simultaneously only on eight synchronization intervals with a duration of 0.02 to 0.42 seconds.Thus, 176 out of 184 (that is, 95.6 percent) occurrences of the interchannel synchronization effect are artifacts and should be excluded from further analysis.
The operation of the algorithms for detecting interchannel synchronization and the algorithm for detecting motion artifacts on a fragment of video EEG data of the first patient is illustrated in Figure 4.The results of the algorithm for detecting the indicator of delayed ischemia are shown in Table 2.
The data shown in Tables 1 and 2 show the following.First, motion artifacts are detected with acceptable accuracy.Secondly, time intervals in which the effect of interchannel synchronization occurs due to the patient's vital activity or the work of medical personnel can be detected and excluded from further analysis.It should be noted that the exclusion from the analysis of the intervals in which artifacts were found does not lead to a loss in the accuracy of diagnostic decisions, since their total duration is significantly less than the duration of the video EEG recording, which is up to ten days.

CONCLUSIONS
are computed in the frequency range from 0.5 to 22 Hz; c) to find synchronized fragments of the EEG signal, we compute the modulus of the frequency difference at the points of the ridges of wavelet spectrograms for pairs of leads (synchronization condition of the pair of channels (see condition (1)) is checked.
n = optical flow values along the axes , XY for a frame with a number of n in a pixel with coordinates   , xy The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLVIII-2/W3-2023 ISPRS Intl.Workshop "Photogrammetric and computer vision techniques for environmental and infraStructure monitoring, Biometrics and Biomedicine" PSBB23, 24-26 April 2023, Moscow, Russia   n  = Gaussian noise N = number of frames in video Here, we use the Lucas-Kanade algorithm (Lucas, 1981) to calculate n .Since there is a noise component in the function () Jn , when detecting events, it is necessary to use the smoothed value of the mobility indicator () Jn 

Ĵ
= the average value of ˆ() Jt in a fragment of a video sequence with low scene dynamics  = standard deviation of value ˆ condition (1) and detecting synchronization of EEG signals in two channels at time t ; c) analysis of the corresponding frames of the video recording, calculation of the value of the mobility indicator ˆ() Jt according to formula (2), and verification of conditions (

Figure 1 .
Figure 1.An example of a region of interest in video frames.The figure shows the movement of the patient's hand (blue arrows represent the vector field of the optical flow characterizing the movement), which affects the EEG electrodes and can cause signal distortion.

Figure 2 .
Figure 2.An example of a region of interest in video frames.The figure shows the work of medical personnel with EEG electrodes, which generates signal distortions.As in Figure1, the blue arrows represent the optical flow vector field characterizing the movement.
Figures 4(a) and 4(b) illustrate the high correlation between EEG interchannel synchronization and motion in a video frame.

Figure 3 .
Figure 3. Flowchart of the algorithm for detecting delayed ischemia indicator.The duration of the analyzed video-EEG recordings of the second patient diagnosed with ischemia was 20 minutes (1200 seconds).The video shows a patient at rest and medical staff performing a head bandage.The algorithm for detecting interchannel synchronization identified 856 intervals in which signal synchronization was observed in leads Fp1 and F3 at frequencies from 1.1 to 2.6 Hz. 309 out of 856 (i.e., 36.1 percent) synchronization intervals coincided with the intervals in which the movement associated with the work of medical personnel was detected, and conditions (1) and (3) of the delayed ischemia indicator detection algorithm were simultaneously met.We consider these synchronization intervals as artifacts and exclude them from further analysis.The operation of the algorithms for detecting interchannel synchronization and the algorithm for detecting motion artifacts on a fragment of video EEG data of the second patient is

Figure 4 .
An illustration of the operation of the algorithms for detecting interchannel synchronization and the algorithm for detecting motion artifacts on a fragment of video EEG data of a patient without ischemia: (a) synchronized fragments of wavelet spectrogram ridges in leads Fp1 and F3 of the left hemisphere; (b) plot of the scene motion index and detected events associated with motion in the frame.

AFigure 5 .
new algorithm for detecting the indicator of delayed cerebral ischemia based on video-EEG monitoring data has been developed.The proposed algorithm is based on a combination of the algorithm for detecting inter-channel synchronization of EEG signals and the algorithm for detecting motion artifacts in video frames.A computational experiment was carried out on the clinical data of video-EEG monitoring.The operability of the proposed algorithm has been confirmed.The experiment showed that the accuracy of detecting motion artifacts is 94 percent.Preliminary results have been obtained that confirm the fundamental possibility of detecting an indicator used to predict the occurrence of ischemia, as well as the possibility of excluding artifacts that lead to erroneous fixation of features of ischemia.Further research will be aimed at studying the properties of the proposed algorithm on a more representative sample of video-EEG monitoring data.An illustration of the operation of the algorithms for detecting interchannel synchronization and the algorithm for detecting motion artifacts on a fragment of video-EEG data of a patient with diagnosed ischemia: (a) synchronized fragments of wavelet spectrogram ridges in leads Fp1 and F3 of the left hemisphere; (b) plot of the scene motion index and detected events associated with motion in the frame.

Table 1 .
Values of quality measures calculated when detecting motion artifacts.International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLVIII-2/W3-2023 ISPRS Intl.Workshop "Photogrammetric and computer vision techniques for environmental and infraStructure monitoring, Biometrics and Biomedicine" PSBB23, 24-26 April 2023, Moscow, Russia

Table 2 .
The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLVIII-2/W3-2023 ISPRS Intl.Workshop "Photogrammetric and computer vision techniques for environmental and infraStructure monitoring, Biometrics and Biomedicine" PSBB23, 24-26 April 2023, Moscow, Russia The results of the detection of the delayed ischemia indicator.