Closed drammock closed 1 month ago
First tip is to use on_error = 'debug'
to get into a pdb
prompt. In principle we should be using the empty room prep function to adjust the empty room file and/or head position file so that this conflict does not occur. The short version is that you want to process the empty room data the same way as the task data as much as possible, so you use the head positions from the task data and use movement compensation on the empty room data. I can't remember if the head position or the first_samp
of the empty room data (or both) are supposed to be adjusted but it seems like this isn't happening properly, or we aren't passing an adjusted version or something.
First tip is to use
on_error = 'debug'
to get into apdb
prompt.
I've been using the --debug
flag and it doesn't leave me in pdb prompt 😢 that was another thing I meant to mention / ask about, but forgot.
I'll see if I can get a dev install of MBP on the remote machine (should work, but it's kinda old and has limited disk space). Then I'll stick in some print
statements and 1/0
s to see what I can figure out
I've been using the --debug flag and it doesn't leave me in pdb prompt 😢 that was another thing I meant to mention / ask about, but forgot.
On my Linux machine I added a 1/0
above line 415 raw_sss = mne.preprocessing.maxwell_filter(raw, **mf_kws)
in _03_maxfilter.py
then did:
$ mne_bids_pipeline mne_bids_pipeline/tests/configs/config_ds004229.py --debug
┌────────┬ Welcome aboard MNE-BIDS-Pipeline! 👋 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│14:02:53│ 📝 Using configuration: mne_bids_pipeline/tests/configs/config_ds004229.py
│14:02:53│ ❌ Overriding config.on_error = 'debug'
└────────┴
...
┌────────┬ preprocessing/_03_maxfilter ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│14:04:13│ ⏳️ sub-102 run-noise Computing eSSS basis with 8 components
│14:04:14│ ⏳️ sub-102 run-noise Adding eSSS projectors to report.
│14:04:15│ ⏳️ sub-102 run-noise Saving report: /home/larsoner/mne_data/derivatives/mne-bids-pipeline/ds004229/sub-102/meg/sub-102_task-amnoise_report.html
│14:04:15│ ⏳️ sub-102 Loading reference run: None.
│14:04:15│ ⏳️ sub-102 Applying tSSS (10 sec, corr=0.98) with MC/eSSS to experimental data
│14:04:16│ ⏳️ sub-102 Marking 1 channel as bad.
│14:04:16│ ⏳️ sub-102 Destination is 17.1 mm and 19.2° from the original head position
│14:04:16│ 🐛 sub-102 A critical error occurred. The error message was: division by zero
Starting post-mortem debugger.
<traceback object at 0x71bd58e3f880>
> /home/larsoner/python/mne-bids-pipeline/mne_bids_pipeline/steps/preprocessing/_03_maxfilter.py(415)run_maxwell_filter()
-> 1/0
(Pdb) p raw
<Raw | sub-102_task-amnoise_meg.fif, 332 x 360001 (300.0 s), ~919.3 MB, data loaded>
and I tried modifying the config to have on_error = "debug"
and ended up at the same prompt. Then I thought maybe having n_jobs=2
could break things but even there things work because it gets overridden:
┌────────┬ Welcome aboard MNE-BIDS-Pipeline! 👋 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│14:07:04│ 📝 Using configuration: mne_bids_pipeline/tests/configs/config_ds004229.py
│14:07:04│ ❌ Setting config.n_jobs=1 because config.on_error="debug"
└────────┴
So I'm not sure why it's not working for you :(
when running with an editable install of MBP, the --debug
flag does indeed drop me into a postmortem debugger on error. Not sure why that wasn't working with a standard (conda-forge) install of 1.9.0
Summarizing the error: it happens when processing the emptyroom recording (which here has a raw._first_time
of 33 seconds), and it loads derivatives/mne-bids-pipeline/sub-116/ses-a/meg/sub-116_ses-a_task-AmplitudeModulatedTones_headpos.txt
(which is headpos from the task run) and finds that the first time of the headpos measurement is ~18 seconds. As @larsoner noted:
I can't remember if the head position or the first_samp of the empty room data (or both) are supposed to be adjusted but it seems like this isn't happening properly, or we aren't passing an adjusted version or something.
The problem turns out to be that raw
was recorded at 1800 Hz, and empty room was recorded at 1000 Hz. So the adjustment of raw_er_prepared
here:
does so without taking into account any possible difference in sfreq
. So one solution would be to downsample all our raw
files before starting the pipeline (since MNEBP does resampling after SSS). But it seems (to me at least, maybe I'm mistaken?) that it ought to be OK to have different sfreqs for the raw and the ER, and that we could make the prepare_emptyroom
function account for such differences. WDYT @larsoner? Is having different sfreqs likely to cause other problems later?
cc @mdclarke
I think having different sampling rates is okay in principle. Subsequent analyses should take them into account if necessary, but given that the most common use cases for empty-room data are computing a covariance or projectors -- neither of which should generally be affected by a sample rate difference -- I think it's okay to process it at a different sample rate.
in trying to work around #964 (by passing
--session a
on the command line) I hit this unrelated error (happens for both subjects):I don't know this dataset intimately yet (i.e. I haven't manually processed/plotted the files so I'm not sure what to expect; this pipeline run of only 2 subjs was meant as a way to do just that). Any suggestions what I should examine to see if it's a legitimate data problem vs a bug?
Here's the full pipeline output: