How to read hypnogram file (.hyp) in matlab

5 views (last 30 days)
Hello, I want to know how to open .hyp file (hypnogram of sleep stage analysis from physionet.org) in matlab? my file format is not ''.edf''. the format of my file is ''.hyp''. the edfread function can not open it in matlab. I test it. thanks
  1 Comment
Ibrahim kaya
Ibrahim kaya on 10 Dec 2020
You can use the following commands in python to convert edf to csv
Then importing csv to Matlab is easy:
import pyedflib
import pandas
import csv
f = pyedflib.EdfReader("SC4001EC-Hypnogram.edf")
annotations = f.readAnnotations()
with open("Test.csv",'w') as fo:
for d in range(len(annotations[0])):
fo.write(str(annotations[0][d])+','+str(annotations[1][d])+','+annotations[2][d]+'\n')

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 25 Aug 2018
Files with a ‘.hyp’ extension are annotation files. They are intended to be used by the Physionet software, not read individually. Not all sleep data are annotated. (Since they are ASCII files, MATLAB can open the files and import them with the fgets function. Making sense of them afterwards is another problem.)
Go back to PhysioBank ATM (link), choose the record you want, and in the ‘Toolbox’ pull-down menu, select ‘Export signals as .mat’. The signals, and annotations (if they exist) should be in that file, that you can then open with the MATLAB load (link) function.
For best results, assign them to a variable, described in Load List of Variables into Structure Array (link).
I have some experience with PhysioNET files, but none with the polysomnographic data, so I cannot help you further with them.

More Answers (0)

Categories

Find more on EEG/MEG/ECoG in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!