Skip to content

Commit 56fbe80

Browse files
authored
manualseg resampling in-place without transformation (#346)
* add option to resample in-place, without transforming to template corobl or assuming any kind of registration already * add cropping tight (with 5 vox pad) to dseg
1 parent 552420f commit 56fbe80

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

hippunfold/config/snakebids.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ parse_args:
171171
help: 'Sets the bounding box size for the crop native (e.g. cropT1w space). Make this larger if your hippocampi in crop{T1w,T2w} space are getting cut-off. This must be in voxels (vox) not millimeters (mm). (default: %(default)s)'
172172
default: '256x256x256vox'
173173

174+
--resample_manualseg:
175+
help: 'Resample the manual segmentation (for --modality manualseg), keeping the bounding box the same, but changing the number of voxels in the image. This can be specified as voxels ("300x300x300"), or a percentage ("20%%") or percentage in each direction ("20x20x40%%"). Note: the segmentation will always be subsequently cropped around the segmentation, with a padding of 5 voxels. (default: %(default)s)'
176+
default: null
177+
178+
174179
--atlas:
175180
choices:
176181
- 'multihist7'
@@ -688,3 +693,4 @@ root: results
688693
workdir: null
689694
use_template_seg: False
690695
template_seg_smoothing_factor: 2
696+
resample_manualseg: null
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11

2-
rule import_manualseg_to_corobl:
2+
rule import_manualseg_with_resample:
33
input:
44
in_img=partial(get_single_bids_input, component="manualseg"),
5-
template_dir=Path(download_dir) / "template" / config["template"],
65
params:
7-
std_to_cor=lambda wildcards, input: Path(input.template_dir)
8-
/ config["template_files"][config["template"]]["xfm_corobl"].format(
9-
**wildcards
10-
),
11-
ref=lambda wildcards, input: Path(input.template_dir)
12-
/ config["template_files"][config["template"]]["crop_ref"].format(**wildcards),
6+
resample_cmd=""
7+
if config["resample_manualseg"] == None
8+
else "-resample {res}".format(res=config["resample_manualseg"]),
9+
crop_cmd="-trim 5vox", #leave 5 voxel padding
1310
output:
1411
nii=bids(
1512
root=work,
@@ -24,5 +21,4 @@ rule import_manualseg_to_corobl:
2421
group:
2522
"subj"
2623
shell:
27-
"ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS={threads} "
28-
"antsApplyTransforms -d 3 --interpolation MultiLabel -i {input.in_img} -o {output.nii} -r {params.ref} -t {params.std_to_cor}"
24+
"c3d {input} -int 0 {params.resample_cmd} {params.crop_cmd} -o {output}"

0 commit comments

Comments
 (0)