@@ -26,3 +26,42 @@ test_that("create_preproc_mask locates mask files", {
2626 expect_true(inherits(mask , " LogicalNeuroVol" ))
2727})
2828
29+ test_that(" create_preproc_mask ignores JSON sidecars for mask matches" , {
30+ skip_if_not_installed(" RNifti" )
31+
32+ tmp <- tempfile(" preproc_mask_sidecar_" )
33+ dir.create(tmp , recursive = TRUE )
34+ on.exit(unlink(tmp , recursive = TRUE , force = TRUE ), add = TRUE )
35+
36+ readr :: write_tsv(
37+ tibble :: tibble(participant_id = " sub-1001" ),
38+ file.path(tmp , " participants.tsv" )
39+ )
40+ jsonlite :: write_json(
41+ list (Name = " MaskSidecar" , BIDSVersion = " 1.8.0" ),
42+ file.path(tmp , " dataset_description.json" ),
43+ auto_unbox = TRUE
44+ )
45+ dir.create(file.path(tmp , " sub-1001" , " func" ), recursive = TRUE )
46+ file.create(file.path(tmp , " sub-1001" , " func" ,
47+ " sub-1001_task-audio_run-01_bold.nii.gz" ))
48+
49+ deriv_root <- file.path(tmp , " derivatives" , " fmriprep" , " sub-1001" , " func" )
50+ dir.create(deriv_root , recursive = TRUE )
51+ jsonlite :: write_json(
52+ list (Name = " fmriprep" , BIDSVersion = " 1.8.0" , DatasetType = " derivative" ),
53+ file.path(tmp , " derivatives" , " fmriprep" , " dataset_description.json" ),
54+ auto_unbox = TRUE
55+ )
56+
57+ mask_path <- file.path(
58+ deriv_root ,
59+ " sub-1001_task-audio_run-01_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.nii.gz"
60+ )
61+ RNifti :: writeNifti(array (1 , dim = c(2 , 2 , 2 )), mask_path )
62+ writeLines(" {}" , sub(" \\ .nii\\ .gz$" , " .json" , mask_path ))
63+
64+ proj <- bids_project(tmp , fmriprep = TRUE )
65+ mask <- create_preproc_mask(proj , subid = " 1001" )
66+ expect_true(inherits(mask , " LogicalNeuroVol" ))
67+ })
0 commit comments