Skip to content

Commit

Permalink
niftyreg package detection
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed May 9, 2022
1 parent e33f9f0 commit 201211d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
1 change: 0 additions & 1 deletion niftypet/nimpa/prc/prc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 15 additions & 11 deletions niftypet/nimpa/prc/regseg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import shutil
import sys
from os import fspath
from subprocess import call
from textwrap import dedent

Expand Down Expand Up @@ -276,7 +277,7 @@ def affine_niftyreg(
fname_aff='',
pickname='ref',
fcomment='',
executable='',
executable=None,
omp=1,
rigOnly=False,
affDirect=False,
Expand All @@ -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 != '':
Expand Down Expand Up @@ -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 != '':
Expand Down

0 comments on commit 201211d

Please sign in to comment.