-
Notifications
You must be signed in to change notification settings - Fork 1
Update PSG montages #1
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -269,8 +269,12 @@ def extract_physiological_features(physiological_data, physiological_fs, csv_pat | |||||||||||||||||
| new_label = rename_map.get(old_label, old_label.lower()) | ||||||||||||||||||
| processed_channels[new_label] = data | ||||||||||||||||||
| # Mapping the sampling rate to the new label | ||||||||||||||||||
| processed_fs[new_label] = physiological_fs.get(old_label, 200.0) # Default to 200 if missing | ||||||||||||||||||
|
|
||||||||||||||||||
| if old_label in physiological_fs: | ||||||||||||||||||
| processed_fs[new_label] = physiological_fs[old_label] | ||||||||||||||||||
| else: | ||||||||||||||||||
| # Report error and stop if no FS is found for a kept channel | ||||||||||||||||||
| raise KeyError(f"Sampling frequency (fs) not found for channel '{old_label}' ") | ||||||||||||||||||
|
|
||||||||||||||||||
| if 'physiological_data' in locals(): del physiological_data | ||||||||||||||||||
|
|
||||||||||||||||||
| # Step 3: Construct Bipolar Derivations | ||||||||||||||||||
|
|
@@ -279,7 +283,7 @@ def extract_physiological_features(physiological_data, physiological_fs, csv_pat | |||||||||||||||||
| ('c3-m2', 'c3', ['m2']), ('c4-m1', 'c4', ['m1']), | ||||||||||||||||||
| ('o1-m2', 'o1', ['m2']), ('o2-m1', 'o2', ['m1']), | ||||||||||||||||||
| ('e1-m2', 'e1', ['m2']), ('e2-m1', 'e2', ['m1']), | ||||||||||||||||||
| ('chin1-chin2', 'chin1', ['chin2']), | ||||||||||||||||||
| ('chin1-chin2', 'chin 1', ['chin 2']), | ||||||||||||||||||
| ('lat', 'lleg+', ['lleg-']), ('rat', 'rleg+', ['rleg-']) | ||||||||||||||||||
| ] | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -433,7 +437,7 @@ def count_discrete_events(key): | |||||||||||||||||
| features.extend([ahi_auto, arousal_auto, limb_auto]) | ||||||||||||||||||
|
|
||||||||||||||||||
| # --- 2. Sleep Architecture (from stage_caisr) --- | ||||||||||||||||||
| # Standard labels: 0=W, 1=N1, 2=N2, 3=N3, 4=R (or similar mapping) | ||||||||||||||||||
| # Standard labels: 5=W, 4=R, 3=N1, 2=N2, 1=N3 (or similar mapping) | ||||||||||||||||||
|
||||||||||||||||||
| # Standard labels: 5=W, 4=R, 3=N1, 2=N2, 1=N3 (or similar mapping) | |
| # Algorithmic CAISR stage labels for stage_caisr: | |
| # 5 = Wake (W), 4 = REM (R), 3 = N1, 2 = N2, 1 = N3. | |
| # NOTE: This mapping applies only to the algorithmic stage_caisr output and | |
| # differs from the human annotation mapping used in | |
| # extract_human_annotations_features (e.g., 0 = W, 1 = N1, ...). | |
| # The w_pct/r_pct/n1_pct/n2_pct/n3_pct features below are computed | |
| # using these algorithmic codes. |
Copilot
AI
Mar 25, 2026
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.
efficiency is now computed as the proportion of epochs in stages 1–4, but extract_human_annotations_features in the same file still computes efficiency as np.mean(valid_stages > 0). If human and algorithmic stage encodings are intended to be comparable features, this introduces an inconsistency in the feature definitions; align the formulas (or add an explicit comment explaining why they differ).
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.
The raised KeyError message has an extra trailing space before the closing quote, which makes the error message look sloppy and harder to match in logs/tests. Remove the trailing whitespace and consider including the standardized label (
new_label) as well, since that’s what downstream code uses.