diff --git a/niftypet/nimpa/prc/prc.py b/niftypet/nimpa/prc/prc.py index c96c7c26..fd6d586d 100644 --- a/niftypet/nimpa/prc/prc.py +++ b/niftypet/nimpa/prc/prc.py @@ -727,7 +727,6 @@ def pvc_iyang( ft1w, outpath=os.path.join(outpath, 'PET', 'positioning'), fcomment=fcomment, - executable=Cnt['REGPATH'], omp=multiprocessing.cpu_count() / 2, rigOnly=True, affDirect=False, diff --git a/niftypet/nimpa/prc/regseg.py b/niftypet/nimpa/prc/regseg.py index d1dcb51b..d7b2f850 100644 --- a/niftypet/nimpa/prc/regseg.py +++ b/niftypet/nimpa/prc/regseg.py @@ -7,6 +7,7 @@ import os import shutil import sys +from os import fspath from subprocess import call from textwrap import dedent @@ -276,7 +277,7 @@ def affine_niftyreg( fname_aff='', pickname='ref', fcomment='', - executable='', + executable=None, omp=1, rigOnly=False, affDirect=False, @@ -294,10 +295,13 @@ def affine_niftyreg( fthrsh=0.05, verbose=True, ): - - # check if the executable exists: + if not executable: + executable = getattr(rs, 'REGPATH', None) + if not executable: + import niftyreg + executable = fspath(next(niftyreg.bin_path.glob("reg_aladin*"))) if not os.path.isfile(executable): - raise IOError('Incorrect path to executable file for registration.') + raise IOError(f"executable not found:{executable}") # create a folder for images registered to ref if outpath != '': @@ -377,16 +381,16 @@ def resample_niftyreg( fcomment='', pickname='ref', intrp=1, - executable='', + executable=None, verbose=True, ): - - # check if the executable exists: - # if executable=='' and 'RESPATH' in Cnt and os.path.isfile(Cnt['RESPATH']): - # executable = Cnt['RESPATH'] - + if not executable: + executable = getattr(rs, 'RESPATH', None) + if not executable: + import niftyreg + executable = fspath(next(niftyreg.bin_path.glob("reg_resample*"))) if not os.path.isfile(executable): - raise IOError('Incorrect path to executable file for registration.') + raise IOError(f"executable not found:{executable}") # > output path if outpath == '' and fimout != '':