if len(iwarpfns) == 0:
iwarpfns = ""
alltx = glob.glob(outprefix+"*"+"[0-9]*")
findinv = np.where([re.search("[0-9]InverseWarp.nii.gz",ff) for ff in alltx])[0]
findfwd = np.where([re.search("[0-9]Warp.nii.gz", ff) for ff in alltx])[0]
if len(findinv) > 0:
fwdtransforms = list(reversed([ff for idx,ff in enumerate(alltx) if idx !=findinv[0]]))
invtransforms = [ff for idx,ff in enumerate(alltx) if idx!=findfwd[0]]
else:
fwdtransforms = list(reversed(alltx))
After Change
if len(iwarpfns) == 0:
iwarpfns = ""
alltx = sorted(glob.glob(outprefix+"*"+"[0-9]*"))
findinv = np.where([re.search("[0-9]InverseWarp.nii.gz",ff) for ff in alltx])[0]
findfwd = np.where([re.search("[0-9]Warp.nii.gz", ff) for ff in alltx])[0]
if len(findinv) > 0:
fwdtransforms = list(reversed([ff for idx,ff in enumerate(alltx) if idx !=findinv[0]]))
invtransforms = [ff for idx,ff in enumerate(alltx) if idx!=findfwd[0]]
else:
fwdtransforms = list(reversed(alltx))