Stanford-STAGES / stanford-stages

Automated sleep staging scoring and narcolepsy identification
76 stars 26 forks source link

Single channel .edf json notation not working #6

Closed informaton closed 4 years ago

informaton commented 5 years ago

Using single channel .edf json notation (e.g., 'central3') gives error messages. Workaround is to use dual channel notation ('centrals') and double the channel (e.g., [2,2]).

The following was reported from Jamie Z.:

When I run this code: python3.6 -W ignore inf_narco_app.py ./edf/DL024_2.edf '{"channel_indices":{"central3":2,"occipital2":3,"eog_l":0,"eog_r":1,"chin_emg":4},

"show":{"plot":false,"hypnodensity":false,"hypnogram":false,"diagnosis":true},

"save":{"plot":true,"hypnodensity":true, "hypnogram":true,"diagnosis":true}}'

I get this error: Load EDF Loading C3 fs 128 original samplerate = 128 resampling to 100 Resampling done Loading C4 channel[C4] was empty (skipped) Loading O1 channel[O1] was empty (skipped) Loading O2 fs 128 original samplerate = 128 resampling to 100 Resampling done Loading EOG-L fs 128 original samplerate = 128 resampling to 100 Resampling done Loading EOG-R fs 128 original samplerate = 128 resampling to 100 Resampling done Loading EMG fs 256 original samplerate = 256 resampling to 100 Resampling done Loading A1 channel[A1] was empty (skipped) Loading A2 channel[A2] was empty (skipped) Load noise level Traceback (most recent call last): File "inf_narco_app.py", line 303, in main(edfFile, jsonObj) File "inf_narco_app.py", line 102, in main narcoApp.eval_hypnodensity() File "inf_narco_app.py", line 254, in eval_hypnodensity self.Hypnodensity.evaluate() File "/home/sleeplab/narco/inf_hypnodensity.py", line 73, in evaluate self.psg_noise_level() File "/home/sleeplab/narco/inf_hypnodensity.py", line 322, in psg_noise_level unused_ch = self.get_loudest_channel(['O1','O2'],meanV[occipitals_idx], covM[occipitals_idx]) File "/home/sleeplab/narco/inf_hypnodensity.py", line 329, in get_loudest_channel noise[idx] = self.channel_noise_level(ch, meanV, covM) File "/home/sleeplab/narco/inf_hypnodensity.py", line 341, in channel_noise_level hjorth= self.extract_hjorth(self.loaded_channels[channelTag]) File "/home/sleeplab/narco/inf_hypnodensity.py", line 133, in extract_hjorth D = skimage.util.view_as_windows(x, dim, dim).T File "/home/sleeplab/.local/lib/python3.6/site-packages/skimage/util/shape.py", line 219, in view_as_windows raise TypeError("arr_in must be a numpy ndarray") TypeError: arr_in must be a numpy ndarray

When I run the same file just modifying the JSON python3.6 -W ignore inf_narco_app.py ./edf/DL024_2.edf '{"channel_indices":{"centrals":[2,2],"occipitals":[3,3],"eog_l":0,"eog_r":1,"chin_emg":4},

"show":{"plot":false,"hypnodensity":false,"hypnogram":false,"diagnosis":true},

"save":{"plot":true,"hypnodensity":true, "hypnogram":true,"diagnosis":true}}'

It works fine...

informaton commented 5 years ago

The problem here is caused by specifying the second occipital EEG channel reference (occipital2) without specifying the first (occipital1).

To prevent the issue, use "occipital" instead of "occipital3" when only providing a single occipital EEG channel reference.

This is also true for the C3 and C4 channel leads. That is, use "central" or "central3" if only one central EEG reference is provided.

informaton commented 4 years ago

Updated in commit f3ba896.