@@ -502,6 +502,51 @@ def test_DerivativesDataSink_values(tmp_path, dtype):
502
502
assert sha1 (out_file .read_bytes ()).hexdigest () == checksum
503
503
504
504
505
+ @pytest .mark .parametrize (
506
+ "source_file" ,
507
+ [
508
+ BOLD_PATH ,
509
+ [BOLD_PATH ],
510
+ [BOLD_PATH , "ds054/sub-100185/func/sub-100185_task-machinegame_run-02_bold.nii.gz" ]
511
+ ]
512
+ )
513
+ @pytest .mark .parametrize ("source_dtype" , ["<i4" , "<f4" ])
514
+ @pytest .mark .parametrize ("in_dtype" , ["<i4" , "<f4" ])
515
+ def test_DerivativesDataSink_data_dtype_source (
516
+ tmp_path , source_file , source_dtype , in_dtype
517
+ ):
518
+
519
+ def make_empty_nii_with_dtype (fname , dtype ):
520
+ Path (fname ).parent .mkdir (exist_ok = True , parents = True )
521
+
522
+ size = (2 , 3 , 4 , 5 )
523
+
524
+ nb .Nifti1Image (np .zeros (size , dtype = dtype ), np .eye (4 )).to_filename (fname )
525
+
526
+ in_file = str (tmp_path / "in.nii" )
527
+ make_empty_nii_with_dtype (in_file , in_dtype )
528
+
529
+ if isinstance (source_file , str ):
530
+ source_file = str (tmp_path / source_file )
531
+ make_empty_nii_with_dtype (source_file , source_dtype )
532
+
533
+ elif isinstance (source_file , list ):
534
+ source_file = [str (tmp_path / s ) for s in source_file ]
535
+ for s in source_file :
536
+ make_empty_nii_with_dtype (s , source_dtype )
537
+
538
+ dds = bintfs .DerivativesDataSink (
539
+ base_directory = str (tmp_path ),
540
+ data_dtype = "source" ,
541
+ desc = "preproc" ,
542
+ source_file = source_file ,
543
+ in_file = in_file ,
544
+ ).run ()
545
+
546
+ nii = nb .load (dds .outputs .out_file )
547
+ assert nii .get_data_dtype () == np .dtype (source_dtype )
548
+
549
+
505
550
@pytest .mark .parametrize ("field" , ["RepetitionTime" , "UndefinedField" ])
506
551
def test_ReadSidecarJSON_connection (testdata_dir , field ):
507
552
"""
0 commit comments