diff --git a/src/xSTIR/cSTIR/cstir.cpp b/src/xSTIR/cSTIR/cstir.cpp index 5c8259307..9e102c7b6 100644 --- a/src/xSTIR/cSTIR/cstir.cpp +++ b/src/xSTIR/cSTIR/cstir.cpp @@ -910,25 +910,9 @@ void* cSTIR_imageFromAcquisitionDataAndNxNy(void* ptr_ad, int nx, int ny) { try { SPTR_FROM_HANDLE(PETAcquisitionData, sptr_ad, ptr_ad); - STIRImageData 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 STIRImageData(*sptr_v)); - sptr->fill(0.0); - return newObjectHandle(sptr); + shared_ptr sptr_im( + new STIRImageData(*sptr_ad, nx, ny)); + return newObjectHandle(sptr_im); } CATCH; } @@ -1044,4 +1028,4 @@ void* cSTIR_setImageData(const void* ptr_im, size_t ptr_data) return new DataHandle; } CATCH; -} \ No newline at end of file +} 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 53296f604..ac2cd7173 100644 --- a/src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h +++ b/src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h @@ -593,6 +593,24 @@ namespace sirf { _data.reset(new Voxels3DF(*ad.get_proj_data_info_sptr())); this->set_up_geom_info(); } + 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); + _data.reset( + new Voxels3DF( + *ad.get_proj_data_info_sptr(), + zoom, origin, sizes)); + this->set_up_geom_info(); + } STIRImageData(const Image3DF& image) { _data.reset(image.clone());