Skip to content

Commit

Permalink
fixed simplistic_petmr.py example
Browse files Browse the repository at this point in the history
- replace constructor from sirf.Gadgetron.ImageData with "manual" construction
- fix sirf.STIR.ImageData doc for constructor

Fixes #974
  • Loading branch information
KrisThielemans committed Jun 24, 2021
1 parent 96b8f92 commit 8cd0068
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 14 additions & 4 deletions examples/Python/PETMR/simplistic_petmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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>, --file=<file> raw data file
[default: simulated_MR_2D_cartesian.h5]
Expand All @@ -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)
Expand All @@ -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__)

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/xSTIR/pSTIR/STIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <arg>
(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 <arg>.
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.
"""
Expand Down

0 comments on commit 8cd0068

Please sign in to comment.