From 4bec943e2a178545cd3efca5fca5f13277ac74f5 Mon Sep 17 00:00:00 2001 From: Ashley Gillman Date: Mon, 5 Nov 2018 19:17:53 +1000 Subject: [PATCH 1/4] [FIX] Constructing STIR Image from Acq Data with nx, ny should use Acq data --- src/xSTIR/cSTIR/cstir.cpp | 20 ++------------------ src/xSTIR/cSTIR/stir_data_containers.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/xSTIR/cSTIR/cstir.cpp b/src/xSTIR/cSTIR/cstir.cpp index 4f8f98402..1d8f95638 100644 --- a/src/xSTIR/cSTIR/cstir.cpp +++ b/src/xSTIR/cSTIR/cstir.cpp @@ -907,24 +907,8 @@ void* cSTIR_imageFromAcquisitionDataAndNxNy(void* ptr_ad, int nx, int ny) try { shared_ptr& sptr_ad = objectSptrFromHandle(ptr_ad); - PETImageData id(*sptr_ad); - int dim[3]; - float vs[3]; - float is[3]; - id.get_dimensions(dim); - id.get_voxel_sizes(vs); - for (int i = 0; i < 3; i++) - is[i] = dim[i] * vs[i]; - int nz = dim[0]; - float vx = is[2] / nx; - float vy = is[1] / ny; - float vz = vs[0]; - shared_ptr sptr_v(new Voxels3DF(IndexRange3D(0, nz - 1, - -(ny / 2), -(ny / 2) + ny - 1, -(nx / 2), -(nx / 2) + nx - 1), - Coord3DF(0, 0, 0), - Coord3DF(vz, vy, vx))); - shared_ptr sptr(new PETImageData(*sptr_v)); - sptr->fill(0.0); + shared_ptr sptr( + new PETImageData(*sptr_ad, nx, ny)); return newObjectHandle(sptr); } CATCH; diff --git a/src/xSTIR/cSTIR/stir_data_containers.h b/src/xSTIR/cSTIR/stir_data_containers.h index 27c78f46e..177efb291 100644 --- a/src/xSTIR/cSTIR/stir_data_containers.h +++ b/src/xSTIR/cSTIR/stir_data_containers.h @@ -476,6 +476,16 @@ namespace sirf { { _data.reset(new Voxels3DF(*ad.get_proj_data_info_sptr())); } + PETImageData + (const PETAcquisitionData& ad, const int nx, const int ny, const float zoom=1.) + { + const Coord3DF origin(0, 0, 0); + const Coord3DI sizes(-1, ny, nx); + _data.reset( + new Voxels3DF( + *ad.get_proj_data_info_sptr(), + zoom, origin, sizes)); + } PETImageData(const Image3DF& image) { _data.reset(image.clone()); From a66f1705c056d91136d3ea35c7e13ebc1f3c1638 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Mon, 26 Nov 2018 13:37:35 +1000 Subject: [PATCH 2/4] Use 1.F in src/xSTIR/cSTIR/stir_data_containers.h Co-Authored-By: ashgillman --- src/xSTIR/cSTIR/stir_data_containers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xSTIR/cSTIR/stir_data_containers.h b/src/xSTIR/cSTIR/stir_data_containers.h index 177efb291..9bd1158e8 100644 --- a/src/xSTIR/cSTIR/stir_data_containers.h +++ b/src/xSTIR/cSTIR/stir_data_containers.h @@ -477,7 +477,7 @@ namespace sirf { _data.reset(new Voxels3DF(*ad.get_proj_data_info_sptr())); } PETImageData - (const PETAcquisitionData& ad, const int nx, const int ny, const float zoom=1.) + (const PETAcquisitionData& ad, const int nx, const int ny, const float zoom=1.F) { const Coord3DF origin(0, 0, 0); const Coord3DI sizes(-1, ny, nx); From 2ebdc9b8db58e2b7f8a3c47e7c2327a74e3b13f7 Mon Sep 17 00:00:00 2001 From: Ashley Gillman Date: Mon, 14 Jan 2019 11:55:46 +1000 Subject: [PATCH 3/4] [FIX] Forgot to set_up_geom_info --- src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h b/src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h index f0f5407fa..fb5ebac15 100644 --- a/src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h +++ b/src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h @@ -602,6 +602,7 @@ namespace sirf { new Voxels3DF( *ad.get_proj_data_info_sptr(), zoom, origin, sizes)); + this->set_up_geom_info(); } STIRImageData(const Image3DF& image) { From b9cc652b69cdd9bea101adaa312b2107ceefffc9 Mon Sep 17 00:00:00 2001 From: Ashley Gillman Date: Mon, 14 Jan 2019 12:32:04 +1000 Subject: [PATCH 4/4] [DOC] Doxygen for new method. --- src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h b/src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h index fb5ebac15..ac2cd7173 100644 --- a/src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h +++ b/src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h @@ -595,6 +595,13 @@ namespace sirf { } STIRImageData (const PETAcquisitionData& ad, const int nx, const int ny, const float zoom=1.F) + //! construct image with appropriate sizes for the given PETAcquisitionData + /*! + The number of z-planes is automatically determined in the STIR + implementation (see STIR documentation for VoxelsOnCartesianGrid), + but x and y size can be chosen. Voxel sizing is default_bin_size/zoom + (again, see STIR documentation for default_bin_size). + */ { const Coord3DF origin(0, 0, 0); const Coord3DI sizes(-1, ny, nx);