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

Tof #390

Closed
wants to merge 16 commits into from
Closed

Tof #390

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
2d27e5d
added tof to STIR.py PETAcquisitionData.show() has sinogram selection…
ALEXJAZZ008008 Apr 22, 2019
298971e
pass through get num tof bins from stir
ALEXJAZZ008008 Apr 26, 2019
c39955c
Merge branch 'master' of https://github.com/CCPPETMR/SIRF into tof
ALEXJAZZ008008 May 22, 2019
72e42db
force ALEXJAZZ008008 repo and force TOF branch in travis
ALEXJAZZ008008 May 28, 2019
6e3746c
Merge branch 'master' of https://github.com/CCPPETMR/SIRF into tof_pu…
ALEXJAZZ008008 Jul 5, 2019
c318d77
attempted to add maximum and minimum threshold to osmaposl in python
ALEXJAZZ008008 Sep 17, 2019
e0995af
added basic passthrough for min and max threshold in osem
ALEXJAZZ008008 Sep 19, 2019
59765a9
Merge branch 'master' of https://github.com/CCPPETMR/SIRF into tof_pu…
ALEXJAZZ008008 Sep 27, 2019
e6cbe65
Only build HKEM if version of STIR is recent enough
Sep 27, 2019
ac480dd
Merge branch 'OldSTIR_dont_compile_HKEM' of https://github.com/CCPPET…
ALEXJAZZ008008 Sep 27, 2019
3e29e9f
Merge branch 'master' of https://github.com/CCPPETMR/SIRF into tof_pu…
ALEXJAZZ008008 Oct 1, 2019
9c148de
Merge branch 'master' of https://github.com/CCPPETMR/SIRF into tof_pu…
ALEXJAZZ008008 Nov 10, 2019
430eefb
changed required version of stir
ALEXJAZZ008008 Nov 11, 2019
5560bcd
set maj min test back to 4 0 0
ALEXJAZZ008008 Nov 11, 2019
ea2f403
Merge branch 'master' of https://github.com/CCPPETMR/SIRF into tof
ALEXJAZZ008008 Feb 1, 2020
0e0ae08
Merge branch 'master' of https://github.com/CCPPETMR/SIRF into tof
ALEXJAZZ008008 Feb 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ before_install:
# Use Travis' currently checked-out SIRF commit ID to build.
# Also no point re-downloading SIRF - just use local URL.
# N.B.: don't put into build matrix to allow caching.
- BUILD_FLAGS="$BUILD_FLAGS -DPYVER=$PYMVER -DSIRF_URL=$PWD -DSIRF_TAG=$TRAVIS_COMMIT"
# Force ALEXJAZZ008008 repo
# Force TOF branch
- BUILD_FLAGS="$BUILD_FLAGS -DPYVER=$PYMVER -DSIRF_URL=https://github.com/ALEXJAZZ008008/SIRF.git -DSIRF_TAG=tof"
# get SuperBuild
- cd ..
- git clone https://github.com/CCPPETMR/SIRF-SuperBuild --recursive -b master
Expand Down
2 changes: 1 addition & 1 deletion data
Submodule data updated from f3c428 to cd139a
26 changes: 15 additions & 11 deletions src/xSTIR/cSTIR/cstir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,16 +585,20 @@ void* cSTIR_acquisitionDataFromScannerInfo
extern "C"
void* cSTIR_getAcquisitionDataDimensions(const void* ptr_acq, size_t ptr_dim)
{
try {
int* dim = (int*)ptr_dim;
SPTR_FROM_HANDLE(PETAcquisitionData, sptr_ad, ptr_acq);
dim[0] = sptr_ad->get_num_tangential_poss();
dim[1] = sptr_ad->get_num_views();
dim[2] = sptr_ad->get_num_sinograms();
dim[3] = sptr_ad->get_num_TOF_bins();
return (void*)new DataHandle;
}
CATCH;
try
{
int* dim = (int*) ptr_dim;

SPTR_FROM_HANDLE(PETAcquisitionData, sptr_ad, ptr_acq);

dim[0] = sptr_ad->get_num_tangential_poss();
dim[1] = sptr_ad->get_num_views();
dim[2] = sptr_ad->get_num_sinograms();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dim[2] = sptr_ad->get_num_sinograms();
dim[2] = sptr_ad->get_num_non_tof_sinograms();

dim[3] = sptr_ad->get_num_TOF_bins();

return (void*) new DataHandle;
}
CATCH;
}

extern "C"
Expand Down Expand Up @@ -1160,4 +1164,4 @@ extern "C"
void* parameter(const void* ptr, const char* obj, const char* name)
{
return cSTIR_parameter(ptr, obj, name);
}
}
4 changes: 4 additions & 0 deletions src/xSTIR/cSTIR/cstir_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ sirf::cSTIR_setOSMAPOSLParameter
objectFromHandle<OSMAPOSLReconstruction<Image3DF> >(hp);
if (boost::iequals(name, "MAP_model"))
recon.set_MAP_model(charDataFromDataHandle(hv));
if (boost::iequals(name, "set_maximum_relative_change"))
recon.set_maximum_relative_change(dataFromHandle<double>((void*)hv));
if (boost::iequals(name, "set_minimum_relative_change"))
recon.set_minimum_relative_change(dataFromHandle<double>((void*)hv));
Comment on lines +590 to +593
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems a good addition, but shouldn't be a in a TOF PR

else
return parameterNotFound(name, __FILE__, __LINE__);
return new DataHandle;
Expand Down
2 changes: 1 addition & 1 deletion src/xSTIR/cSTIR/include/sirf/STIR/stir_data_containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ namespace sirf {
}
int get_num_TOF_bins()
{
return 1;
return data()->get_num_tof_poss();
}
int get_max_segment_num() const
{
Expand Down
17 changes: 12 additions & 5 deletions src/xSTIR/cSTIR/stir_data_containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,33 @@ using namespace sirf;
std::string PETAcquisitionData::_storage_scheme;
shared_ptr<PETAcquisitionData> PETAcquisitionData::_template;

float
PETAcquisitionData::norm() const
float PETAcquisitionData::norm() const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

{
double t = 0.0;

for (int s = 0; s <= get_max_segment_num(); ++s)
{
SegmentBySinogram<float> seg = get_segment_by_sinogram(s);
SegmentBySinogram<float>::full_iterator seg_iter;
for (seg_iter = seg.begin_all(); seg_iter != seg.end_all();) {

for (seg_iter = seg.begin_all(); seg_iter != seg.end_all();)
{
Comment on lines +44 to +46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert. no code clean-up in a "new feature PR"

double r = *seg_iter++;
t += r*r;
}
if (s != 0) {

if (s != 0)
{
Comment on lines +50 to +52
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

seg = get_segment_by_sinogram(-s);
for (seg_iter = seg.begin_all(); seg_iter != seg.end_all();) {

for (seg_iter = seg.begin_all(); seg_iter != seg.end_all();)
{
Comment on lines +54 to +56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

double r = *seg_iter++;
t += r*r;
}
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

return sqrt((float)t);
}

Expand Down
63 changes: 43 additions & 20 deletions src/xSTIR/pSTIR/STIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,18 +785,26 @@ def rebin(self, num_segments_to_combine, \
max_in_segment_num_to_process)
check_status(ad.handle)
return ad
def show(self, sino = None, title = None):


def show(self, sino = None, tof=0, title = None):
'''Displays interactively selected sinograms.'''
assert self.handle is not None

if not HAVE_PYLAB:
print('pylab not found')

return

data = self.as_array()
nz = data.shape[0]

if type(sino) == type(1):
if sino < 0 or sino >= nz:
return
show_2D_array('sinogram %d' % sino, data[0,sino,:,:])

show_2D_array('sinogram %d' % sino, data[tof,sino,:,:])

return
elif sino is None:
ns = nz
Expand All @@ -806,21 +814,28 @@ def show(self, sino = None, title = None):
ns = len(sino)
except:
raise error('wrong sinograms list')

if title is None:
title = 'Selected sinograms'
if ns >= 16:
tiles = (4, 4)
else:
tiles = None

#if ns >= 16:
#tiles = (4, 4)
#else:
#tiles = None

Comment on lines +820 to +825
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why you did this, but I'd rather not do a surprising change in this PR

f = 0

while f < ns:
t = min(f + 16, ns)
err = show_3D_array(data[0,:,:,:], \
index = sino[f : t], tile_shape = tiles, \
label = 'sinogram', \
xlabel = 'tang.pos', ylabel = 'view', \
suptitle = title, show = (t == ns))

#err = show_3D_array(data[0,:,:,:], \
# index = sino[f : t], tile_shape = tiles, \
# label = 'sinogram', \
# xlabel = 'tang.pos', ylabel = 'view', \
# suptitle = title, show = (t == ns))

Comment on lines +831 to +836
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why commented out?

f = t

def allocate(self, value=0, **kwargs):
'''Alias to get_uniform_copy

Expand All @@ -840,6 +855,7 @@ def allocate(self, value=0, **kwargs):
else:
out = self.get_uniform_copy(value)
return out

## print('Please enter sinogram numbers (e.g.: 0, 3-5)')
## print('(a value outside the range 0 to %d will stop this loop)' % \
## (nz - 1))
Expand All @@ -857,6 +873,7 @@ def allocate(self, value=0, **kwargs):
## ' the loop')
## break


DataContainer.register(AcquisitionData)

class ListmodeToSinograms(object):
Expand Down Expand Up @@ -1987,15 +2004,21 @@ def __init__(self, filename = ''):
def __del__(self):
if self.handle is not None:
pyiutil.deleteDataHandle(self.handle)
## def set_MAP_model(self, model):
## parms.set_char_par\
## (self.handle, self.name, 'MAP_model', model)
## def get_objective_function(self):
## obj_fun = PoissonLogLikelihoodWithLinearModelForMean()
## obj_fun.handle = pystir.cSTIR_parameter\
## (self.handle, self.name, 'objective_function')
## check_status(obj_fun.handle)
## return obj_fun
def set_MAP_model(self, model):
parms.set_char_par\
(self.handle, self.name, 'MAP_model', model)
def set_maximum_relative_change(self, value):
parms.set_float_par\
(self.handle, self.name, 'set_maximum_relative_change', value)
def set_minimum_relative_change(self, value):
parms.set_float_par\
(self.handle, self.name, 'set_minimum_relative_change', value)
def get_objective_function(self):
obj_fun = PoissonLogLikelihoodWithLinearModelForMean()
obj_fun.handle = pystir.cSTIR_parameter\
(self.handle, self.name, 'objective_function')
check_status(obj_fun.handle)
return obj_fun
Comment on lines +2007 to +2021
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this is here, maybe it needs another merge from master?


class KOSMAPOSLReconstructor(IterativeReconstructor):
'''
Expand Down