Skip to content

Conversation

@jasmainak
Copy link
Member

I got a very cryptic error today when computing the forward:

--> 270 fwd = mne.make_forward_solution(raw.info, trans_fname, src, bem)
    271 inv = make_inverse_operator(raw.info, fwd, cov)
    272 

<decorator-gen-302> in make_forward_solution(info, trans, src, bem, meg, eeg, mindist, ignore_ref, n_jobs, verbose)

/autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/forward/_make_forward.py in make_forward_solution(***failed resolving arguments***)
    601     ccoils = [compcoils, None]
    602     infos = [meg_info, None]
--> 603     megfwd, eegfwd = _compute_forwards(rr, bem, coils, ccoils,
    604                                        infos, coil_types, n_jobs)
    605 

<decorator-gen-296> in _compute_forwards(rr, bem, coils_list, ccoils_list, infos, coil_types, n_jobs, verbose)

/autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/forward/_compute_forward.py in _compute_forwards(rr, bem, coils_list, ccoils_list, infos, coil_types, n_jobs, verbose)
    917                     infos=infos, coil_types=coil_types)
    918     _prep_field_computation(rr, bem, fwd_data, n_jobs)
--> 919     Bs = _compute_forwards_meeg(rr, fwd_data, n_jobs)
    920     return Bs

/autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/forward/_compute_forward.py in _compute_forwards_meeg(rr, fd, n_jobs, silent)
    863                         % (coil_type.upper(), len(rr), _pl(rr)))
    864         # Calculate forward solution using spherical or BEM model
--> 865         B = fun(rr, mri_rr, mri_Q, coils, solution, bem_rr, n_jobs,
    866                 coil_type)
    867 

/autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/forward/_compute_forward.py in _bem_pot_or_field(rr, mri_rr, mri_Q, coils, solution, bem_rr, n_jobs, coil_type)
    446         # Primary current contribution (can be calc. in coil/dipole coords)
    447         parallel, p_fun, _ = parallel_func(_do_prim_curr, n_jobs)
--> 448         pcc = np.concatenate(parallel(p_fun(r, coils)
    449                                       for r in nas(rr, n_jobs)), axis=0)
    450         B += pcc

/autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/forward/_compute_forward.py in <genexpr>(.0)
    446         # Primary current contribution (can be calc. in coil/dipole coords)
    447         parallel, p_fun, _ = parallel_func(_do_prim_curr, n_jobs)
--> 448         pcc = np.concatenate(parallel(p_fun(r, coils)
    449                                       for r in nas(rr, n_jobs)), axis=0)
    450         B += pcc

/autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/forward/_compute_forward.py in _do_prim_curr(***failed resolving arguments***)
    479         p *= ws
    480         p.shape = (3 * (stop - start), -1)
--> 481         pc[3 * start:3 * stop] = [bincount(bins, pp, bins[-1] + 1) for pp in p]
    482     return pc
    483 

/autofs/space/meghnn_001/users/mjas/github_repos/mne-python/mne/forward/_compute_forward.py in <listcomp>(.0)
    479         p *= ws
    480         p.shape = (3 * (stop - start), -1)
--> 481         pc[3 * start:3 * stop] = [bincount(bins, pp, bins[-1] + 1) for pp in p]
    482     return pc
    483 

RuntimeError: In 'NRT_adapt_ndarray_to_python', 'descr' is NULL

Not sure why this happens. When I tried debugging I realized that I couldn't look at the variables because p conflicted with the p command. Hence, this pull request. Also, the error magically disappeared when I made the change and now going back to master, I can't reproduce it. Don't ask ...

I think removing the single letter variable name is a good idea in any case.

@dengemann
Copy link
Member

Good call, it makes debugging more fun. I guess variables like B can be left as is no?

pp = _bem_inf_fields(rr[start:stop], rmags, cosmags)
pp *= ws
pp.shape = (3 * (stop - start), -1)
pc[3 * start:3 * stop] = [bincount(bins, this_pp, bins[-1] + 1) for this_pp in pp]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pep8 to fix then +1 for MRG

@drammock
Copy link
Member

drammock commented Jan 9, 2021

FYI for next time, in the debugger you can type p p to print a variable called p

@jasmainak
Copy link
Member Author

FYI for next time, in the debugger you can type p p to print a variable called p

no that didn't work actually

@drammock
Copy link
Member

drammock commented Jan 9, 2021

FYI for next time, in the debugger you can type p p to print a variable called p

no that didn't work actually

strange, I get this:

$ ipython --pdb
In [1]: p = 'q'
In [2]: raise RuntimeError
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-2-a23cb6c08fe6> in <module>
----> 1 raise RuntimeError

RuntimeError: 
> <ipython-input-2-a23cb6c08fe6>(1)<module>()
----> 1 raise RuntimeError

ipdb> p p
'q'

@jasmainak
Copy link
Member Author

yeah what you say makes sense. But anyhow, single letter variable names are not good for grepping either ...

i've fixed the pep8 issue

@agramfort agramfort merged commit 0388324 into mne-tools:master Jan 14, 2021
@agramfort
Copy link
Member

thx @jasmainak

cbrnr pushed a commit to cbrnr/mne-python that referenced this pull request Jan 15, 2021
larsoner added a commit to vpeterson/mne-python that referenced this pull request Feb 25, 2021
* upstream/master: (66 commits)
  MRG, ENH: Add infant template downloader (mne-tools#8738)
  ENH: add reader for NeuroElectrics .nedf files (mne-tools#8734)
  DOC: improve glossary entry about fiducials (mne-tools#8763)
  MRG, ENH: Add Report.add_custom_css (mne-tools#8762)
  BUG, DOC: read_raw_egi didn't support pathlib.Path; update read_raw() docstring (mne-tools#8759)
  Add "dbs" as new channel type (mne-tools#8739)
  MRG, VIZ: Fix title position in plot_sensors (mne-tools#8752)
  MRG: Support for non-FIFF files in Report.parse_folder (mne-tools#8744)
  MRG, VIZ, FIX: sEEG picking in _prepare_topomap_plot() (mne-tools#8736)
  DOC: don't use single letter variable name in _compute_forward (mne-tools#8727)
  WIP: Fix search [skip github] [skip azp] (mne-tools#8742)
  WIP: Compare Beer-lambert to HOMER (mne-tools#8711)
  MRG: bump spyder version (mne-tools#8020)
  FIX anon with IO round trip (mne-tools#8731)
  fix set_bipolar_reference for Epochs (mne-tools#8728)
  WIP: Add width argument, reduce default (mne-tools#8725)
  ENH: Add toggle-all button to Report (mne-tools#8723)
  fix int/float conversion in nicolet header (mne-tools#8712)
  MRG, BUG: Fix Report.add_bem_to_section n_jobs != 1 (mne-tools#8713)
  MRG, DOC: Make "rank" options in docs more accessible (mne-tools#8707)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants