Skip to content

Commit f7f209f

Browse files
authored
Merge pull request #66 from nipype/updated-auto-conv-generate
updated auto-conv generate
2 parents 59cf890 + bdb5c15 commit f7f209f

33 files changed

+101
-52
lines changed

nipype-auto-conv/generate

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
11
#!/usr/bin/env bash
2+
set -e
3+
24
conv_dir=$(dirname $0)
5+
6+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
7+
AUTO_CONV_SUFFIX="-auto-conv"
8+
REBASED_SUFFIX="-rebased-on-auto-conv"
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-converted 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+
git reset --hard $CURRENT_BRANCH
25+
else
26+
REBASE_BRANCH=${CURRENT_BRANCH}$REBASED_SUFFIX
27+
BASE_BRANCH=${CURRENT_BRANCH}$AUTO_CONV_SUFFIX
28+
git checkout -b $REBASE_BRANCH
29+
git checkout -b $BASE_BRANCH
30+
fi
31+
32+
echo "Apply nipype-auto-conv spec changes between current branch and the main auto-conv branch to the rebase branch..."
33+
git fetch origin auto-conv
34+
git reset origin/auto-conv
35+
git add $conv_dir/specs
36+
git commit -m "Update auto-conv specs with latest changes from '$CURRENT_BRANCH'" || echo true
37+
# Ignore any other changes outside the nipype-auto-conv/specs directory
38+
git reset --hard HEAD
39+
40+
echo "Running nipype2pydra conversion..."
341
nipype2pydra convert $conv_dir/specs $conv_dir/..
42+
43+
echo "Committing converted tasks to ${CURRENT_BRANCH}$AUTO_CONV_SUFFIX..."
44+
git add pydra/tasks/fsl
45+
git commit -m "Auto-converted Nipype tasks to Pydra tasks" || echo true
46+
47+
echo "Rebasing '$REBASE_BRANCH' to apply changes..."
48+
git checkout $REBASE_BRANCH
49+
git rebase $BASE_BRANCH
50+
51+
echo "Successfully converted Nipype tasks to Pydra tasks and rebased manual edits over the top of them in '$REBASE_BRANCH'

pydra/tasks/fsl/v6/aroma/ica__aroma.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class ICA_AROMA(shell.Task["ICA_AROMA.Outputs"]):
106106
help="volume to be denoised", argstr="-i {in_file}"
107107
)
108108
out_dir: ty.Any | None = shell.arg(
109-
help="output directory", formatter="out_dir_formatter", default="out"
109+
help="output directory", formatter=out_dir_formatter, default="out"
110110
)
111111
mask: NiftiGz | None = shell.arg(help="path/name volume mask", argstr="-m {mask}")
112112
dim: int = shell.arg(

pydra/tasks/fsl/v6/dti/distance_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class DistanceMap(shell.Task["DistanceMap.Outputs"]):
8989
)
9090
invert_input: bool = shell.arg(help="invert input image", argstr="--invert")
9191
local_max_file: ty.Any = shell.arg(
92-
help="write an image of the local maxima", formatter="local_max_file_formatter"
92+
help="write an image of the local maxima", formatter=local_max_file_formatter
9393
)
9494

9595
class Outputs(shell.Outputs):

pydra/tasks/fsl/v6/dti/prob_track_x.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ class ProbTrackX(shell.Task["ProbTrackX.Outputs"]):
232232
)
233233
seed: ty.Any = shell.arg(
234234
help="seed volume(s), or voxel(s) or freesurfer label file",
235-
formatter="seed_formatter",
235+
formatter=seed_formatter,
236236
)
237237
target_masks: list[Nifti1] = shell.arg(
238238
help="list of target masks - required for seeds_to_targets classification",
239-
formatter="target_masks_formatter",
239+
formatter=target_masks_formatter,
240240
)
241241
waypoints: File = shell.arg(
242242
help="waypoint mask or ascii list of waypoint masks - only keep paths going through ALL the masks",

pydra/tasks/fsl/v6/dti/prob_track_x2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,11 @@ class ProbTrackX2(shell.Task["ProbTrackX2.Outputs"]):
338338
)
339339
seed: ty.Any = shell.arg(
340340
help="seed volume(s), or voxel(s) or freesurfer label file",
341-
formatter="seed_formatter",
341+
formatter=seed_formatter,
342342
)
343343
target_masks: list[File] = shell.arg(
344344
help="list of target masks - required for seeds_to_targets classification",
345-
formatter="target_masks_formatter",
345+
formatter=target_masks_formatter,
346346
)
347347
waypoints: File = shell.arg(
348348
help="waypoint mask or ascii list of waypoint masks - only keep paths going through ALL the masks",

pydra/tasks/fsl/v6/dti/tract_skeleton.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class TractSkeleton(shell.Task["TractSkeleton.Outputs"]):
116116
project_data: bool = shell.arg(
117117
help="project data onto skeleton",
118118
requires=["threshold", "distance_map", "data_file"],
119-
formatter="project_data_formatter",
119+
formatter=project_data_formatter,
120120
)
121121
threshold: float = shell.arg(help="skeleton threshold value")
122122
distance_map: File = shell.arg(help="distance map image")
@@ -135,7 +135,7 @@ class TractSkeleton(shell.Task["TractSkeleton.Outputs"]):
135135
)
136136
projected_data: Path = shell.arg(help="input data projected onto skeleton")
137137
skeleton_file: ty.Any = shell.arg(
138-
help="write out skeleton image", formatter="skeleton_file_formatter"
138+
help="write out skeleton image", formatter=skeleton_file_formatter
139139
)
140140

141141
class Outputs(shell.Outputs):

pydra/tasks/fsl/v6/epi/apply_topup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ApplyTOPUP(shell.Task["ApplyTOPUP.Outputs"]):
8282
in_topup_fieldcoef: NiftiGz | None = shell.arg(
8383
help="topup file containing the field coefficients",
8484
requires=["in_topup_movpar"],
85-
formatter="in_topup_fieldcoef_formatter",
85+
formatter=in_topup_fieldcoef_formatter,
8686
)
8787
in_topup_movpar: File | None = shell.arg(
8888
help="topup movpar.txt file", requires=["in_topup_fieldcoef"]

pydra/tasks/fsl/v6/epi/eddy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class Eddy(shell.Task["Eddy.Outputs"]):
312312
)
313313
out_base: str = shell.arg(
314314
help="Basename for output image",
315-
formatter="out_base_formatter",
315+
formatter=out_base_formatter,
316316
default="eddy_corrected",
317317
)
318318
session: File = shell.arg(
@@ -322,14 +322,14 @@ class Eddy(shell.Task["Eddy.Outputs"]):
322322
in_topup_fieldcoef: File | None = shell.arg(
323323
help="Topup results file containing the field coefficients",
324324
requires=["in_topup_movpar"],
325-
formatter="in_topup_fieldcoef_formatter",
325+
formatter=in_topup_fieldcoef_formatter,
326326
)
327327
in_topup_movpar: File | None = shell.arg(
328328
help="Topup results file containing the movement parameters (movpar.txt)",
329329
requires=["in_topup_fieldcoef"],
330330
)
331331
field: File = shell.arg(
332-
help="Non-topup derived fieldmap scaled in Hz", formatter="field_formatter"
332+
help="Non-topup derived fieldmap scaled in Hz", formatter=field_formatter
333333
)
334334
field_mat: File = shell.arg(
335335
help="Matrix specifying the relative positions of the fieldmap, --field, and the first volume of the input file, --imain",

pydra/tasks/fsl/v6/epi/topup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,15 @@ class TOPUP(shell.Task["TOPUP.Outputs"]):
189189
encoding_direction: list[ty.Any] = shell.arg(
190190
help="encoding direction for automatic generation of encoding_file",
191191
requires=["readout_times"],
192-
formatter="encoding_direction_formatter",
192+
formatter=encoding_direction_formatter,
193193
)
194194
readout_times: MultiInputObj = shell.arg(
195195
help="readout times (dwell times by # phase-encode steps minus 1)",
196196
requires=["encoding_direction"],
197197
)
198198
out_base: Path = shell.arg(
199199
help="base-name of output files (spline coefficients (Hz) and movement parameters)",
200-
formatter="out_base_formatter",
200+
formatter=out_base_formatter,
201201
)
202202
out_warp_prefix: str = shell.arg(
203203
help="prefix for the warpfield images (in mm)",

pydra/tasks/fsl/v6/maths/dilate_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class DilateImage(shell.Task["DilateImage.Outputs"]):
5656
operation: ty.Any = shell.arg(
5757
help="filtering operation to perform in dilation",
5858
position=6,
59-
formatter="operation_formatter",
59+
formatter=operation_formatter,
6060
)
6161
kernel_shape: ty.Any = shell.arg(
6262
help="kernel shape to use", argstr="-kernel {kernel_shape}", position=4

0 commit comments

Comments
 (0)