Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Constructing STIR Image from Acq Data with nx, ny should use Acq data #231

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions src/xSTIR/cSTIR/cstir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Voxels3DF> 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<STIRImageData> sptr(new STIRImageData(*sptr_v));
sptr->fill(0.0);
return newObjectHandle(sptr);
shared_ptr<STIRImageData> sptr_im(
new STIRImageData(*sptr_ad, nx, ny));
return newObjectHandle(sptr_im);
}
CATCH;
}
Expand Down Expand Up @@ -1044,4 +1028,4 @@ void* cSTIR_setImageData(const void* ptr_im, size_t ptr_data)
return new DataHandle;
}
CATCH;
}
}
18 changes: 18 additions & 0 deletions src/xSTIR/cSTIR/include/sirf/cSTIR/stir_data_containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down