Skip to content

Commit 5c44374

Browse files
committed
Generated mrtrix tasks from print-pydra-dev
1 parent 8b1cd93 commit 5c44374

File tree

298 files changed

+26000
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

298 files changed

+26000
-2
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,3 @@ _version.py
140140
# Mac Garbage
141141
.DS_Store
142142

143-
/pydra/tasks/mrtrix3/v3_0

generate

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
PKG_DIR=$(dirname $0)
5+
6+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
7+
AUTO_CONV_SUFFIX="-auto-gen"
8+
REBASED_SUFFIX="-rebased-on-auto-gen"
9+
10+
if ! git diff-index --quiet HEAD --; then
11+
echo "Current branch '$CURRENT_BRANCH' has uncommitted changes. Please commit or stash them before proceeding."
12+
exit 1
13+
fi
14+
15+
echo "Automatically converting Nipype tasks to Pydra tasks..."
16+
17+
echo "Create '$CURRENT_BRANCH$REBASED_SUFFIX' and '$CURRENT_BRANCH$AUTO_CONV_SUFFIX' branches if not present and switch to $CURRENT_BRANCH$AUTO_CONV_SUFFIX"
18+
echo "NB: $CURRENT_BRANCH$AUTO_CONV_SUFFIX will contain the conversion specs from '$CURRENT_BRANCH' and the auto-generted tasks,"
19+
echo "wherease '$CURRENT_BRANCH$REBASED_SUFFIX' will be the changes in the current branch rebased on that"
20+
if [ "$CURRENT_BRANCH" == "*$REBASED_SUFFIX"]; then
21+
BASE_BRANCH=${CURRENT_BRANCH%"$REBASED_SUFFIX"}$AUTO_CONV_SUFFIX
22+
REBASE_BRANCH=$CURRENT_BRANCH
23+
git checkout $BASE_BRANCH
24+
else
25+
REBASE_BRANCH=${CURRENT_BRANCH}$REBASED_SUFFIX
26+
BASE_BRANCH=${CURRENT_BRANCH}$AUTO_CONV_SUFFIX
27+
git checkout -b $REBASE_BRANCH
28+
git checkout -b $BASE_BRANCH
29+
fi
30+
31+
32+
echo "Running auto-generation of MRtrix3 tasks..."
33+
CMD_DIR=$(dirname $(which mrconvert))
34+
python3 $PKG_DIR/generate.py $CMD_DIR $PKG_DIR 3.1.0
35+
36+
echo "Committing converted tasks to ${CURRENT_BRANCH}$AUTO_CONV_SUFFIX..."
37+
git add pydra/tasks/mrtrix3
38+
git commit -m "auto-generated MRtrix3 Pydra tasks" || echo true
39+
40+
echo "Rebasing '$REBASE_BRANCH' to apply changes..."
41+
git checkout $REBASE_BRANCH
42+
git rebase $BASE_BRANCH
43+
44+
echo "Successfully converted Nipype tasks to Pydra tasks and rebased manual edits over the top of them in '$REBASE_BRANCH'

generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def auto_gen_cmd(
234234
base_cmd = str(cmd_dir / cmd[0])
235235
cmd = [base_cmd] + cmd[1:]
236236
try:
237-
code_str = sp.check_output(cmd + ["__print_usage_pydra__"]).decode("utf-8")
237+
code_str = sp.check_output(cmd + ["__print_pydra_code__"]).decode("utf-8")
238238
except sp.CalledProcessError:
239239
if log_errors:
240240
logger.error("Could not generate interface for '%s'", cmd_name)
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Auto-generated, do not edit
2+
3+
from .fivett2gmwmi import Fivett2Gmwmi
4+
from .fivett2vis import Fivett2Vis
5+
from .fivettcheck import FivettCheck
6+
from .fivettedit import FivettEdit
7+
from .fivettgen_deep_atropos import FivettGen_Deep_atropos
8+
from .fivettgen_freesurfer import FivettGen_Freesurfer
9+
from .fivettgen_fsl import FivettGen_Fsl
10+
from .fivettgen_gif import FivettGen_Gif
11+
from .fivettgen_hsvs import FivettGen_Hsvs
12+
from .afdconnectivity import AfdConnectivity
13+
from .amp2response import Amp2Response
14+
from .amp2sh import Amp2Sh
15+
from .connectome2tck import Connectome2Tck
16+
from .connectomeedit import ConnectomeEdit
17+
from .connectomestats import ConnectomeStats
18+
from .dcmedit import DcmEdit
19+
from .dcminfo import DcmInfo
20+
from .dirflip import DirFlip
21+
from .dirgen import DirGen
22+
from .dirmerge import DirMerge
23+
from .dirorder import DirOrder
24+
from .dirrotate import DirRotate
25+
from .dirsplit import DirSplit
26+
from .dirstat import DirStat
27+
from .dwi2adc import Dwi2Adc
28+
from .dwi2fod import Dwi2Fod
29+
from .dwi2mask_3dautomask import Dwi2Mask_3dautomask
30+
from .dwi2mask_ants import Dwi2Mask_Ants
31+
from .dwi2mask_b02template import Dwi2Mask_B02template
32+
from .dwi2mask_consensus import Dwi2Mask_Consensus
33+
from .dwi2mask_fslbet import Dwi2Mask_Fslbet
34+
from .dwi2mask_hdbet import Dwi2Mask_Hdbet
35+
from .dwi2mask_legacy import Dwi2Mask_Legacy
36+
from .dwi2mask_mean import Dwi2Mask_Mean
37+
from .dwi2mask_mtnorm import Dwi2Mask_Mtnorm
38+
from .dwi2mask_synthstrip import Dwi2Mask_Synthstrip
39+
from .dwi2mask_trace import Dwi2Mask_Trace
40+
from .dwi2response_dhollander import Dwi2Response_Dhollander
41+
from .dwi2response_fa import Dwi2Response_Fa
42+
from .dwi2response_manual import Dwi2Response_Manual
43+
from .dwi2response_msmt_5tt import Dwi2Response_Msmt_5tt
44+
from .dwi2response_tax import Dwi2Response_Tax
45+
from .dwi2response_tournier import Dwi2Response_Tournier
46+
from .dwi2tensor import Dwi2Tensor
47+
from .dwibiascorrect_ants import DwiBiascorrect_Ants
48+
from .dwibiascorrect_fsl import DwiBiascorrect_Fsl
49+
from .dwibiascorrect_mtnorm import DwiBiascorrect_Mtnorm
50+
from .dwibiasnormmask import DwiBiasnormmask
51+
from .dwicat import DwiCat
52+
from .dwidenoise import DwiDenoise
53+
from .dwiextract import DwiExtract
54+
from .dwifslpreproc import DwiFslpreproc
55+
from .dwigradcheck import DwiGradcheck
56+
from .dwinormalise_group import DwiNormalise_Group
57+
from .dwinormalise_manual import DwiNormalise_Manual
58+
from .dwinormalise_mtnorm import DwiNormalise_Mtnorm
59+
from .dwishellmath import DwiShellmath
60+
from .fixel2peaks import Fixel2Peaks
61+
from .fixel2sh import Fixel2Sh
62+
from .fixel2tsf import Fixel2Tsf
63+
from .fixel2voxel import Fixel2Voxel
64+
from .fixelcfestats import FixelCfestats
65+
from .fixelconnectivity import FixelConnectivity
66+
from .fixelconvert import FixelConvert
67+
from .fixelcorrespondence import FixelCorrespondence
68+
from .fixelcrop import FixelCrop
69+
from .fixelfilter import FixelFilter
70+
from .fixelreorient import FixelReorient
71+
from .fod2dec import Fod2Dec
72+
from .fod2fixel import Fod2Fixel
73+
from .label2colour import Label2Colour
74+
from .label2mesh import Label2Mesh
75+
from .labelconvert import LabelConvert
76+
from .labelsgmfirst import LabelSgmfirst
77+
from .labelstats import LabelStats
78+
from .mask2glass import Mask2Glass
79+
from .maskdump import MaskDump
80+
from .maskfilter import MaskFilter
81+
from .mesh2voxel import Mesh2Voxel
82+
from .meshconvert import MeshConvert
83+
from .meshfilter import MeshFilter
84+
from .mraverageheader import MrAverageheader
85+
from .mrcat import MrCat
86+
from .mrcentroid import MrCentroid
87+
from .mrcheckerboardmask import MrCheckerboardmask
88+
from .mrclusterstats import MrClusterstats
89+
from .mrcolour import MrColour
90+
from .mrconvert import MrConvert
91+
from .mrdegibbs import MrDegibbs
92+
from .mrdump import MrDump
93+
from .mredit import MrEdit
94+
from .mrfilter import MrFilter
95+
from .mrgrid import MrGrid
96+
from .mrhistmatch import MrHistmatch
97+
from .mrhistogram import MrHistogram
98+
from .mrinfo import MrInfo
99+
from .mrmath import MrMath
100+
from .mrmetric import MrMetric
101+
from .mrregister import MrRegister
102+
from .mrstats import MrStats
103+
from .mrthreshold import MrThreshold
104+
from .mrtransform import MrTransform
105+
from .mrtrix_cleanup import MrTrix_Cleanup
106+
from .mtnormalise import MtNormalise
107+
from .peaks2amp import Peaks2Amp
108+
from .peaks2fixel import Peaks2Fixel
109+
from .population_template import PopulationTemplate
110+
from .responsemean import ResponseMean
111+
from .sh2amp import Sh2Amp
112+
from .sh2peaks import Sh2Peaks
113+
from .sh2power import Sh2Power
114+
from .sh2response import Sh2Response
115+
from .shbasis import ShBasis
116+
from .shconv import ShConv
117+
from .tck2connectome import Tck2Connectome
118+
from .tck2fixel import Tck2Fixel
119+
from .tckconvert import TckConvert
120+
from .tckdfc import TckDfc
121+
from .tckedit import TckEdit
122+
from .tckgen import TckGen
123+
from .tckglobal import TckGlobal
124+
from .tckinfo import TckInfo
125+
from .tckmap import TckMap
126+
from .tckresample import TckResample
127+
from .tcksample import TckSample
128+
from .tcksift import TckSift
129+
from .tcksift2 import TckSift2
130+
from .tckstats import TckStats
131+
from .tcktransform import TckTransform
132+
from .tensor2metric import Tensor2Metric
133+
from .transformcalc import TransformCalc
134+
from .transformcompose import TransformCompose
135+
from .transformconvert import TransformConvert
136+
from .tsfdivide import TsfDivide
137+
from .tsfinfo import TsfInfo
138+
from .tsfmult import TsfMult
139+
from .tsfsmooth import TsfSmooth
140+
from .tsfthreshold import TsfThreshold
141+
from .tsfvalidate import TsfValidate
142+
from .vectorstats import VectorStats
143+
from .voxel2fixel import Voxel2Fixel
144+
from .voxel2mesh import Voxel2Mesh
145+
from .warp2metric import Warp2Metric
146+
from .warpconvert import WarpConvert
147+
from .warpcorrect import WarpCorrect
148+
from .warpinit import WarpInit
149+
from .warpinvert import WarpInvert
150+
from ..manual.mrcalc import MrCalc
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Auto-generated from MRtrix C++ command with '__print_pydra_code__' secret option
2+
3+
import typing as ty
4+
from pathlib import Path # noqa: F401
5+
from fileformats.generic import File, Directory # noqa: F401
6+
from fileformats.medimage_mrtrix3 import ImageIn, ImageOut, Tracks # noqa: F401
7+
from pydra.compose import shell
8+
from pydra.utils.typing import MultiInputObj
9+
10+
11+
@shell.define
12+
class AfdConnectivity(shell.Task["AfdConnectivity.Outputs"]):
13+
"""This estimate is obtained by determining a fibre volume (AFD) occupied by the pathway of interest, and dividing by the streamline length.
14+
15+
If only the streamlines belonging to the pathway of interest are provided, then ALL of the fibre volume within each fixel selected will contribute to the result. If the -wbft option is used to provide whole-brain fibre-tracking (of which the pathway of interest should contain a subset), only the fraction of the fibre volume in each fixel estimated to belong to the pathway of interest will contribute to the result.
16+
17+
Use -quiet to suppress progress messages and output fibre connectivity value only.
18+
19+
For valid comparisons of AFD connectivity across scans, images MUST be intensity normalised and bias field corrected, and a common response function for all subjects must be used.
20+
21+
Note that the sum of the AFD is normalised by streamline length to account for subject differences in fibre bundle length. This normalisation results in a measure that is more related to the cross-sectional volume of the tract (and therefore 'connectivity'). Note that SIFT-ed tract count is a superior measure because it is unaffected by tangential yet unrelated fibres. However, AFD connectivity may be used as a substitute when Anatomically Constrained Tractography is not possible due to uncorrectable EPI distortions, and SIFT may therefore not be as effective.
22+
23+
Longer discussion regarding this command can additionally be found at: https://mrtrix.readthedocs.io/en/3.0.4/concepts/afd_connectivity.html (as well as in the relevant reference).
24+
25+
26+
References
27+
----------
28+
29+
Smith, R. E.; Raffelt, D.; Tournier, J.-D.; Connelly, A. Quantitative Streamlines Tractography: Methods and Inter-Subject Normalisation. Open Science Framework, https://doi.org/10.31219/osf.io/c67kn.
30+
31+
Tournier, J.-D.; Smith, R. E.; Raffelt, D.; Tabbara, R.; Dhollander, T.; Pietsch, M.; Christiaens, D.; Jeurissen, B.; Yeh, C.-H. & Connelly, A. MRtrix3: A fast, flexible and open software framework for medical image processing and visualisation. NeuroImage, 2019, 202, 116137
32+
33+
34+
MRtrix
35+
------
36+
37+
Version:3.0.4-1402-gd28b95cd, built Aug 22 2025
38+
39+
Author: David Raffelt ([email protected]) and Robert E. Smith ([email protected])
40+
41+
Copyright: Copyright (c) 2008-2025 the MRtrix3 contributors.
42+
43+
This Source Code Form is subject to the terms of the Mozilla Public
44+
License, v. 2.0. If a copy of the MPL was not distributed with this
45+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
46+
47+
Covered Software is provided under this License on an "as is"
48+
basis, without warranty of any kind, either expressed, implied, or
49+
statutory, including, without limitation, warranties that the
50+
Covered Software is free of defects, merchantable, fit for a
51+
particular purpose or non-infringing.
52+
See the Mozilla Public License v. 2.0 for more details.
53+
54+
For more details, see http://www.mrtrix.org/.
55+
"""
56+
57+
executable = "afdconnectivity"
58+
59+
# Arguments
60+
image_: ImageIn = shell.arg(
61+
argstr="",
62+
position=1,
63+
help="""the input FOD image.""",
64+
)
65+
tracks: Tracks = shell.arg(
66+
argstr="",
67+
position=2,
68+
help="""the input track file defining the bundle of interest.""",
69+
)
70+
71+
# Options
72+
wbft: Tracks | None = shell.arg(
73+
default=None,
74+
argstr="-wbft",
75+
help="""provide a whole-brain fibre-tracking data set (of which the input track file should be a subset), to improve the estimate of fibre bundle volume in the presence of partial volume""",
76+
)
77+
all_fixels: bool = shell.arg(
78+
default=False,
79+
argstr="-all_fixels",
80+
help="""if whole-brain fibre-tracking is NOT provided, then if multiple fixels within a voxel are traversed by the pathway of interest, by default the fixel with the greatest streamlines density is selected to contribute to the AFD in that voxel. If this option is provided, then ALL fixels with non-zero streamlines density will contribute to the result, even if multiple fixels per voxel are selected.""",
81+
)
82+
83+
# Standard options
84+
info: bool = shell.arg(
85+
default=False,
86+
argstr="-info",
87+
help="""display information messages.""",
88+
)
89+
quiet: bool = shell.arg(
90+
default=False,
91+
argstr="-quiet",
92+
help="""do not display information messages or progress status; alternatively, this can be achieved by setting the MRTRIX_QUIET environment variable to a non-empty string.""",
93+
)
94+
debug: bool = shell.arg(
95+
default=False,
96+
argstr="-debug",
97+
help="""display debugging messages.""",
98+
)
99+
force: bool = shell.arg(
100+
default=False,
101+
argstr="-force",
102+
help="""force overwrite of output files (caution: using the same file as input and output might cause unexpected behaviour).""",
103+
)
104+
nthreads: int | None = shell.arg(
105+
default=None,
106+
argstr="-nthreads",
107+
help="""use this number of threads in multi-threaded applications (set to 0 to disable multi-threading).""",
108+
)
109+
config: MultiInputObj[tuple[str, str]] | None = shell.arg(
110+
default=None,
111+
argstr="-config",
112+
help="""temporarily set the value of an MRtrix config file entry.""",
113+
sep=" ",
114+
)
115+
116+
class Outputs(shell.Outputs):
117+
afd_map: ImageOut | bool | None = shell.outarg(
118+
default=None,
119+
argstr="-afd_map",
120+
path_template="afd_map.mif",
121+
help="""output a 3D image containing the AFD estimated for each voxel.""",
122+
)

0 commit comments

Comments
 (0)