Skip to content

Commit 211abd3

Browse files
Add parcel (#317)
parcel for marmo
1 parent 49d9554 commit 211abd3

9 files changed

Lines changed: 331 additions & 97 deletions

File tree

macapype/bash/IterREGBET.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,13 @@ for ((i = 1 ; i <= $NITER ; i++)); do
278278

279279
# Extra whole-head non-linear registration, if wanted
280280
if [[ -n $REF_WHOLE ]] && [[ $i == $NITER ]]; then
281-
echo "FNIRT..."
281+
echo "FNIRT..." 1>&2
282282
"${FSLPREFIX}fnirt" --in=$IN_WHOLE --ref=$REF_WHOLE --aff=$I2R_XFM --iout=${WARP[WH_OUT]} --cout=${WARP[WH_WARP]} # compute warp
283-
echo "Inverting warp..."
283+
#"${FSLPREFIX}fnirt" --in=$IN_WHOLE --ref=$REF_WHOLE --aff=$I2R_XFM --iout=${WARP[WH_OUT]} --cout=${WARP[WH_WARP]} --miter=5,3 --subsamp=4,2 --infwhm=6,4 --reffwhm=4,2 --estint=false --applyrefmask=false --applyinmask=false # compute warp
284+
#"${FSLPREFIX}fnirt" --in=$IN_WHOLE --ref=$REF_WHOLE --aff=$I2R_XFM --iout=${WARP[WH_OUT]} --cout=${WARP[WH_WARP]} --miter=1 --subsamp=4 --infwhm=6 --reffwhm=4 --estint=false --applyrefmask=false --applyinmask=false # compute warp
285+
echo "Inverting warp..." 1>&2
284286
"${FSLPREFIX}invwarp" -r $IN_WHOLE -w ${WARP[WH_WARP]} -o ${WARP[WH_INVWARP]}
285-
echo "Applying inverse warp..."
287+
echo "Applying inverse warp..." 1>&2
286288
"${FSLPREFIX}applywarp" --ref=$IN_WHOLE --in=${TMP[REF_MASK]} --out=$IN_OUT_MASK --warp=${WARP[WH_INVWARP]} --interp=nn
287289
else
288290
"${FSLPREFIX}flirt" -in ${TMP[REF_MASK]} -ref $IN_WHOLE -out $IN_OUT_MASK -interp nearestneighbour -applyxfm -init $R2I_XFM # move brain mask to in_file

macapype/nodes/register.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ class IterREGBETOutputSpec(TraitedSpec):
221221
exists=True,
222222
desc="inv_transfo_file")
223223

224+
nonlin_warp_file = File(
225+
desc="nonlin_warp_file")
226+
227+
nonlin_invwarp_file = File(
228+
desc="nonlin_invwarp_file")
229+
224230

225231
class IterREGBET(CommandLine):
226232
"""
@@ -334,8 +340,16 @@ def _list_outputs(self):
334340
outfile = self._gen_outfilename()
335341

336342
outputs["warp_file"] = os.path.abspath(outfile + ".nii.gz")
343+
337344
outputs["transfo_file"] = os.path.abspath(outfile + ".xfm")
338345
outputs["inv_transfo_file"] = os.path.abspath(outfile + "_inverse.xfm")
346+
347+
if isdefined(self.inputs.refw_file) and self.inputs.k is True:
348+
outputs["nonlin_warp_file"] = \
349+
os.path.abspath(outfile + "_Warp.nii.gz")
350+
outputs["nonlin_invwarp_file"] = \
351+
os.path.abspath(outfile + "_InverseWarp.nii.gz")
352+
339353
return outputs
340354

341355

macapype/nodes/segment.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,16 @@ def merge_imgs(list_img_files):
248248
path, fname, ext = split_f(img_file)
249249
img = nib.load(img_file)
250250
img_data = img.get_fdata()
251-
new_img_data = np.zeros(shape=img_data.shape)
252-
new_img_data[img_data != 0] += img_data[img_data != 0]
251+
new_img_data = np.zeros(shape=img_data.shape, dtype=np.int32)
252+
new_img_data[img_data != 0] = 1
253253

254254
else:
255255
img_data = nib.load(img_file).get_fdata()
256+
256257
assert img_data.shape == new_img_data.shape, \
257258
"Error, shapes {} != {}".format(img_data.shape,
258259
new_img_data.shape)
259-
new_img_data[img_data != 0] += img_data[img_data != 0]
260+
new_img_data[img_data != 0] = 1
260261

261262
# creating indexed_mask
262263
merged_img = nib.Nifti1Image(dataobj=new_img_data,

0 commit comments

Comments
 (0)