BUG: Dev version of coreg crashing sometimes during fiducial fit
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
The traceback points to _filtered_extra_points in mne/coreg.py, which indexes the digitization hsp array with _extra_points_filter. The filter has 175 entries but hsp has 270, so the filter is stale after a new dig is loaded. Find where _extra_points_filter is set and reset when dig data changes. Done means fit_fiducials runs without IndexError after loading a second dig, covered by a test in mne/tests/test_coreg.py. The reporter has no reliable reproduction yet, so a test that reproduces the size mismatch is a useful first step.
索引モデルが issue の本文から書いたものです。
説明
Description of the problem
@larsoner @payamsash
Working my way slowly through a set of 180 coregistrations 😄, I've been test driving the dev versions of mne.coreg quite a bit. I do want to say, on the whole, it's looking great and working fast, so thanks @payamsash and all for the good work! With that said, there are a couple small issues I've come across.
Notably, I am sometimes, but not always, getting a crash when trying an initial fiducial fit to one of the ANTS template anats after loading in a new dig. I don't have a reliable reproduction MWE yet because I haven't been able to figure out what circumstances are differentiating the successful and crashing fid fits, but I wanted to throw this error up here so folks know about it since I know the coreg gui is under active development.
I just recently started hitting this issue, so I'll work on narrowing down an example that more reliably reproduces the behavior.
Steps to reproduce
mne.gui.coregistration(scale_by_distance=False, fullscreen=False, show=True)
# 1. Load an ANTS template.
# 2. Load an infant MEG file with dig.
# So far, the first fit after launching the gui has always worked
# 3. Click the "Fit fiducials" button.
# 4. Reset parameters.
# 5. Load a new infant MEG file with dig.
# After loading a new dig, fid fit will often succeed, but sometimes fail
# 6. Click the "Fit fiducials" button.
Link to data
No response
Expected results
I expect the fiducials to fit and the gui to not crash.
Actual results
Sometimes the gui freezes.
Here's the traceback from my terminal.
`IndexError Traceback (most recent call last)
File ~/repos/mne-python/mne/gui/_coreg.py:1508, in CoregistrationUI._fit_fiducials(self)
1506 def _fit_fiducials(self):
1507 with self._lock(scale_mode=True):
-> 1508 self._fits_fiducials()
File ~/repos/mne-python/mne/gui/_coreg.py:1513, in CoregistrationUI._fits_fiducials(self)
1511 with self._lock(params=True, fitting=True):
1512 start = time.time()
-> 1513 self.coreg.fit_fiducials(
1514 lpa_weight=self._lpa_weight,
1515 nasion_weight=self._nasion_weight,
1516 rpa_weight=self._rpa_weight,
1517 verbose=self._verbose,
1518 )
1519 end = time.time()
1520 self._display_message(
1521 f"Fitting fiducials finished in {end - start:.2f} seconds."
1522 )
File :12, in fit_fiducials(self, lpa_weight, nasion_weight, rpa_weight, verbose)
File ~/repos/mne-python/mne/coreg.py:1911, in Coregistration.fit_fiducials(self, lpa_weight, nasion_weight, rpa_weight, verbose)
1889 """Find rotation and translation to fit all 3 fiducials.
1890
1891 Parameters
(...) 1908 The modified Coregistration object.
1909 """
1910 logger.info("Aligning using fiducials")
-> 1911 self._log_dig_mri_distance("Start")
1912 n_scale_params = self._n_scale_params
1913 if n_scale_params == 3:
1914 # enforce 1 even for 3-axis here (3 points is not enough)
File ~/repos/mne-python/mne/coreg.py:1869, in Coregistration._log_dig_mri_distance(self, prefix)
1868 def _log_dig_mri_distance(self, prefix):
-> 1869 errs_nearest = self.compute_dig_mri_distances()
1870 logger.info(
1871 f"{prefix} median distance: {np.median(errs_nearest * 1000):6.2f} mm"
1872 )
File ~/repos/mne-python/mne/coreg.py:2175, in Coregistration.compute_dig_mri_distances(self)
2162 """Compute distance between head shape points and MRI skin surface.
2163
2164 Returns
(...) 2171 mne.dig_mri_distances
2172 """
2173 # we don't use dig_mri_distances here because it should be much
2174 # faster to use our already-determined nearest points
-> 2175 hsp_points, mri_points, _ = self._setup_icp(0)
2176 hsp_points = apply_trans(self._head_mri_t, hsp_points)
2177 return np.linalg.norm(mri_points - hsp_points, axis=-1)
File ~/repos/mne-python/mne/coreg.py:1959, in Coregistration._setup_icp(self, n_scale_params)
1957 mri_pts = [np.zeros((0, 3))]
1958 weights = [np.zeros(0)]
-> 1959 if self._has_dig_data and self._hsp_weight > 0: # should be true
1960 head_pts.append(self._filtered_extra_points)
1961 mri_pts.append(
1962 self._processed_high_res_mri_points[
1963 self._nearest_transformed_high_res_mri_idx_hsp
1964 ]
1965 )
File ~/repos/mne-python/mne/coreg.py:1857, in Coregistration._has_dig_data(self)
1853 @property
1854 def _has_dig_data(self):
1855 return (
1856 self._has_mri_data
-> 1857 and len(self._nearest_transformed_high_res_mri_idx_hsp) > 0
1858 )
File ~/repos/mne-python/mne/coreg.py:1787, in Coregistration._nearest_transformed_high_res_mri_idx_hsp(self)
1784 @property
1785 def _nearest_transformed_high_res_mri_idx_hsp(self):
1786 return self._nearest_calc.query(
-> 1787 apply_trans(self._head_mri_t, self._filtered_extra_points)
1788 )[1]
File ~/repos/mne-python/mne/coreg.py:1760, in Coregistration._filtered_extra_points(self)
1758 return self._dig_dict["hsp"]
1759 else:
-> 1760 return self._dig_dict["hsp"][self._extra_points_filter]
IndexError: boolean index did not match indexed array along axis 0; size of axis is 175 but size of corresponding boolean axis is 270`
Additional information
~$ mne sys_info
Platform Linux-6.17.0-1033-oem-x86_64-with-glibc2.39 (X11)
Python 3.14.6 | packaged by conda-forge | (main, Jun 12 2026, 08:51:42) [GCC 14.3.0]
Executable /home/nordme/miniconda3/envs/bids_dev26/bin/python3.14
CPU Intel(R) Xeon(R) w5-2455X (24 cores)
Memory 125.4 GiB
Core
├☑ mne 1.14.0.dev85+g5ec89de23 (development, latest release is 1.13.2)
├☑ numpy 2.4.6 (OpenBLAS 0.3.33 with 24 threads via pthreads)
├☑ scipy 1.18.0
└☑ matplotlib 3.11.0 (backend=qtagg)
Numerical (optional)
├☑ scikit-learn 1.8.0
├☑ threadpoolctl 3.6.0
├☑ numba 0.65.1
├☑ nibabel 5.4.2
├☑ nilearn 0.14.0
├☑ dipy 1.12.1
├☑ openmeeg 2.5.16
├☑ pandas 3.0.3
├☑ h5io 0.2.5
├☑ h5py 3.16.0
└☐ unavailable python-picard, jamica, cupy
Visualization (optional)
├☑ pyvista 0.48.4 (OpenGL 4.5.0 NVIDIA 595.99.02 via NVIDIA RTX A400/PCIe/SSE2)
├☑ pyvistaqt 0.12.0
├☑ vtk 9.6.2
├☑ qtpy 2.4.3 (PySide6=6.11.1)
├☑ pyqtgraph 0.14.0
├☑ mne-qt-browser 0.7.5
├☑ ipywidgets 8.1.8
├☑ trame 3.13.2
├☑ trame_client 3.13.2
├☑ trame_server 3.12.5
├☑ trame_vtk 2.11.13
├☑ trame_vuetify 3.2.2
└☐ unavailable ipympl, trame_pyvista
Ecosystem (optional)
├☑ mne-bids 0.21.0.dev6+gcd32e35ff
├☑ mne-nirs 0.7.3
├☑ mne-connectivity 0.8.1
├☑ mne-icalabel 0.9.0
├☑ mne-bids-pipeline 1.11.0.dev84+g51b0df8e9
├☑ autoreject 0.4.4
├☑ neo 0.14.5
├☑ eeglabio 0.1.3
├☑ edfio 0.4.13
├☑ curryreader 0.1.2
├☑ mffpy 0.11.0
├☑ pybv 0.8.1
├☑ pymef 1.4.8
├☑ antio 0.7.0
├☑ defusedxml 0.7.1
└☐ unavailable mne-features
- 主要言語
- Python
- スター
- 3.5k
- フォーク
- 1.6k
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 74
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
mne-tools/mne-python のほかの issue
-
ENH: Add `description` filter parameter to `Raw.crop_by_annotations()`対応中かも @aman-coder03 が 192 日前に担当しました。 オープンENH
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mne-tools/mne-python#13743 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
BUG
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
mne-tools/mne-python#14421 ·
メンテナーはふだん 1 日以内に返信
-
BUG: fNIRS `interpolate_bads` copies wrong channel when positions are missing対応中かも @kalomak が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 20/100
mne-tools/mne-python#14415 ·
メンテナーはふだん 1 日以内に返信
-
Add a check for `sklearn` availability to `decoding` module対応中かも @SohamXYZDev が 3 日前に担当しました。 オープン
難易度 3/5 半日 初心者へのやさしさ 35/100
mne-tools/mne-python#14394 · コメント 13 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
mne-tools/mne-python#14392 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
mne-tools/mne-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
UKGovernmentBEIS/control-arena#917 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
debpalash/VoiceStudio#2937 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
aws-samples/sample-per-model-bedrock#261 ·
メンテナーはふだん 1 日以内に返信