Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept StringIO for Annotation-Files #27

Open
skjerns opened this issue May 23, 2022 · 1 comment
Open

Accept StringIO for Annotation-Files #27

skjerns opened this issue May 23, 2022 · 1 comment

Comments

@skjerns
Copy link

skjerns commented May 23, 2022

Heyho, I'm currently working my way through #26 to apply different spindle detection methods on our dataset. Our data is in EDF+ and simple csv files for sleep scoring.

I want to avoid having to create everything in XML files and was thinking about supplying files on-the-fly and passing them as StringIO/BytesIO or lists/np.arrays. Is there any possibly to supply the Annotations and all the other information as lists or StringIO?

When not using the GUI its a bit difficult to understand how to call the functions and what the functions expect. E.g. it took me some time to find out I can simply call the Detection class (i.e. that the class itself is a method and implements a __call__), and that there is no method defined that is called detection.run(data) .

I think this package is really awesome and has great potential, some more tutorials on non-GUI-use and it would be perfect!

@jnobyrne
Copy link
Contributor

Hey, thanks for your feedback !

Regarding your question about eschewing Annotation files, you can do so if you know the start and end times of the target signal in your data record:

method = 'Lacourse2018'
records_list = ['Subject1.edf', 'Subject2.edf', ...]
start_end_times = [(0, 3000), (5656, 8901), ...]
rater = 'rater_name_here'
chan = ['Cz']
event_name = 'event_name_here'

detector =DetectSpindle(method)
for rec_file, (beg, end) in zip(records_list, start_end_times):
    dset = Dataset(rec_file)
    data = dset.read_data(chan=chan, begtime=beg, endtime=end)
    spindles = detector(data)

Note that this method does not offer re-referencing of channels, and you lose the stage selection functionality.
But it does allow you to forgo Annotation files altogether, and just pass time tuples instead.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants