From 8cd006849be73376e58ef4b526b398413bd2a166 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Thu, 24 Jun 2021 14:46:28 +0100 Subject: [PATCH] fixed simplistic_petmr.py example - replace constructor from sirf.Gadgetron.ImageData with "manual" construction - fix sirf.STIR.ImageData doc for constructor Fixes #974 --- examples/Python/PETMR/simplistic_petmr.py | 18 ++++++++++++++---- src/xSTIR/pSTIR/STIR.py | 3 ++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/examples/Python/PETMR/simplistic_petmr.py b/examples/Python/PETMR/simplistic_petmr.py index acc20732e..19bfe3874 100644 --- a/examples/Python/PETMR/simplistic_petmr.py +++ b/examples/Python/PETMR/simplistic_petmr.py @@ -3,6 +3,8 @@ Usage: simplistic_petmr [--help | options] +This demo currently only shows how to convert an MR image to a PET object. + Options: -f , --file= raw data file [default: simulated_MR_2D_cartesian.h5] @@ -14,7 +16,7 @@ ## SyneRBI Synergistic Image Reconstruction Framework (SIRF) ## Copyright 2015 - 2019 Rutherford Appleton Laboratory STFC -## Copyright 2015 - 2017 University College London. +## Copyright 2015 - 2017, 2021 University College London. ## ## This is software developed for the Collaborative Computational ## Project in Synergistic Reconstruction for Biomedical Imaging (formerly CCP PETMR) @@ -31,10 +33,11 @@ ## limitations under the License. # import common (engine-independent) utilities -import pUtilities as pUtil +import sirf.Utilities as pUtil +import numpy # get command-line arguments -__version__ = '0.1.0' +__version__ = '0.2.0' from docopt import docopt args = docopt(__doc__, version=__version__) @@ -66,7 +69,14 @@ def main(): # PET # convert MR image into PET image - image = PET.ImageData(complex_image) + # At present, we cannot do the following yet + #image = PET.ImageData(complex_image) + # So, instead we do it "by hand". + # Note however that the lines below ignore any orientation (TODO) + image = PET.ImageData() + image.initialise(complex_image.dimensions(), complex_image.get_geometrical_info().get_spacing()) + image.fill(numpy.abs(complex_image.as_array())) + # should give the same values as the MR ones print(image.norm()) print(image.dot(image)) # apply filter that zeroes the image outside a cylinder of the same diff --git a/src/xSTIR/pSTIR/STIR.py b/src/xSTIR/pSTIR/STIR.py index 86276c9ca..ef0fe1b02 100644 --- a/src/xSTIR/pSTIR/STIR.py +++ b/src/xSTIR/pSTIR/STIR.py @@ -286,9 +286,10 @@ def __init__(self, arg=None): arg : Python str or AcquisitionData or None, interpreted as follows: str : read the object from a file specified by (the file format has to be support by STIR). - AcquisitionData: create an object compatible with the scanner data + STIR.AcquisitionData: create an object compatible with the scanner data recorded in an AcquisitionData object . This sets default voxel sizes. + SIRF.ImageData : (attempt to) convert data from another SIRF ImageData container. None : create an empty ImageData object. Call initialise() method before using it. """