Webpage-based general sleep polysomnogram visualization and labeling method and system

CN118038459BActive Publication Date: 2026-09-25ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410200912.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-23
Publication Date
2026-09-25
Estimated Expiration
2044-02-23

AI Technical Summary

Technical Problem

该类软件稳定性高且功能丰富,但是也存在许多问题,例如不同医院睡眠多导监测仪器数据格式不统一,无法通用;客户端软件需要本地安装,可拓展性差且升级成本高;客户端软件不具备跨平台性,数量有限且移动性差

Benefits of technology

[0030]相比于医院里用的基于C/S架构的可视化和标注软件,本发明方法基于B/S架构设计,可以突破地点和数量的局限,使用方便且移动性强。相比于现有其他基于B/S架构的可视化平台,本发明允许用户自主上传任何以EDF格式文件,且可在线人工标注和下载,本发明的功能更丰富,可操作性更强,此外目前并未查询到有实现该功能的可视化平台。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118038459B_ABST
    Figure CN118038459B_ABST
Patent Text Reader

Abstract

The application discloses a webpage-based general sleep polysomnogram visualization marking method and system. The specific process is as follows: sleep polysomnogram files are uploaded through a toolbar, the application automatically analyzes the uploaded files and extracts a PSG data list with a time length of 30s, and the obtained PSG data list is subjected to channel-level normalization operation and then the data of each channel is rendered point by point. The rendered sleep polysomnogram can also be subjected to window switching, scaling and jumping operation through mouse and keyboard operation to meet different view requirements of users. In addition, the system also meets various sleep interpretation requirements of users, such as sleep staging and sleep event marking, and the interpretation results can be downloaded and saved. The application has the advantages of cross-platform, high expansibility, user-friendly operation and the like, is very suitable for the sleep medical field, and greatly improves the work efficiency of workers and researchers in the related field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of medical data processing, and in particular relates to a web-based general method and system for visualizing and annotating polysomnography signals. Background Technology

[0002] In today's society, sleep quality has become a widespread concern in daily life. Clinically, the diagnosis of sleep-related disorders relies on polysomnography (PSG). Technicians interpret the physiological signals from different channels in the PSG to diagnose the presence of sleep disorders. Visualization and annotation of PSG signals are crucial aspects of manual interpretation. Clinically, PSG typically involves continuously collecting multiple sleep physiological parameters and pathological events using a polysomnography device, followed by visualization using accompanying client software. While this software is highly stable and feature-rich, it also has several drawbacks. For example, data formats from different hospitals' polysomnography devices are inconsistent, making them incompatible; the client software requires local installation, resulting in poor scalability and high upgrade costs; and the client software lacks cross-platform compatibility, has a limited number of versions, and poor portability.

[0003] Web-based polysomnography visualization platforms can solve the problems mentioned above with client software. However, visualization platforms for medical signal data on the market are usually designed for a specific dataset, and users cannot upload their own files or perform online manual annotation, resulting in poor usability. Summary of the Invention

[0004] The purpose of this invention is to solve the problems existing in the prior art and to provide a web-based universal sleep polysomnography visualization annotation method and system.

[0005] The specific technical solution adopted in this invention is as follows:

[0006] In a first aspect, the present invention provides a web-based general method for visualizing and annotating sleep polysomnography signals, comprising the following steps:

[0007] S1. Upload the polysomnography file to be visualized and determine whether the file content is empty. If the file content is empty, a prompt box will pop up to prompt the user to re-upload. If the file content is not empty, further determine the file type of the polysomnography file. If the file type is a PSG file stored in standard EDF format, convert the polysomnography file into processable PSG data, read the channel name, sampling rate, channel unit, and channel data information of all channels in the PSG data, and obtain the maximum and minimum values ​​of each channel data through the maximum and minimum value algorithm. At the same time, initialize the start and end times of the display window. Otherwise, a prompt box will pop up to prompt the user to re-upload.

[0008] S2. Calculate the start and end points of the data drawn for each channel based on the start and end times of the window and the sampling rate of each channel. Then, truncate the data for each channel according to the start and end points. After truncation, normalize the data for each channel using the maximum and minimum values ​​of each channel data and save all the normalized channel data into a data list.

[0009] S3. Using the start and end times of the window as the start and end points of the horizontal axis, generate a horizontal axis coordinate list corresponding to each channel based on the number of data points in the data list; generate a vertical axis coordinate list with a preset interval starting from 0, the length of the vertical axis coordinate list being the same as the number of PSG data channels; encapsulate the horizontal axis coordinate list and the data list into a data trajectory, encapsulate the vertical axis coordinate list into a frame layout, and render the window screen based on the data trajectory and the frame layout;

[0010] S4. When the user modifies the rendered window display through key operations, the window control function captures the key operations and implements the corresponding window transformation.

[0011] S5. After the window is confirmed by key operation, when the user triggers sleep stage labeling through a new key operation, the sleep stage listening and processing function captures the new key operation, saves the sleep stage labeling result and renders it; when the user triggers sleep event labeling through mouse operation, the sleep event listening and processing function captures the corresponding mouse operation, saves the sleep event labeling result and renders it.

[0012] S6. After the user clicks the save button to encapsulate the PSG data into form data, the PSG data is uploaded to the server for storage via the Fetch API. After obtaining the sleep staging annotation results and the sleep event annotation results, the user clicks the corresponding button to generate the sleep staging annotation file and the sleep event annotation file, thus completing the web-based general sleep polysomnography visualization annotation.

[0013] Preferably, the algorithm for finding the maximum or minimum value first saves all channel data into an array format to obtain a channel array, and sorts each channel array in ascending order. The value at the 0.1% position in each channel array is selected as the minimum value, and the value at the 99.9% position is selected as the maximum value.

[0014] As a preferred method, when normalizing the data of each channel, it is determined whether the maximum and minimum values ​​of the current channel data are equal: if they are equal, all data of the current channel are replaced with preset fixed values; if they are not equal, the current channel data is normalized.

[0015] Preferably, the preset fixed value is 0.5.

[0016] Preferably, the window control function listens for and obtains user key press information, and executes the corresponding key operation through conditional statements.

[0017] Preferably, the preset interval is 1.

[0018] Preferably, the window transformation includes window switching, window scaling, and window navigation.

[0019] Secondly, the present invention provides a web-based universal sleep polysomnography visualization and annotation system, comprising:

[0020] The data upload module is used to upload polysomnography signal files to be visualized.

[0021] The data preprocessing module is used to determine whether the content of the polysomnography file is empty. If the file content is empty, a prompt box will pop up to prompt the user to re-upload. If the file content is not empty, the module will further determine the file type of the polysomnography file. If the file type is a PSG file stored in standard EDF format, the polysomnography file will be converted into processable PSG data. The module will read the channel name, sampling rate, channel unit, and channel data information of all channels in the PSG data, and obtain the maximum and minimum values ​​of each channel data through an extremum algorithm. At the same time, the start and end times of the display window will be initialized. Otherwise, a prompt box will pop up to prompt the user to re-upload. The module will calculate the start and end points of the data plotted for each channel based on the start and end times of the window and the sampling rate of each channel, and truncate the data of each channel according to the start and end points. After truncation, the maximum and minimum values ​​of each channel data will be used to normalize the data of each channel, and the normalized data of all channels will be saved as a data list.

[0022] The image rendering module is used to generate a horizontal axis coordinate list corresponding to each channel based on the number of data points in the data list, using the start and end times of the window as the start and end points of the horizontal axis; generate a vertical axis coordinate list with a preset interval starting from 0, the length of the vertical axis coordinate list being the same as the number of PSG data channels; encapsulate the horizontal axis coordinate list and the data list into a data trajectory, encapsulate the vertical axis coordinate list into a frame layout, and render the window image based on the data trajectory and the frame layout;

[0023] The window control module is used to capture the key operation and implement the corresponding window transformation when the user modifies the rendered window display through key operation.

[0024] The manual annotation module is used to capture new key presses that trigger sleep staging annotation after the user confirms the window via key operation. The sleep staging monitoring and processing function then captures the new key presses, saves the sleep staging annotation results, and renders them. Similarly, when the user triggers sleep event annotation via mouse operation, the sleep event monitoring and processing function captures the corresponding mouse operation, saves the sleep event annotation results, and renders them. The data storage module is used to upload the PSG data to the server for storage via the Fetch API after the user clicks the save button to encapsulate the PSG data into form data. Once the sleep staging annotation results and sleep event annotation results are obtained, the user clicks the corresponding button to generate the sleep staging annotation file and sleep event annotation file, thus completing the web-based general sleep multichannel signal visualization annotation.

[0025] Thirdly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a web-based general sleep polysaccharide visualization annotation method as described in any of the solutions of the first aspect above.

[0026] Fourthly, the present invention provides a computer electronic device, which includes a memory and a processor;

[0027] The memory is used to store computer programs;

[0028] The processor is configured, when executing the computer program, to perform the web-based general sleep polysaccharide visualization annotation method as described in any of the first aspects above.

[0029] Compared with the prior art, the present invention has the following advantages:

[0030] Compared to the C / S architecture-based visualization and annotation software used in hospitals, the method of this invention is based on a B / S architecture, which can overcome the limitations of location and quantity, and is convenient and highly mobile. Compared to other existing B / S architecture-based visualization platforms, this invention allows users to independently upload any EDF format file, and enables online manual annotation and downloading. This invention has richer functions and stronger operability. Furthermore, no visualization platform that implements this function has been found so far. Attached Figure Description

[0031] Figure 1 This is a schematic diagram of the steps of the present invention;

[0032] Figure 2 This is a flowchart of the multichannel sleep signal data uploading and data preprocessing process according to an embodiment of the present invention;

[0033] Figure 3This is a flowchart illustrating the visualization of multichannel sleep signal data according to an embodiment of the present invention.

[0034] Figure 4 This is a window control timing diagram according to an embodiment of the present invention;

[0035] Figure 5 This is a flowchart of the manual annotation process according to an embodiment of the present invention;

[0036] Figure 6 This is a visualization page layout diagram of multichannel sleep signals according to an embodiment of the present invention;

[0037] Figure 7 This is a diagram showing the sleep staging results of an embodiment of the present invention;

[0038] Figure 8 This is a diagram showing the annotation results of leg movement events according to an embodiment of the present invention;

[0039] Figure 9 This is a diagram showing the user operation toolbar in an embodiment of the present invention;

[0040] Figure 10 This is a complete interface display diagram including user operations in an embodiment of the present invention;

[0041] Figure 11 This is a module relationship diagram of the present invention. Detailed Implementation

[0042] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. Technical features in the various embodiments of the present invention can be combined accordingly without mutual conflict.

[0043] The purpose of this invention is to provide a user-friendly, highly operable, and scalable method for visualizing and annotating polysomnography data. This method is developed based on a B / S architecture, which overcomes the shortcomings of poor client software distribution and difficulty in expansion and maintenance. It also supports user-uploaded EDF format files, online manual annotation, and result file download. Compared to existing polysomnography data visualization methods, this method offers richer functionality and greater usability.

[0044] In a preferred embodiment of the present invention, a web-based general method for visualizing and annotating sleep polysomnography is provided, such as... Figure 1 As shown, the specific steps are as follows:

[0045] S1. Upload the sleep polysomnography (PSG) file to be visualized and check if the file content is empty. If the file content is empty, a prompt box will pop up to prompt the user to re-upload. If the file content is not empty, further determine the file type of the sleep polysomnography (PSG) file. If the file type is a standard EDF format polysomnography (PSG) file, use the EDF.js toolkit to convert the sleep polysomnography (PSG) file into processable PSG data, read the channel name, sampling rate, channel unit, and channel data information of all channels in the PSG data, and obtain the maximum and minimum values ​​of each channel data through the extreme value algorithm. At the same time, initialize the start and end times of the display window. Otherwise, a prompt box will pop up to prompt the user to re-upload.

[0046] It should be noted that in step S1 of this invention, an EDF format file is uploaded first, and all cached file information is cleared. An H5 file upload button is created, allowing users to select any file to be displayed in the file system. Uploadable files include one-dimensional medical polysomnography (PPS) signals and sleep stage label data, uploaded in a specific order. The one-dimensional medical polysomnography signal can be any file stored in the EDF standard format, while the sleep stage label data is a text file stored in numerical form. The correspondence between the numbers and stages is as follows: '0' represents wakefulness (W), '1' represents non-rapid eye movement (NREM) stage 1 (N1), '2' represents NREM stage 2 (N2), '3' represents NREM stage 3 (N3), and '5' represents rapid eye movement (R) stage (R). The filename is obtained through the file upload process, and the file extension is used to determine if it is an "EDF file". Files that meet the standards enter the data preprocessing stage. The EDF.js toolkit in JavaScript reads the file content and parses the uploaded file data stream. Information is filtered from the parsed PSG data, and useful information is stored in variables and data structures defined in the global area. If a file does not meet the requirements or the user has not selected a file, a prompt will appear requiring the user to re-upload the file. Only after the sleep polygraph has been rendered can the matching sleep stage tag file be uploaded. The stage content will be synchronously rendered onto the sleep polygraph according to the timeline.

[0047] It should be noted that in this embodiment, after uploading the EDF format file, considering the large amount of PSG data (up to 900MB per file), PSG data preprocessing is performed directly on the front end without interaction with the back end. Specifically, after converting the uploaded file data stream into readable PSG data using a toolkit, the names, sampling rates, units, and raw data of all PSG channels are read and stored in their respective data structures. It is important to note that before data preprocessing, the cached content of the previously uploaded file needs to be cleared, and all parameters and data structures reinitialized to prevent unexpected errors.

[0048] It should also be noted that in step S1 of the present invention, the above-mentioned algorithm for finding the maximum and minimum values ​​first saves the channel data into an array format to obtain a channel array, and sorts each channel array in ascending order. In order to eliminate the interference of outliers, the actual maximum and minimum values ​​are not selected in each channel array, but the value at the 0.1% position is selected as the minimum value and the value at the 99.9% position is selected as the maximum value.

[0049] S2. Calculate the start and end points of the data plotted for each channel using the start and end times of the window and the sampling rate of each channel. Then, truncate the data for each channel based on the start and end points. After truncation, normalize the data for each channel using the maximum and minimum values ​​of each channel data and save all the normalized channel data into a data list.

[0050] It should be noted that in step S2 of this invention, in addition to considering that a PSG file contains multiple signal channels with different signal amplitudes, if a highly readable sleep polygraph is to be presented, the data needs to be normalized. That is, by calculating the maximum and minimum values ​​of the data in each channel and compressing the data of each channel to 0 to 1. It should be noted that this refers to mathematical values, not physical values. The units of each channel are not exactly the same. Therefore, data points at the same height are displayed on the sleep polygraph. The overall presentation effect is that the amplitude range of all channels is the same, but the physical size they represent is not the same.

[0051] It should also be noted that in step S2 of this embodiment, when normalizing the data of each channel, the first step is to determine whether the maximum and minimum values ​​of the current channel data are equal. If they are equal, all data of the current channel are replaced with preset fixed values. If they are not equal, all data of the current channel are normalized, that is, all data are uniformly subtracted from the minimum value of the current channel data, and then divided by the difference between the maximum and minimum values ​​of the current channel data. The above normalization calculation method is as follows:

[0052]

[0053] Among them, y oThis represents the normalized data for the current channel; y i This represents the data before normalization of the current channel; y min This represents the minimum value of the current channel data; y max This indicates the maximum value of the current channel data.

[0054] It should also be noted that, in this invention, the aforementioned preset fixed value can be set according to the actual situation. In this embodiment, the preset fixed value is set to 0.5.

[0055] It should be further noted that, considering the large amount of data in some datasets, in order to improve rendering speed, global data will not be normalized in advance. Instead, during image rendering, only the data in the current window will be normalized in real time.

[0056] S3. Using the start and end times of the above window as the start and end points of the horizontal axis, generate a horizontal axis coordinate list for each channel based on the number of data points in the data list; generate a vertical axis coordinate list with a preset interval starting from 0, the length of the vertical axis coordinate list being the same as the number of PSG data channels; encapsulate the above horizontal axis coordinate list and the above data list into a data trajectory, encapsulate the above vertical axis coordinate list into a frame layout, and render the window screen based on the above data trajectory and the above frame layout.

[0057] It should be noted that in step S3 of this invention, after storing all information of the PSG file into global variables and data structures, the Plotly plotting toolkit is used to render the data of all channels of the current window screen point by point in real time. Global data is used to draw the current window, with the default drawing window being a sleep polygraph spanning 0-30 seconds. The drawing process is divided into three stages:

[0058] 1) Generate frame layout

[0059] The framework layout mainly includes the canvas background, title, interactive modes (drag and drop, zoom), and horizontal and vertical axis style settings. The vertical axis coordinate values ​​are calculated, and since the data range is 0-1, the vertical axis coordinates of each channel are set to differ by 1.5. Furthermore, because this invention supports online manual annotation of sleep stages and sleep events, when setting the canvas background, a global data structure related to the annotation events needs to be defined in advance, and an event listener function needs to be set. When the corresponding event is triggered, the corresponding operation will be read and the data will be saved in the event-related data structure. Adding the generated event-related data structure to the framework layout achieves the online manual annotation effect.

[0060] 2) Generate data trajectory

[0061] The data trajectory mainly consists of a horizontal axis coordinate list and a data list. Since the current window only needs to display 30 seconds of sleep polygraph data, only a segment of the global signal variables needs to be extracted. Add the two parameters (horizontal axis coordinate list and data list) to the data trajectory, and set the channel names and curve colors to make the rendered image more aesthetically pleasing. Specifically:

[0062] ① The data list is a local variable that only stores all signal data for the current window. Since each sleep polygraph has multiple channels, a loop structure is used to iterate through and extract data from the global signal variable. It's important to note that because the sleep polygraph data is rendered from top to bottom in the display window, while the coordinate axis is positive from smallest to largest, the iteration of the global signal variable is in reverse order. Two global variables, start and end times, are predefined to control the time period of the current window, with default initial values ​​of 0 and 30 seconds. Within the loop, the channel name and frequency of the current channel are retrieved, and the number of data points is calculated based on the current time length, thus extracting the corresponding number of data points and adding them to the data list. Furthermore, because the amplitude range of each channel is different, to display the data at a fixed channel position, local normalization of each channel's data segment is needed to limit it to the range of 0-1.

[0063] ② Calculate the horizontal axis value. Since the number of data points in different channels is different within the same 30 seconds, if you want them to be displayed in the same time period, the minimum interval needs to be obtained by dividing the time length and frequency.

[0064] 3) Generate or re-render the canvas

[0065] After uploading the file, the canvas creation function will be automatically called to render the data window from 0 to 30 seconds. Each time the content of the current window is changed, the above two operations are required to update the corresponding global variables and data structures, and then the canvas refresh function is called to re-render the canvas.

[0066] This invention considers the possibility of excessively large PSG data volumes, which would prevent complete rendering. Therefore, it employs "time-sharing rendering" to reduce rendering pressure and "local normalization" to improve rendering speed and usability. Simultaneously, it controls the content displayed in the window by defining the start and end times. The specific principle of time-sharing rendering is to control the time period displayed in the current window by defining the start and end times, rendering only the image within that time period. Since the AASM standard specifies that sleep staging is based on 30-second epochs, the window size is defaulted to the data within 30 seconds. This means that each drawing only needs to render the current 30-second window, significantly reducing rendering pressure. Furthermore, by changing the two time points, corresponding data is extracted from the global dataset, ensuring that switching to any data period does not affect rendering speed.

[0067] It should also be noted that, in this invention, the preset interval can be set according to the actual situation. In this embodiment, the preset interval is set to 1.

[0068] S4. When the user modifies the rendered window display through key operations, the window control function captures the key operations and implements the corresponding window transformations, including window switching, window scaling, and window navigation.

[0069] It should be noted that the window control function of this invention listens for and obtains user key press information, and executes the corresponding key operations through conditional statements. All key operations first modify the start and end times of the current window, and then re-execute the start and end point calculation, channel data interception, and screen rendering based on the start and end times.

[0070] It should be noted that step S4 of this invention is used to change the currently displayed screen. All button operations in this step are divided into two steps: changing the current global start time variable and the global end time variable, and re-executing image rendering. The window transformation categories that can be implemented in this step include the following:

[0071] 1) Window Switching: The "left" and "right" buttons switch windows left and right, the "up" button switches to the last window, and the "down" button switches to the first window. All window transitions implemented using this method can be labeled. When the user presses a button, the button event listener function retrieves the corresponding value. If the user switches to the left, both global variables are decremented by 30; similarly, if the user switches to the right, both variables are incremented by 30.

[0072] It's important to note that if the global start time variable is less than 0, it will be automatically corrected to 0 and a message "Start point reached" will be displayed. If the global end time variable is greater than the global length, it will be automatically corrected to the global length and a message "End point reached" will be displayed. Additionally, when a user marks the current window as a sleep phase, the system will automatically jump to the next window to improve efficiency.

[0073] 2) Window Scaling: Window scaling refers to shortening or lengthening the data range that the current window can display from the original 30 seconds. In this embodiment, the "i" key is set to shrink the window, and the "o" key is set to enlarge the window. Each key press changes the window by 10 seconds. Specifically, the start time remains unchanged, and the end time is decreased or increased by 10 seconds. Similar to the window switching left and right operations, the window scaling operation also has a corresponding key event listener function to constantly obtain the corresponding key presses and call the corresponding function to modify the global time function.

[0074] 3) Window Jump: The window jump function allows you to jump to any point in time within the current data entry for display. The user enters the desired time in the text box on the page, then clicks the jump button. The jump listener function retrieves the data and modifies the current global start time variable.

[0075] In addition to the three window transformation categories mentioned above, this embodiment of the invention provides two additional new window transformation categories: correction operation and window seeking operation. Specifically, the correction operation takes into account the AASM standard's requirement that sleep stage labeling time is 30 seconds. Therefore, it stipulates that if the current window needs to be labeled for sleep stage, the start time must be a multiple of 30 seconds. If the user's actions, such as jumping or other operations, do not conform to this rule, pressing the 'r' key triggers a one-click correction function, calculates the nearest valid window time point to the current start time, and jumps to the nearest window that meets the stage standard, thus resetting the window. The window seeking operation refers to the function triggered when the user presses the 's' key. The window seeking function calculates and jumps to the first window from left to right that has not been labeled for sleep stage, allowing the search to determine if there are any unlabeled windows in the current data.

[0076] S5. After the window is confirmed by key operation, when the user triggers sleep stage labeling through a new key operation, the sleep stage listening and processing function captures the corresponding new key operation, saves the sleep stage labeling result and renders it; when the user triggers sleep event labeling through mouse operation, the sleep event listening and processing function captures the corresponding mouse operation, saves the sleep event labeling result and renders it.

[0077] It should be noted that step S5 of this invention mainly implements two major functions: sleep staging and sleep event annotation. Sleep staging annotation is triggered by pre-defined keyboard key presses. The sleep staging listening and processing function obtains the key press information and converts it into the corresponding staging number. Simultaneously, the current stage index is calculated by dividing the current window's start time by 30, and the sleep staging data is stored in the corresponding position of the "sleep staging annotation array". Next, the frame layout and background color are reset, and a sleep staging marker is added to the upper left corner of the canvas to distinguish it from unannotated stages. Finally, the canvas is re-rendered. Specifically, the canvas background of the current window is rendered as light yellow, and the current sleep stage is marked in the upper left corner, with corresponding relationships such as '0-W' (i.e., '0' represents wakefulness (W)), '1-N1', '2-N2', '3-N3', and '5-R'. Different sleep stages are separated by red vertical lines. The sleep staging annotation result list and the sleep staging annotation time list are defined as global variables, respectively recording the sleep staging annotation results and the corresponding time windows.

[0078] It should be noted that since the window control function may input the above 5 numbers, in order to prevent automatic phase marking, the sleep phase monitoring function needs to determine whether the current jump input text box is selected, in order to avoid possible accidental operation.

[0079] Sleep event annotation is triggered by mouse hovering. The selected area is rendered as a light purple rectangle. The size and position of the rectangle are corrected and standardized by the corresponding algorithm. Users can freely hover in the corresponding channel. In addition, a rectangle fusion algorithm is designed so that users can modify it based on the original. The sleep event annotation result list is defined as a global variable to record the annotation time period.

[0080] This embodiment uses leg movement events in sleep events as an example to illustrate the relevant annotation process. Other sleep event annotation functions can be extended. Leg movement events are determined using electromyography (EMG) sequence data of the left and right legs. In this embodiment, pre-written program code limits the triggering of the leg movement event listening and processing function only when the mouse selects on the EMG sequence data of the left and right legs. The judgment principle is to obtain the y-axis range of the channel in the composition of the drawn image, calculate the ordinate of the center point of the current area to determine whether the sliding area is within the specified channel: if the center of the mouse selection area is within this range, it is considered a valid selection. If it is, the x-coordinates of the start and end points of the selected area need to be obtained to calculate the coordinates of the four right-angle points of the rectangle, and then a standard rectangle is drawn; if it is an invalid selection, no rectangle is drawn. Next, the coordinates of the right-angle points are stored in the "Leg Movement Event Annotation Array" in order, ensuring that the array is ordered and there is no coordinate overlap. Finally, the frame layout is reset, the rectangle coordinates are added, and the canvas is re-rendered.

[0081] In addition, this embodiment also incorporates a rectangle merging algorithm. When a user needs to extend the duration of an event segment, the algorithm merges the added time segment into the original time segment. The basic principle of this algorithm is to check whether a new rectangle intersects with existing data in the array list each time it is drawn. If it does, the union is used for replacement; otherwise, the rectangle is added to the end. After maintaining the array list, the screen is re-rendered. Furthermore, all manual annotation operations are stored in the global area with a suitable data structure for subsequent downloading and saving.

[0082] S6. After the user clicks the "Save" button to encapsulate the above PSG data into form data, the above PSG data is uploaded to the server for storage via the Fetch API. After obtaining the sleep staging annotation results and the sleep event annotation results (after the manual annotation of events is completed), the user clicks the "Download Sleep Staging Annotation Results" button to generate a sleep staging annotation file saved in digital form, and the user clicks the "Download Sleep Event Annotation Results" button to generate a sleep event annotation file containing the start and end points of time, thus completing the web-based general sleep polysomnography visualization annotation.

[0083] It should be noted that step S6 of this invention is used to save and download the PSG data and annotation data results uploaded by the user. The PSG data is uploaded to the server via the HTTP protocol and saved in the file system as an EDF format file, while the manually annotated data is downloaded directly in the browser to generate a TEXT file and is not saved on the server.

[0084] Specifically, for PSG data, an H5 page creates a save button. Since the uploaded PSG data file is stored in a form component, clicking the "Save" button on the page sends a file upload request, retrieves the form data, and prevents the form from submitting by default. The file data, i.e., the PSG file data stream, is obtained from the form, encapsulated into a FormData class, and then sent to the backend using the FetchAPI. At this point, the file has been transferred to the backend. The backend is written using the Django framework and receives the data sent from the frontend through a RESTful API. It then performs format conversion, and Python code saves the file in EDF format to the specified file directory.

[0085] For manually labeled data, sleep stage labeling results and sleep event labeling results are stored in a global data structure, and JavaScript code is directly written on the front end to implement the download link. For example, for sleep stage labeling results, clicking the "Download Sleep Stage Labeling Results" button triggers the corresponding function, which obtains the data, converts it into a text file, and downloads it to the browser. The file content represents the sleep stage results in numerical form, which can be re-uploaded and displayed later.

[0086] The present invention will now demonstrate the specific implementation and technical effects of the web-based general sleep polysomnography visualization annotation method described in S1 to S6 of the above embodiments through a specific example, so as to facilitate understanding of the essence of the present invention.

[0087] Example

[0088] This embodiment provides a web-based general method for visualizing and annotating polysomnography (PSG). This method allows users to upload any EDF format file, as well as sleep staging annotation files. The method renders a PSG graph point-by-point and displays the uploaded staging results in the background. After rendering, users can annotate or modify the current sleep staging result using the keyboard and select sleep event time periods using the mouse. Furthermore, this method supports background storage of PSG data and online download of annotation results. In this embodiment, the PSG data upload and preprocessing process is as follows: Figure 2 As shown, the visualization process for polysomnography data is as follows: Figure 3 As shown, the window control timing is as follows Figure 4 As shown, the manual annotation process is as follows: Figure 5 As shown in the image. The layout of the polysomnography visualization page is as follows. Figure 6 As shown in the image. The display effect of sleep stage marking is as follows. Figure 7 As shown, the display effect of leg movement event annotation is as follows: Figure 8 As shown. Figure 10 This is a complete screenshot of the interface including user actions, where the user action toolbar is shown as follows. Figure 9 As shown, the user's specific operation process is as follows:

[0089] Step 1. The user first clicks the "Upload" button to upload polysomnography data (EDF file).

[0090] Step 2. The current window displays the first epoch of the patient's data for the entire night, namely the polysomnography of the 0-30 time period.

[0091] Step 3. After the polysomnography (PSG) data is rendered, click the "Upload Tag Data" button to upload the sleep staging results file (this step is optional).

[0092] Step 4. Users can use the "←", "→", "↑", and "↓" keys to switch between left and right or up and down on the screen. The window switching time is fixed at 30 seconds.

[0093] Step 5. The user enters the time (in seconds) in the text box before the jump button, and clicks the jump button. The screen will automatically jump to the target window.

[0094] Step 6. When the user clicks the "o" or "i" button, the window display area will expand or shrink while remaining unchanged from the start time, with a single step change range of 10 seconds.

[0095] Step 7. The user clicks "r" to restore the current window to normal.

[0096] Step 8. When the user clicks "s", the screen will jump to the first window that has not been tagged with sleep stage.

[0097] Step 9. When the window is within the normal range and time point, the user clicks "0, 1, 2, 3, 5". The screen will automatically display the background after sleep stage segmentation, and the corresponding stage will be marked. If the current window does not meet the requirements, press the "r" key to restore it.

[0098] Step 10. If a leg movement channel exists in the polysomnography, you can mark the corresponding channel by sliding the mouse.

[0099] Step 11. After manual labeling is completed, users can click the corresponding event download button to download the labeled file to the browser.

[0100] Step 12. The user clicks the "Save" button, and the PSG data will be saved in the backend file system.

[0101] It should also be noted that the web-based general sleep polysomnography visualization and annotation method in the above embodiments can essentially be executed by a computer program or module. Therefore, similarly, based on the same inventive concept, another preferred embodiment of the present invention also provides a web-based general sleep polysomnography visualization and annotation system corresponding to the web-based general sleep polysomnography visualization and annotation method provided in the above embodiments, such as... Figure 11 As shown, it includes:

[0102] The data upload module is used to upload polysomnography signal files that are to be visualized.

[0103] The data preprocessing module is used to determine whether the content of the polysomnography file is empty. If the file content is empty, a prompt box will pop up to prompt the user to re-upload. If the file content is not empty, the module will further determine the file type of the polysomnography file. If the file type is a PSG file stored in standard EDF format, the polysomnography file will be converted into processable PSG data. The module will read the channel name, sampling rate, channel unit, and channel data information of all channels in the PSG data, and obtain the maximum and minimum values ​​of each channel data through an extremum algorithm. At the same time, the start and end times of the display window will be initialized. Otherwise, a prompt box will pop up to prompt the user to re-upload. The module will calculate the start and end points of the data plotted for each channel based on the start and end times of the window and the sampling rate of each channel, and truncate the data of each channel according to the start and end points. After truncation, the maximum and minimum values ​​of each channel data will be used to normalize the data of each channel, and the normalized data of all channels will be saved as a data list.

[0104] The image rendering module is used to generate a horizontal axis coordinate list corresponding to each channel based on the number of data points in the data list, using the start and end times of the window as the start and end points of the horizontal axis; generate a vertical axis coordinate list with a preset interval starting from 0, the length of the vertical axis coordinate list being the same as the number of PSG data channels; encapsulate the horizontal axis coordinate list and the data list into a data trajectory, encapsulate the vertical axis coordinate list into a frame layout, and render the window image based on the data trajectory and the frame layout;

[0105] The window control module is used to capture the key operation and implement the corresponding window transformation when the user modifies the rendered window display through key operation.

[0106] The manual annotation module is used to capture new key presses that trigger sleep staging annotation after the user confirms the window via key operations. The sleep staging monitoring and processing function then captures these new key presses, saves the sleep staging annotation results, and renders them. Similarly, when a user triggers sleep event annotation via mouse operations, the sleep event monitoring and processing function captures the corresponding mouse operations, saves the sleep event annotation results, and renders them. The data storage module is used to upload the PSG data to the server for storage via the Fetch API after the user clicks the save button to encapsulate the PSG data into form data. Once the sleep staging annotation results and sleep event annotation results are obtained, the user clicks the corresponding button to generate the sleep staging annotation file and the sleep event annotation file, thus completing the web-based general sleep multichannel signal visualization annotation.

[0107] Similarly, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer electronic device corresponding to the web-based general sleep polysomnography visualization annotation method provided in the above embodiments, which includes a memory and a processor;

[0108] The memory is used to store computer programs;

[0109] The processor is configured to implement the web-based general sleep polysaccharide visualization and annotation method described in the above embodiments when executing the computer program.

[0110] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0111] Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer-readable storage medium corresponding to the web-based general sleep polysomnography visualization annotation method provided in the above embodiments. The storage medium stores a computer program, which, when executed by a processor, can realize the web-based general sleep polysomnography visualization annotation method in the above embodiments.

[0112] It is understood that the aforementioned storage media may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Furthermore, the storage media may also be various media capable of storing program code, such as USB flash drives, external hard drives, magnetic disks, or optical discs.

[0113] It is understood that the processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0114] It should also be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the system described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. In the embodiments provided in this application, the division of steps or modules in the system and method is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple modules or steps may be combined or integrated together, and a module or step may also be split.

[0115] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, all technical solutions obtained through equivalent substitution or transformation fall within the protection scope of the present invention.

Claims

1. A web-based general method for visualizing and annotating sleep polysomnography signals, characterized in that, Includes the following steps: S1. Upload the sleep polysaccharide file to be visualized and determine whether the file content is empty. If the file content is empty, a prompt box will pop up to prompt the user to re-upload. If the file content is not empty, further determine the file type of the sleep polysaccharide file. If the file type is a PSG file stored in standard EDF format, convert the sleep polysaccharide file into processable PSG data, read the channel name, sampling rate, channel unit, and channel data information of all channels in the PSG data, and obtain the maximum and minimum values ​​of each channel data through the maximum and minimum value algorithm. At the same time, initialize the start and end times of the display window. Otherwise, a prompt box will pop up to prompt the user to re-upload. S2. Calculate the start and end points of the data drawn for each channel based on the start and end times of the window and the sampling rate of each channel. Then, truncate the data for each channel according to the start and end points. After truncation, normalize the data for each channel using the maximum and minimum values ​​of each channel data and save all the normalized channel data into a data list. S3. Using the start and end times of the window as the start and end points of the horizontal axis, generate a list of horizontal axis coordinates for the corresponding channels based on the number of data points for each channel in the data list. Starting from 0, a list of vertical coordinates is generated at preset intervals. The length of the vertical coordinate list is the same as the number of PSG data channels. The list of horizontal coordinates and the list of data are encapsulated into a data trajectory, and the list of vertical coordinates is encapsulated into a frame layout. The window screen is rendered according to the data trajectory and the frame layout. S4. When the user modifies the rendered window display through key operations, the window control function captures the key operations and implements the corresponding window transformation. S5. After the window is confirmed by key operation, when the user triggers sleep stage labeling through a new key operation, the sleep stage listening and processing function captures the new key operation, saves the sleep stage labeling result and renders it; when the user triggers sleep event labeling through mouse operation, the sleep event listening and processing function captures the corresponding mouse operation, saves the sleep event labeling result and renders it. S6. After the user clicks the save button to encapsulate the PSG data into form data, the PSG data is uploaded to the server for storage via the Fetch API. After obtaining the sleep stage annotation results and the sleep event annotation results, the user clicks the corresponding button to generate the sleep stage annotation file and the sleep event annotation file, thus completing the web-based general sleep polysomnography visualization annotation. The algorithm for finding the maximum and minimum values ​​first saves the channel data into an array format to obtain a channel array, and then sorts each channel array in ascending order. The value at the 0.1% position in each channel array is selected as the minimum value, and the value at the 99.9% position is selected as the maximum value.

2. The web-based general sleep polysomnography visualization and annotation method as described in claim 1, characterized in that, When normalizing the data of each channel, it is determined whether the maximum and minimum values ​​of the current channel data are equal: if they are equal, all data of the current channel are replaced with preset fixed values; if they are not equal, the current channel data is normalized.

3. The webpage-based general sleep polysomnography visualization annotation method as described in claim 2, characterized in that, The preset fixed value is 0.

5.

4. The webpage-based general sleep polysomnography visualization and annotation method as described in claim 1, characterized in that, The window transformations include window switching, window scaling, and window navigation.

5. The webpage-based general sleep polysomnography visualization and annotation method as described in claim 1, characterized in that, The window control function listens for and obtains user key press information, and executes the corresponding key operation through conditional statements.

6. The webpage-based general sleep polysomnography visualization and annotation method as described in claim 1, characterized in that, The preset interval is 1.

7. A web-based universal sleep polysomnography visualization and annotation system, characterized in that, include: The data upload module is used to upload sleep polysomnography (PSG) files that are to be visualized. The data preprocessing module is used to determine whether the content of the sleep polysaccharide file is empty. If the content is empty, a prompt box will pop up to prompt the user to re-upload. If the content is not empty, the module will further determine the file type of the sleep polysaccharide file. If the file type is a PSG file stored in standard EDF format, the sleep polysaccharide file will be converted into processable PSG data. The module will read the channel name, sampling rate, channel unit, and channel data information of all channels in the PSG data, and obtain the maximum and minimum values ​​of each channel data through an extremum algorithm. At the same time, the start and end times of the display window will be initialized. Otherwise, a prompt box will pop up to prompt the user to re-upload. The start and end points of the data drawn for each channel are calculated based on the start and end times of the window and the sampling rate of each channel. The data of each channel is then truncated according to the start and end points. After truncating, the maximum and minimum values ​​of the data of each channel are used to normalize the data of each channel, and all the normalized channel data is saved as a data list. The image rendering module is used to generate a list of horizontal axis coordinates for each channel based on the number of data points for each channel in the data list, using the start and end times of the window as the start and end points of the horizontal axis. Starting from 0, a list of vertical coordinates is generated at preset intervals. The length of the vertical coordinate list is the same as the number of PSG data channels. The list of horizontal coordinates and the list of data are encapsulated into a data trajectory, and the list of vertical coordinates is encapsulated into a frame layout. The window screen is rendered according to the data trajectory and the frame layout. The window control module is used to capture the key operation and implement the corresponding window transformation when the user modifies the rendered window display through key operation. The manual annotation module is used to capture new key presses that trigger sleep stage annotation after the user confirms the window via key operations. The sleep stage annotation function then captures these new key presses, saves the annotation results, and renders them. Similarly, when a user triggers sleep event annotation via mouse operations, the sleep event annotation function captures these mouse operations, saves the annotation results, and renders them. The data storage module is used to upload the PSG data to the server via the Fetch API after the user clicks the save button to encapsulate the PSG data into form data. Once the sleep stage annotation results and sleep event annotation results are obtained, the user clicks the corresponding button to generate the sleep stage annotation file and sleep event annotation file, thus completing the web-based visualization annotation of general sleep polysomnography signals. The algorithm for finding the maximum and minimum values ​​first saves the channel data into an array format to obtain a channel array, and then sorts each channel array in ascending order. The value at the 0.1% position in each channel array is selected as the minimum value, and the value at the 99.9% position is selected as the maximum value.

8. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the web-based general sleep polysaccharide signal visualization annotation method as described in any one of claims 1 to 6.

9. A computer electronic device, characterized in that, Including memory and processor; The memory is used to store computer programs; The processor is configured to, when executing the computer program, implement the web-based general sleep polysaccharide visualization annotation method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Human sleep and breathing monitoring system and method based on bed body

    CN109528159A

  • Sleep disorder auxiliary diagnosis method based on deep learning and infrared thermography

    CN110348500A