From 0af98c8ad71ba584cdc3e57ed3d51d9f9cf7f056 Mon Sep 17 00:00:00 2001 From: Constantin Pape <constantin.pape@iwr.uni-heidelberg.de> Date: Fri, 20 Sep 2019 15:29:50 +0200 Subject: [PATCH] Debugging apply_registration WIP --- .../registration/apply_registration.py | 17 ++++++++++++++--- test/registration/check_wrapper.py | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scripts/extension/registration/apply_registration.py b/scripts/extension/registration/apply_registration.py index 01631ae..41f6ab6 100644 --- a/scripts/extension/registration/apply_registration.py +++ b/scripts/extension/registration/apply_registration.py @@ -123,15 +123,26 @@ def apply_for_file(input_path, output_path, # "elastixDirectory='/g/almf/software/elastix_v4.8', workingDirectory='$TMPDIR', # inputImageFile='$INPUT_IMAGE',transformationFile='/g/cba/exchange/platy-trafos/linear/TransformParameters.BSpline10-3Channels.0.txt # outputFile='$OUTPUT_IMAGE',outputModality='Save as BigDataViewer .xml/.h5',numThreads='1'" - # NOTE: I ommit --run here, because fiji throws a warning that it does not recognise the argument - cmd = [fiji_executable, "--ij2", "--headless", "\"Transformix\"", transformix_argument] + cmd = [fiji_executable, "--ij2", "--headless", "--run", "\"Transformix\"", transformix_argument] cmd_str = " ".join(cmd) fu.log("Calling the following command:") fu.log(cmd_str) + # the elastix wrapper only works properly if we set these as environment variables as well, see + # TODO make issue about this + # os.environ['TMPDIR'] = tmp_folder + os.environ['TRAFO'] = transformation_file + try: - check_output(cmd) + # check_output(cmd) + # the CLI parser is very awkward (to put it nicely). + # I could only get it to work by passing the whole command string + # and setting shell to True. + # otherwise, it would parse something wrong, and do nothing but + # throwing a warning: + # [WARNING] Ignoring invalid argument: --run + check_output([cmd_str], shell=True) except CalledProcessError as e: raise RuntimeError(e.output) diff --git a/test/registration/check_wrapper.py b/test/registration/check_wrapper.py index 12fa5bc..6313f72 100644 --- a/test/registration/check_wrapper.py +++ b/test/registration/check_wrapper.py @@ -9,7 +9,8 @@ from scripts.extension.registration import ApplyRegistrationLocal def check_wrapper(): - in_path = '/g/kreshuk/pape/Work/my_projects/platy-browser-data/registration/9.9.9/images/ProSPr/Stomach_forRegistration.tif' + in_path = os.path.join('/g/kreshuk/pape/Work/my_projects/platy-browser-data/registration/9.9.9/images/ProSPr', + 'Stomach_forRegistration.tif') out_path = '/g/kreshuk/pape/Work/my_projects/dev-platy/test/registration/somach_prospr_registered' in_list = [in_path] -- GitLab