Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make M0 TR optional for BASIL #323

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions aslprep/interfaces/cbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,24 @@ def _run_interface(self, runtime):
control_img = smooth_image(control_img, fwhm=self.inputs.fwhm).get_fdata()
m0data = mask_data * np.mean(control_img, axis=3)

# Use the control volumes' TR as the M0 TR.
if np.array(metadata["RepetitionTimePreparation"]).size > 1:
m0tr = np.array(metadata["RepetitionTimePreparation"])[control_volume_idx[0]]
else:
m0tr = metadata["RepetitionTimePreparation"]

elif cbf_volume_idx:
# If we have precalculated CBF data, we don't need M0, so we'll just use the mask.
m0data = mask_data

m0tr = None

else:
raise RuntimeError(
"m0scan is absent, "
"and there are no control volumes that can be used as a substitute"
)

m0tr = None

else:
raise RuntimeError("no pathway to m0scan")

Expand Down Expand Up @@ -823,7 +829,7 @@ class _BASILCBFInputSpec(FSLCommandInputSpec):
m0tr = traits.Float(
desc="The repetition time for the calibration image (the M0 scan).",
argstr="--tr %.2f",
mandatory=True,
mandatory=False,
)
tis = traits.Either(
traits.Float(),
Expand Down
8 changes: 6 additions & 2 deletions aslprep/workflows/asl/cbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ def _getfiledir(file):
(("m0_file", _getfiledir), "out_basename"),
("out_file", "deltam"),
("m0_file", "mzero"),
("m0tr", "m0tr"),
]),
(determine_bolus_duration, basilcbf, [("bolus", "bolus")]),
(determine_inflow_times, basilcbf, [("tis", "tis")]),
Expand All @@ -482,6 +481,9 @@ def _getfiledir(file):
])
# fmt:on

if metadata["M0Type"] != "Estimate":
workflow.connect([(extract_deltam, basilcbf, [("m0tr", "m0tr")])])

return workflow


Expand Down Expand Up @@ -834,7 +836,6 @@ def _getfiledir(file):
(inputnode, basilcbf, [
(("asl_mask", _getfiledir), "out_basename"),
("m0_file", "mzero"),
("m0tr", "m0tr"),
]),
(collect_cbf, basilcbf, [("deltam", "deltam")]),
(gm_tfm, basilcbf, [("output_image", "gm_tpm")]),
Expand All @@ -849,6 +850,9 @@ def _getfiledir(file):
])
# fmt:on

if metadata["M0Type"] != "Estimate":
workflow.connect([(inputnode, basilcbf, [("m0tr", "m0tr")])])

return workflow


Expand Down
Loading