Repository navigation
Log skipped TUH recordings and accept float rates in EEGAbnormalTUAB - #1474
Conversation
EEGEventsTUEV and EEGAbnormalTUAB skipped a recording they could not read or convert without any message. TUEV also contains linked-ear recordings, which have no EEG XX-REF channels, so the task drops them without telling the user. Keep the skip, as the BIOT preprocessing does, but log a warning with the file and the reason. EEGAbnormalTUAB used fs * 10 as a slice index, so a float resample_rate (the parameter is typed float) raised TypeError. Compute the window length as an int. Fix the docstrings: TUEV resamples to resample_rate (200 Hz by default, not 256 Hz), both tasks return torch tensors, and offending_channel indexes the 22-channel TCP montage of the .rec file, not the 16 rows of signal.
Test CoverageTotal: 85.64% (42616 / 49764 lines)
|
|
/review Generated by Claude Code |
|
/review |
There was a problem hiding this comment.
Previous review
AI Review
suggestion: approve
decision: approve
Thank you for this contribution. It makes skipped TUEV and TUAB recordings visible through logged warnings and fixes the TypeError that a float resample_rate caused in EEGAbnormalTUAB. The docstring corrections are also useful.
The change stays inside the two task classes and doesn't touch shared code. The description matches the diff. The new tests cover float rates, the unreadable-file warning, a -REF recording being used, and a -LE recording being skipped with a warning. Coverage of temple_university_EEG_tasks.py is 81.98%, which meets the 80% bar. Whole-repo coverage is 83.31%, which is above the 60% bar. It looks ready to merge.
Optional suggestions:
round(fs * 10)shortens the window slightly for non-integer rates such as 200.05. You could note in the docstring that the shape10 * resample_rateassumes the product is a whole number of samples.- In
EEGAbnormalTUAB,convert_to_bipolaris outside thetryblock. A recording missing an electrode would raise instead of being skipped with a warning. This was already the case before your change, so it is fine to leave for a follow-up.
Reviewed commit 560d5c0
Resolve conflicts in the TUAB and TUEV tests by keeping both the new robustness tests and the metadata cache tests from sunlabuiuc#1470.
The window is round(10 * resample_rate) samples, so it is exactly 10 s only when that product is a whole number.
convert_to_bipolar ran outside the try block, so a recording without one of the 16 EEG XX-REF electrodes raised a ValueError and stopped set_task. It is now skipped with a warning, like an unreadable recording.
|
/review |
There was a problem hiding this comment.
Previous review
AI Review
suggestion: approve
decision: approve
Thank you for this contribution, Axel. It makes skipped TUEV and TUAB recordings visible through warnings. It also skips TUAB recordings that lack one of the 16 electrodes instead of crashing, lets EEGAbnormalTUAB accept float resample rates, and fixes several docstrings. The change stays inside the two self-contained task classes. It adds no new links between components, and the tests match the described behavior. It looks ready to merge.
Coverage: temple_university_EEG_tasks.py is at 82.39%, above the 80% bar. The whole repository is at 84.95%, above the 60% bar.
Optional suggestions:
- The TUEV docstring says the signal shape is
(16, 5 * resample_rate). That isn't exact for non-integer rates, becauseBuildEventsusesint(fs). You could add a short note like the one in the TUAB docstring. - The missing-electrode warning shows Python's raw "'EEG T5-REF' is not in list" text. A message that names the missing channel directly would read more clearly.
Reviewed commit 1af4ac3
The warning for a TUAB recording without an electrode of the bipolar montage now names the missing channels instead of quoting list.index. The EEGEventsTUEV docstring states that resample_rate has to be a whole number of Hz, since BuildEvents sizes the windows with int().
|
/review Generated by Claude Code |
There was a problem hiding this comment.
Previous review
AI Review
suggestion: approve
decision: approve
Thank you for this contribution. Skipped TUEV and TUAB recordings are now logged with the file and the reason. A TUAB recording that lacks one of the 16 bipolar electrodes is now skipped instead of stopping set_task. EEGAbnormalTUAB also accepts float resample_rate values, and the docstrings are corrected. It looks ready to merge.
The change stays inside the two self-contained task classes in temple_university_EEG_tasks.py. It adds no cross-component sharing. The tests cover float rates, the unreadable-file warning, the missing-electrode skip, and TUEV -REF and -LE recordings. Coverage for the modified file is 82.49%, which meets the 80% bar. Total repository coverage is 85.08%, above the 60% bar.
Optional suggestions:
- The TUEV docstring says
resample_ratemust be a whole number of Hz, but the code doesn't enforce it. You could raise a clear error in__init__, or leave it documented as it is. - The TUAB docstring shape
round(10 * resample_rate)could be made simpler. For example, state that integer rates give(16, 10 * resample_rate).
Reviewed commit fcad8a7
|
/review |
There was a problem hiding this comment.
Previous review
AI Review
suggestion: approve
decision: approve
Thank you for this contribution, Axel. It makes skipped TUEV and TUAB recordings visible through warnings. It also skips TUAB recordings that lack one of the 16 bipolar electrodes, so they no longer abort set_task. And it fixes float resample_rate handling in EEGAbnormalTUAB.
It looks ready to merge. The change stays inside the two self-contained task classes and a module-level logger. The tests cover float rates, unreadable files, a missing electrode, and TUEV -REF versus -LE recordings. Coverage for temple_university_EEG_tasks.py is 82.49%, above the 80% bar, and total repository coverage is 85.11%, above the 60% bar. The description matches the diff, and no components are shared.
Optional suggestions:
- When several electrodes are missing, the TUAB warning reads "it has no A, B channel". Wording like "it has no A, B channels" would read better.
- The TUEV docstring shape
(16, 5 * resample_rate)assumes an integer rate. You already note this, but you could also say it in the shape line itself.
Reviewed commit 5fd6efe
The warning now reads "channels" when several electrodes are missing, with a test for that case. The TUEV signal shape line also states that resample_rate must be a whole number of Hz.
|
/review Generated by Claude Code |
| - "signal": np.ndarray, shape (16, 256*5) | ||
| - "offending_channel": int | ||
| - "signal": torch.FloatTensor, shape (16, 5 * resample_rate), with | ||
| ``resample_rate`` a whole number of Hz. ``BuildEvents`` sizes the windows with ``int(resample_rate)``, so |
There was a problem hiding this comment.
[low] Garbled, duplicated sentence in EEGEventsTUEV docstring
The "signal" entry says the same thing twice in one line: the first half is "with resample_rate a whole number of Hz" and the second half is "BuildEvents sizes the windows with int(resample_rate), so resample_rate has to be a whole number of Hz." The line is also far too long. Merge these into one short sentence, for example: "signal: torch.FloatTensor, shape (16, 5 * resample_rate). BuildEvents uses int(resample_rate) for the window size, so use a whole-number rate."
There was a problem hiding this comment.
AI Review
suggestion: approve
decision: approve
Thank you for this contribution, Axel. Skipped TUEV and TUAB recordings now log a warning, and a TUAB recording missing one of the 16 electrodes is skipped instead of stopping set_task. A float resample_rate also works in EEGAbnormalTUAB. The change looks ready to merge.
- Scope: The change stays inside the two task classes. It adds no new links between components and doesn't alter any shared code or public API. For integer rates, the output samples are the same as before.
- Tests: The new tests cover float rates (200.0 and 256.0), the unreadable-file warning, and the missing-electrode warnings (one electrode and several). They also cover TUEV, where a
-REFrecording is used and a-LErecording is skipped with a warning. - Coverage:
temple_university_EEG_tasks.pyis at 82.49%, above the 80% bar. The whole repository is at 85.64%, above the 60% bar.
Optional suggestions:
- The
EEGEventsTUEVdocstring now says the same thing twice: "withresample_ratea whole number of Hz" and "resample_ratehas to be a whole number of Hz". You could keep one of the two sentences and wrap the line. - The TUAB docstring says "round(10 * resample_rate)" samples for non-integer rates, while the code uses
round(fs * 10). These are equivalent, so it's fine as is.
Reviewed commit 1e9638a
BuildEvents sized its buffer with int(fs) * 5 and sliced from start - 2*int(fs) to end + 2*int(fs). At a non-integer rate the two lengths differ and the assignment raised a broadcast ValueError, which stopped set_task because BuildEvents runs outside the try in __call__. The window is now round(5 * fs) samples starting round(2 * fs) samples before the event onset, as sunlabuiuc#1474 did with round(10 * fs) for TUAB. At an integer rate the windows are unchanged. Fixes sunlabuiuc#1522
) * Size TUEV event windows with round() so float resample rates work BuildEvents sized its buffer with int(fs) * 5 and sliced from start - 2*int(fs) to end + 2*int(fs). At a non-integer rate the two lengths differ and the assignment raised a broadcast ValueError, which stopped set_task because BuildEvents runs outside the try in __call__. The window is now round(5 * fs) samples starting round(2 * fs) samples before the event onset, as #1474 did with round(10 * fs) for TUAB. At an integer rate the windows are unchanged. Fixes #1522 * Document that TUEV windows ignore the event end time The window is round(5 * fs) samples from 2 s before the onset, so the end time in the .rec file is no longer used. Say so in the docstring and pin it with a test on a 2 s event, which the old slicing rejected with a broadcast ValueError. Nested with statements in the tests of this PR are merged into one (ruff SIM117).
…nlabuiuc#1600) * Size TUEV event windows with round() so float resample rates work BuildEvents sized its buffer with int(fs) * 5 and sliced from start - 2*int(fs) to end + 2*int(fs). At a non-integer rate the two lengths differ and the assignment raised a broadcast ValueError, which stopped set_task because BuildEvents runs outside the try in __call__. The window is now round(5 * fs) samples starting round(2 * fs) samples before the event onset, as sunlabuiuc#1474 did with round(10 * fs) for TUAB. At an integer rate the windows are unchanged. Fixes sunlabuiuc#1522 * Document that TUEV windows ignore the event end time The window is round(5 * fs) samples from 2 s before the onset, so the end time in the .rec file is no longer used. Say so in the docstring and pin it with a test on a 2 s event, which the old slicing rejected with a broadcast ValueError. Nested with statements in the tests of this PR are merged into one (ruff SIM117).
Contributor: Axel Coiffard-Donaty (@AxelNoun)
Contribution Type: Bug fix
Description:
Part of #1473.
EEGEventsTUEVandEEGAbnormalTUABused to skip a recording they could not read or convert without any message. TUEV also contains linked-ear recordings, which have noEEG XX-REFchannels, so they were dropped silently. The skip itself is unchanged, as in the BIOT preprocessing, so the samples produced are the same. Alogger.warningnow gives the file and the reason.convert_to_bipolarran outside thetryblock, so the missing channel raised aValueErrorthat stoppedset_task. It is now skipped with a warning, like an unreadable recording (suggestion of the AI review).EEGAbnormalTUABusedfs * 10as a slice index, so a floatresample_rate(the parameter is typedfloat) raisedTypeError: slice indices must be integers. The window length is now an int.resample_rate(200 Hz by default, not 256 Hz);torch.FloatTensorsignals;offending_channelis the channel number from the.recfile, which indexes the 22-channel TCP montage (0-21), not a row ofsignal.No public API change. The samples produced from the recordings that were already processed are unchanged.
Note: #1293 also edits the
EEGEventsTUEVdocstring. The overlap is a few lines and easy to resolve, whichever PR lands first.Files to Review:
pyhealth/tasks/temple_university_EEG_tasks.py: warnings for skipped recordings, int window length inEEGAbnormalTUAB, docstrings.tests/core/test_tuab.py: floatresample_rate(200.0, 256.0), and the warnings for an unreadable file and for a recording missing an electrode.tests/core/test_tuev.py: a-REFrecording is used, and a-LErecording is skipped with a warning.Testing:
pytest tests/core/test_tuab.py tests/core/test_tuev.pyon Linux: 33 passed, 2 subtests passed.temple_university_EEG_tasks.py, the new tests fail: 4 failures, including both float-rate subtests. The test for a missing electrode fails withValueError: 'EEG T5-REF' is not in listwithout the last commit.python tools/check_pr_rules.py --base upstream/master --head HEAD: passed.Claude helped me with this PR.