-
Notifications
You must be signed in to change notification settings - Fork 8
Alaska2 #6
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
Open
otoien
wants to merge
6
commits into
paulbrodersen:alaska
Choose a base branch
from
otoien:alaska2
base: alaska
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Alaska2 #6
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f012efa
Added reading and writing EDF headers from the original file to the t…
otoien bed44a4
Heading taken from original of truncated file etc.
otoien 1ac5cc0
Truncating edf annotations should not overwrite original file
otoien bb644f4
Update 00_truncate_edf_annotations.py
otoien 812e259
Fix issue #7 in truncate EDF annotations
otoien 8cc78d5
Update to solve issue #8 when plotting
otoien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| file_path_raw_signals,file_path_preprocessed_signals,file_path_manual_state_annot_orig,file_path_manual_state_annotation,file_path_automated_state_annotation,file_path_refined_state_annotation,file_path_review_intervals,sampling_frequency_in_hz,ECG,BP,EEG,EOG,EMG,EMGamp,Resp,Tabd | ||
| WorkPath\Bears11_Bear2\Bear20120112a-Bear2-HH.edf,WorkPath\Processed\Bear20120112a-Bear2-HH.npy,WorkPath\Scores\Bear20120112a-Bear2-HH_OT.edf,WorkPath\Scores\Bear20120112a-Bear2-HH_OT_adj.edf,WorkPath\Processed\Bear20120112a-Bear2-HH_annotation_predicted.edf,WorkPath\Processed\Bear20120112a-Bear2-HH_refined_annotation.csv,WorkPath\Processed\Bear20120112a-Bear2-HH_review_intervals.csv,500,ECG,BP,EEG,EOG,EMG,EMGamp,Resp,Tabd | ||
| WorkPath\Bears11_Bear2\Bear20120203a-Bear2-HL.edf,WorkPath\Processed\Bear20120203a-Bear2-HL.npy,WorkPath\Scores\Bear20120203a-Bear2-HL_OT.edf,WorkPath\Scores\Bear20120203a-Bear2-HL_OT_adj.edf,WorkPath\Processed\Bear20120203a-Bear2-HL_annotation_predicted.edf,WorkPath\Processed\Bear20120203a-Bear2-HL_refined_annotation.csv,WorkPath\Processed\Bear20120203a-Bear2-HL_review_intervals.csv,500,ECG,BP,EEG,EOG,EMG,EMGamp,Resp,Tabd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,7 +153,8 @@ def _chebychev_bandpass(lowcut, highcut, fs, rs, order=5): | |
| ('Sleep stage 1 (artefact)', -2), | ||
| ('Sleep stage R' , 3), | ||
| ('Sleep stage R (artefact)', -3), | ||
| ('undefined' , 0), | ||
| ('Sleep stage ?' , 0), # ? = Undefined/unscorable code in Polyman | ||
| ('Movement Time' , 0), # Just included in case M code is accidentally added to avoid exception, cannot be deleted in Polyman | ||
| ]) | ||
|
|
||
| # Construct the inverse mapping to convert back from state predictions to human readabe labels. | ||
|
|
@@ -167,7 +168,7 @@ def _chebychev_bandpass(lowcut, highcut, fs, rs, order=5): | |
| 'N' : 'Sleep stage 1 (artefact)', | ||
| 'r' : 'Sleep stage R' , | ||
| 'R' : 'Sleep stage R (artefact)', | ||
| 'x' : 'undefined' , | ||
| 'x' : 'Sleep stage ?' , # ? = Undefined/unscorable code in Polyman | ||
| 'X' : 'undefined (artefact)' , | ||
| } | ||
|
|
||
|
|
@@ -179,7 +180,7 @@ def _chebychev_bandpass(lowcut, highcut, fs, rs, order=5): | |
| 'Sleep stage 1 (artefact)' : 'cornflowerblue', | ||
| 'Sleep stage R' : 'gold', | ||
| 'Sleep stage R (artefact)' : 'yellow', | ||
| 'undefined' : 'gray', | ||
| 'Sleep stage ?' : 'gray', # ? = Undefined/unscorable code in Polyman | ||
| 'undefined (artefact)' : 'lightgray', | ||
| } | ||
|
|
||
|
|
@@ -190,7 +191,7 @@ def _chebychev_bandpass(lowcut, highcut, fs, rs, order=5): | |
| 'Sleep stage 1 (artefact)' , | ||
| 'Sleep stage R' , | ||
| 'Sleep stage R (artefact)' , | ||
| 'undefined' , | ||
| 'Sleep stage ?' , # ? = Undefined/unscorable code in Polyman | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Polyman terminology for undefined states adopted in 7059e9f. |
||
| 'undefined (artefact)' , | ||
| ] | ||
|
|
||
|
|
@@ -213,7 +214,7 @@ def _chebychev_bandpass(lowcut, highcut, fs, rs, order=5): | |
| # -------------------------------------------------------------------------------- | ||
|
|
||
| # desired time resolution of the automated annotation (in seconds) | ||
| time_resolution = 1 | ||
| time_resolution = 10 | ||
|
|
||
| # default view length when manually annotating states | ||
| default_view_length = 60. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,12 @@ | |
| import pandas | ||
|
|
||
| from argparse import ArgumentParser | ||
| from collections import Iterable | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python v3.3 changes to |
||
| try: | ||
| # Python <= 3.9 | ||
| from collections import Iterable | ||
| except ImportError: | ||
| # Python > 3.9 | ||
| from collections.abc import Iterable | ||
| from pyedflib import EdfReader, EdfWriter | ||
| from six import ensure_str | ||
|
|
||
|
|
@@ -338,7 +343,7 @@ def _load_edf_hypnogram(file_path): | |
| return states, intervals | ||
|
|
||
|
|
||
| def _export_edf_hypnogram(file_path, states, intervals): | ||
| def _export_edf_hypnogram(file_path, states, intervals, header=None): | ||
| """Export hypnogram as "Time-stamped Annotations Lists (TALs)" in | ||
| EDF annotations. | ||
|
|
||
|
|
@@ -361,8 +366,10 @@ def _export_edf_hypnogram(file_path, states, intervals): | |
| with EdfWriter(file_path, 0) as writer: | ||
| for (start, stop), state in zip(intervals, states): | ||
| writer.writeAnnotation(start, stop-start, state) | ||
| if header: | ||
| writer.setHeader(header) | ||
| writer.close() | ||
|
|
||
|
|
||
| # -------------------------------------------------------------------------------- | ||
| # aliases | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behaviour is implemented in c020140. However, the headers are only copied, if the target file for the annotations is indeed in an EDF format.