File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -363,3 +363,25 @@ def test_LinearTransformsMapping_apply(
363
363
reference = testdata_path / "sbref.nii.gz" ,
364
364
serialize_nvols = 2 if serialize_4d else np .inf ,
365
365
)
366
+
367
+
368
+ def test_apply_serialized_4d_multiple_targets ():
369
+ """Regression test for per-volume transforms with serialized resampling."""
370
+ nvols = 9
371
+ shape = (10 , 5 , 5 )
372
+ base = np .zeros (shape , dtype = np .float32 )
373
+ base [9 , 2 , 2 ] = 1
374
+ img = nb .Nifti1Image (np .stack ([base ] * nvols , axis = - 1 ), np .eye (4 ))
375
+
376
+ transforms = []
377
+ for i in range (nvols ):
378
+ mat = np .eye (4 )
379
+ mat [0 , 3 ] = i
380
+ transforms .append (nitl .Affine (mat ))
381
+
382
+ xfm = nitl .LinearTransformsMapping (transforms , reference = img )
383
+ moved = apply (xfm , img , order = 0 )
384
+
385
+ data = np .asanyarray (moved .dataobj )
386
+ idxs = [tuple (np .argwhere (data [..., i ])[0 ]) for i in range (nvols )]
387
+ assert idxs == [(9 - i , 2 , 2 ) for i in range (nvols )]
You can’t perform that action at this time.
0 commit comments