Skip to content

Commit 0be8a65

Browse files
committed
ENH: Add helper script to test workflow
1 parent 088784e commit 0be8a65

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

scripts/bold_subcortical.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""Script for testing the subcortical MNI alignment"""
2+
from pathlib import Path
3+
4+
5+
def init_workflow(bold_file, bold_roi, bold_atlas_roi, atlas_xfm, TR=None):
6+
from nibabies.workflows.bold.alignment import init_subcortical_mni_alignment_wf
7+
8+
if TR is None:
9+
# guess TR from header
10+
import nibabel as nb
11+
img = nb.load(bold_file)
12+
assert len(img.shape) > 3, "Not a 4D file"
13+
TR = img.header['pixdim'][4]
14+
15+
wf = init_subcortical_mni_alignment_wf(repetition_time=TR)
16+
wf.inputs.inputnode.bold_file = bold_file
17+
wf.inputs.inputnode.bold_roi = bold_roi
18+
wf.inputs.inputnode.atlas_roi = bold_atlas_roi
19+
wf.inputs.inputnode.atlas_xfm = atlas_xfm
20+
21+
wf.base_dir = Path('workdir').absolute()
22+
return wf
23+
24+
25+
if __name__ == "__main__":
26+
from argparse import ArgumentParser, RawTextHelpFormatter
27+
28+
parser = ArgumentParser(
29+
description="DCAN subcortical MNI alignment",
30+
formatter_class=RawTextHelpFormatter,
31+
)
32+
parser.add_argument(
33+
"bold_file",
34+
type=Path,
35+
help="the input BOLD file",
36+
)
37+
parser.add_argument(
38+
"bold_roi",
39+
type=Path,
40+
help="segmentations in BOLD space",
41+
)
42+
parser.add_argument(
43+
"bold_atlas_roi",
44+
type=Path,
45+
help="segmentations in ROI space, unrefined",
46+
)
47+
parser.add_argument(
48+
"atlas_xfm",
49+
type=Path,
50+
help="transformation of input BOLD file to MNI space",
51+
)
52+
parser.add_argument(
53+
"--tr",
54+
type=float,
55+
help="BOLD repetition time. If not provided, NIfTI header information is used",
56+
)
57+
opts = parser.parse_args()
58+
init_workflow(
59+
opts.bold_file.absolute(),
60+
opts.bold_roi.absolute(),
61+
opts.bold_atlas_roi.absolute(),
62+
opts.atlas_xfm.absolute(),
63+
TR=opts.tr,
64+
).run()

0 commit comments

Comments
 (0)