Repository navigation
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: 84.95% (39734 / 46772 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 |
| Each returned sample contains: | ||
| - "signal": np.ndarray, shape (16, 256*5) | ||
| - "offending_channel": int | ||
| - "signal": torch.FloatTensor, shape (16, 5 * resample_rate) |
There was a problem hiding this comment.
[low] TUEV shape docstring is wrong for non-integer resample_rate
The docstring says the signal shape is (16, 5 * resample_rate), but BuildEvents allocates int(fs) * 5 samples and slices with int(fs), so for example resample_rate=200.5 gives 1000 samples, not 1002.5. Either write the shape as (16, 5 * int(resample_rate)), as the TUAB docstring does with round(), or note that the shape holds for integer rates.
There was a problem hiding this comment.
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
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.