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

[FIX] Fix input specs for eddy #67

Merged
merged 1 commit into from
Sep 14, 2023
Merged
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
121 changes: 87 additions & 34 deletions src/pydra/tasks/fsl/eddy/eddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
... fieldmap_image="fieldmap.nii",
... )
>>> task.cmdline # doctest: +ELLIPSIS
'eddy --imain input.nii --mask brain.nii --acqp params.txt --index index.txt \
--bvecs input.bvec --bvals input.bval --field fieldmap.nii --out eddy ...'
'eddy --imain=input.nii --mask=brain.nii --acqp=params.txt --index=index.txt \
--bvecs=input.bvec --bvals=input.bval --field=fieldmap.nii --out=eddy ...'
"""

__all__ = ["Eddy"]
Expand All @@ -37,41 +37,59 @@ class EddySpec(ShellSpec):

# Parameters that specify input files.
input_image: PathLike = field(
metadata={"help_string": "input image as a 4D volume", "mandatory": True, "argstr": "--imain"}
metadata={
"help_string": "input image as a 4D volume",
"mandatory": True,
"argstr": "--imain={input_image}",
}
)

brain_mask: PathLike = field(
metadata={"help_string": "brain mask as a single volume image", "mandatory": True, "argstr": "--mask"}
metadata={
"help_string": "brain mask as a single volume image",
"mandatory": True,
"argstr": "--mask={brain_mask}",
}
)

encoding_file: PathLike = field(
metadata={
"help_string": "acquisition parameters for the diffusion protocol",
"mandatory": True,
"argstr": "--acqp",
"argstr": "--acqp={encoding_file}",
}
)

index_file: PathLike = field(
metadata={
"help_string": "mapping from volume index to encoding parameters",
"mandatory": True,
"argstr": "--index",
"argstr": "--index={index_file}",
}
)

bvec_file: PathLike = field(
metadata={"help_string": "diffusion directions", "mandatory": True, "argstr": "--bvecs"}
metadata={
"help_string": "diffusion directions",
"mandatory": True,
"argstr": "--bvecs={bvec_file}",
}
)

bval_file: PathLike = field(metadata={"help_string": "diffusion weighting", "mandatory": True, "argstr": "--bvals"})
bval_file: PathLike = field(
metadata={
"help_string": "diffusion weighting",
"mandatory": True,
"argstr": "--bvals={bval_file}",
}
)

fieldmap_image: PathLike = field(metadata={"help_string": "fieldmap image", "argstr": "--field"})
fieldmap_image: PathLike = field(metadata={"help_string": "fieldmap image", "argstr": "--field={fieldmap_image}"})

fieldmap_matrix: PathLike = field(
metadata={
"help_string": "rigid-body transformation matrix from fieldmap to first input volume",
"argstr": "--field_mat",
"argstr": "--field_mat={fieldmap_matrix}",
"requires": {"fieldmap_image"},
}
)
Expand All @@ -82,15 +100,19 @@ class EddySpec(ShellSpec):

# Parameters specifying names of output-files.
output_basename: str = field(
default="eddy", metadata={"help_string": "basename for output files", "argstr": "--out"}
default="eddy",
metadata={
"help_string": "basename for output files",
"argstr": "--out={output_basename}",
},
)

# Parameters specifying how eddy should be run.
first_level_model: str = field(
default="quadratic",
metadata={
"help_string": "model for the magnetic field generated by Eddy currents",
"argstr": "--flm",
"argstr": "--flm={first_level_model}",
"allowed_values": {"movement", "linear", "quadratic", "cubic"},
},
)
Expand All @@ -99,7 +121,7 @@ class EddySpec(ShellSpec):
default="none",
metadata={
"help_string": "model for how diffusion gradients generate Eddy currents",
"argstr": "--slm",
"argstr": "--slm={second_level_model}",
"allowed_values": {"none", "linear", "quadratic"},
},
)
Expand All @@ -108,12 +130,16 @@ class EddySpec(ShellSpec):
default=0,
metadata={
"help_string": "filter width used for pre-conditioning data prior to estimating distortions",
"argstr": "--fwhm",
"argstr": "--fwhm={fwhm}",
},
)

num_iterations: int = field(
default=5, metadata={"help_string": "number of iterations for eddy", "argstr": "--niter"}
default=5,
metadata={
"help_string": "number of iterations for eddy",
"argstr": "--niter={num_iterations}",
},
)

fill_empty_planes: bool = field(metadata={"help_string": "detect and fill empty planes", "argstr": "--fep"})
Expand All @@ -122,23 +148,34 @@ class EddySpec(ShellSpec):
default="spline",
metadata={
"help_string": "interpolation method for the estimation phase",
"argstr": "--interp",
"argstr": "--interp={interpolation}",
"allowed_values": {"spline", "trilinear"},
},
)

resampling: str = field(
default="jac",
metadata={"help_string": "final resampling strategy", "argstr": "--resamp", "allowed_values": {"jac", "lsr"}},
metadata={
"help_string": "final resampling strategy",
"argstr": "--resamp={resampling}",
"allowed_values": {"jac", "lsr"},
},
)

num_voxels: int = field(
default=1000,
metadata={"help_string": "number of voxels to use for GP hyperparameter estimation", "argstr": "--nvoxhp"},
metadata={
"help_string": "number of voxels to use for GP hyperparameter estimation",
"argstr": "--nvoxhp={num_voxels}",
},
)

fudge_factor: int = field(
default=10, metadata={"help_string": "fudge factor for Q-space smoothing during estimation", "argstr": "--ff"}
default=10,
metadata={
"help_string": "fudge factor for Q-space smoothing during estimation",
"argstr": "--ff={fudge_factor}",
},
)

# Parameters for outlier replacement (ol)
Expand All @@ -147,67 +184,81 @@ class EddySpec(ShellSpec):
outlier_num_stdevs: int = field(
metadata={
"help_string": "number of times off the standard deviation to qualify as outlier",
"argstr": "--ol_nstd",
"argstr": "--ol_nstd={outlier_num_stdevs}",
"requires": {"replace_outliers"},
}
)

outlier_num_voxels: int = field(
metadata={
"help_string": "minimum number of voxels in a slice to qualify for outlier detection",
"argstr": "--ol_nvox",
"argstr": "--ol_nvox={outlier_num_voxels}",
"requires": {"replace_outliers"},
}
)

outlier_type: str = field(
metadata={
"help_string": "type of outliers detected",
"argstr": "--ol_type",
"argstr": "--ol_type={outlier_type}",
"allowed_values": {"both", "gw", "sw"},
"requires": {"replace_outliers"},
}
)

multiband_factor: int = field(metadata={"help_string": "multiband factor", "argstr": "--mb"})
multiband_factor: int = field(metadata={"help_string": "multiband factor", "argstr": "--mb={multiband_factor}"})

multiband_offset: int = field(
metadata={"help_string": "multiband slice offset", "argstr": "--mb_offs", "requires": {"multiband_factor"}}
metadata={
"help_string": "multiband slice offset",
"argstr": "--mb_offs={multiband_offset}",
"requires": {"multiband_factor"},
}
)

# Parameters for intra-volume movement correction (s2v)
movement_prediction_order: int = field(
default=0, metadata={"help_string": "order of movement prediction model", "argstr": "--mporder"}
default=0,
metadata={
"help_string": "order of movement prediction model",
"argstr": "--mporder={movement_prediction_order}",
},
)

s2v_num_iterations: int = field(
metadata={"help_string": "number of iterations for s2v movement estimation", "argstr": "--s2v_niter"}
metadata={
"help_string": "number of iterations for s2v movement estimation",
"argstr": "--s2v_niter={s2v_num_iterations}",
}
)

s2v_lambda: float = field(
metadata={"help_string": "weighting of regularization for s2v movement estimation", "argstr": "--s2v_lambda"}
metadata={
"help_string": "weighting of regularization for s2v movement estimation",
"argstr": "--s2v_lambda={s2v_lambda}",
}
)

s2v_interpolation: str = field(
metadata={
"help_string": "interpolation method for s2v movement estimation.",
"argstr": "--s2v_interp",
"argstr": "--s2v_interp={s2v_interpolation}",
"allowed_values": {"spline", "trilinear"},
}
)

slice_grouping_file: PathLike = field(
metadata={
"help_string": "file containing slice grouping information",
"argstr": "--slspec",
"argstr": "--slspec={slice_grouping_file}",
"xor": {"slice_timing_file"},
}
)

slice_timing_file: PathLike = field(
metadata={
"help_string": "file containing slice timing information",
"argstr": "--json",
"argstr": "--json={slice_timing_file}",
"xor": {"slice_grouping_file"},
}
)
Expand All @@ -223,23 +274,23 @@ class EddySpec(ShellSpec):
mbs_num_iterations: int = field(
metadata={
"help_string": "number of iterations for MBS field estimation",
"argstr": "--mbs_niter",
"argstr": "--mbs_niter={mbs_num_iterations}",
"requires": {"estimate_move_by_susceptibility"},
}
)

mbs_lambda: int = field(
metadata={
"help_string": "weighting of regularization for MBS field estimation",
"argstr": "--mbs_lambda",
"argstr": "--mbs_lambda={mbs_lambda}",
"requires": {"estimate_move_by_susceptibility"},
}
)

mbs_knot_spacing: int = field(
metadata={
"help_string": "knot-spacing for MBS field estimation",
"argstr": "--mbs_ksp",
"argstr": "--mbs_ksp={mbs_knot_spacing}",
"requires": {"estimate_move_by_susceptibility"},
}
)
Expand All @@ -249,7 +300,9 @@ class EddySpec(ShellSpec):
metadata={"help_string": "bypass checks for data shelling", "argstr": "--data_is_shelled"}
)

random_seed: int = field(metadata={"help_string": "random seed for voxel selection", "argstr": "--initrand"})
random_seed: int = field(
metadata={"help_string": "random seed for voxel selection", "argstr": "--initrand={random_seed}"}
)

save_cnr_maps: bool = field(metadata={"help_string": "save shell-wise CNR maps", "argstr": "--cnr_maps"})

Expand Down