`DenseFieldTransform.map()` wraps or raises for on-grid points outside the field
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- numpy, python
調査の方向性
nitransforms/nonlinear.py の 185-191 行付近にある fast path から始めます。ここでは on-grid の点がボクセルインデックスに丸められ、境界チェックなしでフィールドのインデックス指定に使われます。次に、0.01 mm off-grid で使われる補間パスと比較します。issue の再現スニペットを実行して、インデックス -1 がラップし、インデックス n が IndexError を発生させることを確認します。両方のアサーションが通り、グリッド外の on-grid の点が off-grid パスと同じ結果を返したら完了です。
索引モデルが issue の本文から書いたものです。
説明
When every point falls on a voxel center, map() takes a fast path:
That rounds points to voxel indices and indexes the field with them, without checking bounds. A point one voxel before the grid gets index -1 and wraps to the last voxel. A point one voxel past the grid gets index n and raises IndexError. Shifting 0.01 mm off the grid switches to the interpolation path, with the correct result.
Reproduction
import nibabel as nb
import numpy as np
from nitransforms.nonlinear import DenseFieldTransform
# 21^3 grid of 4 mm voxels spanning -40..40 mm; +100 mm x-shift in the last x slab only
deltas = np.zeros((21, 21, 21, 3), dtype="float32")
deltas[-1, ..., 0] = 100.0
affine = nb.affines.from_matvec(np.eye(3) * 4, [-40] * 3)
xfm = DenseFieldTransform(nb.Nifti1Image(deltas, affine))
# 0.01 mm off-grid, one voxel before the grid start: no displacement
assert np.allclose(xfm.map([[-44.01, 0, 0]]), [[-44.01, 0, 0]])
# On-grid, one voxel before the grid start
assert np.allclose(xfm.map([[-44.0, 0, 0]]), [[-44.0, 0, 0]])
The first assertion passes, second fails:
>>> xfm.map([[-44.01, 0, 0]])
array([[-44.01, 0. , 0. ]])
>>> xfm.map([[-44.0, 0, 0]])
array([[140., 0., 0.]])
- 主要言語
- Python
- スター
- 36
- フォーク
- 18
- 平均マージ
- 1時間 24分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nipy/nitransforms のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nipy/nitransforms#307 ·
-
難易度 3/5 半日 初心者へのやさしさ 25/100
nipy/nitransforms#305 ·
-
`BSplineFieldTransform` ignores `order`対応中かも @effigies が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
nipy/nitransforms#302 ·
-
`BSplineFieldTransform.to_field()` reuses the weights of its first reference対応中かも @effigies が 1 日前に担当しました。 オープン
難易度 3/5 半日 初心者へのやさしさ 55/100
nipy/nitransforms#301 ·
-
`BSplineFieldTransform.to_field()` ignores the orientation of the reference grid対応中かも @effigies が 1 日前に担当しました。 オープン
難易度 3/5 半日 初心者へのやさしさ 45/100
nipy/nitransforms#300 ·
nipy/nitransforms の issue をすべて見る
似ている issue
-
eegprep-lean: set channel types from the Zarr group's channel_type対応中かも @claude が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
blacklanternsecurity/bbot#3679 ·
メンテナーはふだん 2 日以内に返信
-
Link Checker ReportオープンBot Type: Bug Type: Documentation
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
speakeasy-api/speakeasy#2159 ·
メンテナーはふだん 1 日以内に返信