Skip to content

Commit

Permalink
Merge pull request #61 from KrisThielemans/merge_master_to_TOF_2024_0…
Browse files Browse the repository at this point in the history
…1_02

Merge master to TOF 2024 01 02
  • Loading branch information
KrisThielemans authored Jan 3, 2024
2 parents d5aae0d + c653a1b commit d60ba7b
Show file tree
Hide file tree
Showing 17 changed files with 354 additions and 169 deletions.
25 changes: 16 additions & 9 deletions documentation/STIR-developers-overview.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,21 @@ \section{
# add my include directory to compiler switches (or better: use target_include_directories)
include_directories(include)
# check CMakeLists in next directories
add_subdirectory(buildblock my_buildblock)
# check CMakeLists in next directory
# note: 2nd argument needs to have different name than any of the existing STIR libraries
add_subdirectory(${STIR_LOCAL}/buildblock my_buildblock)
# add registries (if you have any)
list(APPEND STIR_REGISTRIES
${STIR_LOCAL}/buildblock/my_registries.cxx)
# add to list of libraries to include in linking
list(APPEND STIR_LIBRARIES my_buildblock)
# copy variables to PARENT_SCOPE
SET( STIR_REGISTRIES ${STIR_REGISTRIES} PARENT_SCOPE)
SET( STIR_LIBRARIES ${STIR_LIBRARIES} PARENT_SCOPE)
\end{verbatim}
where \textbf{buildblock} is the name of your subdirectory and \textbf{my\_buildblock} is a name for the
sub-directory where CMake will build the files (make sure the latter is different from any
Expand All @@ -1286,12 +1299,6 @@ \section{
# declare dependencies on other STIR libraries, for instance
target_link_libraries($(dir) PUBLIC buildblock)
# add to list of libraries for STIR to include in linking
list(APPEND STIR_LIBRARIES $(dir))
# add source file for registries (if you have one)
list(APPEND STIR_REGISTRIES my_registry)
include(stir_lib_target)
\end{verbatim}

Expand All @@ -1311,7 +1318,7 @@ \section{
#include "myOutputFileFormat.h"
static myOutputFileFormat::RegisterIt dummy1;
\end{verbatim}
If you add that to the \texttt{STIR\_REGISTRIES} variable in your \textbf{CMakeLists.txt}
If you add that to the \texttt{STIR\_REGISTRIES} variable in your \textbf{extra\_stir\_dirs.cmake}
as above, everything should work as expected.

\section{Contributing to STIR}
Expand Down
43 changes: 43 additions & 0 deletions examples/python/listmode_loop_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Demo how to use STIR from Python to access events in a list-mode file

# Copyright 2023 - University College London
# This file is part of STIR.
#
# SPDX-License-Identifier: Apache-2.0
#
# See STIR/LICENSE.txt for details

#%% Initial imports
import stir

#%% read file
filename = '20170809_NEMA_60min_UCL.l.hdr'
# example using the hroot file in recon_test_pack, which needs some env variables to be set
#import os
#os.environ["INPUT_ROOT_FILE"]="test_PET_GATE.root"
#os.environ["EXCLUDE_SCATTERED"] = "1"
#os.environ["EXCLUDE_RANDOM"] = "0"
#filename = "root_header.hroot"

lm=stir.ListModeData.read_from_file(filename)
# could print some exam info
# print(lm.get_exam_info().parameter_info())
proj_data_info = lm.get_proj_data_info()
# could print some geometric info
#print(proj_data_info.parameter_info())

#%% loop over first few events and print some information
# create some variables for re-use in the loop
record = lm.get_empty_record()
b = stir.Bin()
for i in range(50):
lm.get_next_record(record)
if (record.is_time()):
print(f"Time: {record.time().get_time_in_millisecs()}")
if (record.is_event()):
event = record.event()
lor = event.get_LOR()
event.get_bin(b, proj_data_info);
# TODO We can will be able to simply print bin once STIR_TOF is on
print(f"Event: p/d: {event.is_prompt()} LOR: {[lor.p1(), lor.p2()]}, ",
f"bin: s:{b.segment_num}, a: {b.axial_pos_num}, v: {b.view_num}, t:{b.tangential_pos_num}")
149 changes: 75 additions & 74 deletions src/IO/InterfileHeader.cxx

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/buildblock/RadionuclideDB.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ get_radionuclide_from_json(ImagingModality rmodality, const std::string &rname)
case ImagingModality::NM:
modality_string = "nucmed"; break;
default:
warning("RadionuclideDB::get_radionuclide_from_json called with unknown modality. Returning \"unknown\" radionuclide.");
warning(std::string("RadionuclideDB::get_radionuclide_from_json called with unknown modality. Returning \"unknown\" radionuclide."));
return Radionuclide();
}

Expand All @@ -151,7 +151,7 @@ get_radionuclide_from_json(ImagingModality rmodality, const std::string &rname)

if (rnuclide_entry == all_nuclides.end())
{
warning("RadionuclideDB: radionuclide " + rname + " not found in JSON database. Returning \"unknown\" radionuclide.");
warning(std::string("RadionuclideDB: radionuclide " + rname + " not found in JSON database. Returning \"unknown\" radionuclide."));
return Radionuclide();
}

Expand Down Expand Up @@ -180,7 +180,7 @@ get_radionuclide_from_json(ImagingModality rmodality, const std::string &rname)

if (decay_entry == decays.end())
{
warning("RadionuclideDB: radionuclide " + rname + ": modality " + modality_string + " not found in JSON database. Returning \"unknown\" radionuclide.");
warning(std::string("RadionuclideDB: radionuclide " + rname + ": modality " + modality_string + " not found in JSON database. Returning \"unknown\" radionuclide."));
return Radionuclide();
}

Expand Down Expand Up @@ -240,7 +240,7 @@ get_radionuclide(ImagingModality rmodality, const std::string& rname)
return get_radionuclide(rmodality, "^99m^Technetium");
else
{
warning("RadioNuclideDB::get_radionuclide: unknown modality. Returning \"unknown\" radionuclide.");
warning(std::string("RadioNuclideDB::get_radionuclide: unknown modality. Returning \"unknown\" radionuclide."));
return Radionuclide();
}
}
Expand All @@ -256,7 +256,7 @@ get_radionuclide(ImagingModality rmodality, const std::string& rname)
if(rmodality.get_modality()==ImagingModality::PT){
if (rname != "^18^Fluorine")
{
warning("RadioNuclideDB::get_radionuclide: since STIR was compiled without nlohmann-json-dev, We only have information for ^18^Fluorine for the PET modality. Returning \"unknown\" radionuclide.");
warning(std::string("RadioNuclideDB::get_radionuclide: since STIR was compiled without nlohmann-json-dev, We only have information for ^18^Fluorine for the PET modality. Returning \"unknown\" radionuclide."));
return Radionuclide();
}

Expand All @@ -268,7 +268,7 @@ get_radionuclide(ImagingModality rmodality, const std::string& rname)
}else if(rmodality.get_modality()==ImagingModality::NM){
if (rname != "^99m^Technetium")
{
warning("RadioNuclideDB::get_radionuclide: since STIR was compiled without nlohmann-json-dev, We only have information for ^99m^Technetium for the NM modality. Returning \"unknown\" radionuclide.");
warning(std::string("RadioNuclideDB::get_radionuclide: since STIR was compiled without nlohmann-json-dev, We only have information for ^99m^Technetium for the NM modality. Returning \"unknown\" radionuclide."));
return Radionuclide();
}

Expand All @@ -280,7 +280,7 @@ get_radionuclide(ImagingModality rmodality, const std::string& rname)
}
else
{
warning("RadioNuclideDB::get_radionuclide: unknown modality. Returning \"unknown\" radionuclide.");
warning(std::string("RadioNuclideDB::get_radionuclide: unknown modality. Returning \"unknown\" radionuclide."));
return Radionuclide();
}

Expand Down
59 changes: 28 additions & 31 deletions src/include/stir/LORCoordinates.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ class LORCylindricalCoordinates_z_and_radius
template <class coordT>
class LORInCylinderCoordinates : public LOR<coordT>
{
#ifdef SWIG
// SWIG needs this typedef to be public
public:
#endif
typedef LORInCylinderCoordinates<coordT> self_type;
private:
void check_state() const
{
assert(_radius>0);
Expand Down Expand Up @@ -233,16 +238,14 @@ class LORInCylinderCoordinates : public LOR<coordT>
inline
LORInCylinderCoordinates(const LORInAxialAndSinogramCoordinates<coordT>&);

#if 0
// disabled as would need radius argument as well, but currently not needed
inline
LORInCylinderCoordinates(const LORAs2Points<coordT>&);
#endif

virtual
#ifndef STIR_NO_COVARIANT_RETURN_TYPES
self_type*
#else
LOR<coordT>*
#endif
clone() const { return new self_type(*this); }
self_type* clone() const override
{ return new self_type(*this); }

virtual
Succeeded
Expand Down Expand Up @@ -275,6 +278,10 @@ class LORInCylinderCoordinates : public LOR<coordT>
template <class coordT>
class LORAs2Points : public LOR<coordT>
{
#ifdef SWIG
// SWIG needs this typedef to be public
public:
#endif
typedef LORAs2Points<coordT> self_type;
public:
const CartesianCoordinate3D<coordT>& p1() const { return _p1; }
Expand All @@ -297,14 +304,6 @@ class LORAs2Points : public LOR<coordT>

inline
LORAs2Points(const LORInAxialAndNoArcCorrSinogramCoordinates<coordT>&);

virtual
#ifndef STIR_NO_COVARIANT_RETURN_TYPES
self_type*
#else
LOR<coordT>*
#endif
clone() const { return new self_type(*this); }

//! \copybrief LOR::is_swapped()
/*! In this class, this currently always return \c false. You can swap the points if
Expand All @@ -315,6 +314,9 @@ class LORAs2Points : public LOR<coordT>
return false;
}

self_type* clone() const override
{ return new self_type(*this); }

virtual
Succeeded
change_representation(LORInCylinderCoordinates<coordT>&,
Expand Down Expand Up @@ -351,7 +353,12 @@ class LORInAxialAndSinogramCoordinates
: public LOR<coordT>, private LORCylindricalCoordinates_z_and_radius<coordT>
{
private:
#ifdef SWIG
// SWIG needs this typedef to be public
public:
#endif
typedef LORInAxialAndSinogramCoordinates<coordT> self_type;
private:
typedef LORCylindricalCoordinates_z_and_radius<coordT> private_base_type;
// sorry: has to be first to give the compiler a better chance of inlining
void check_state() const
Expand Down Expand Up @@ -398,18 +405,13 @@ class LORInAxialAndSinogramCoordinates
inline
LORInAxialAndSinogramCoordinates(const LORInAxialAndNoArcCorrSinogramCoordinates<coordT>&);

#if __cplusplus>= 201103L
#if 0
inline
LORInAxialAndSinogramCoordinates(const LORAs2Points<coordT>&);
#endif

virtual
#ifndef STIR_NO_COVARIANT_RETURN_TYPES
self_type*
#else
LOR<coordT>*
#endif
clone() const { return new self_type(*this); }
self_type* clone() const override
{ return new self_type(*this); }

void reset(coordT radius=1)
{
Expand Down Expand Up @@ -537,18 +539,13 @@ class LORInAxialAndNoArcCorrSinogramCoordinates
inline
LORInAxialAndNoArcCorrSinogramCoordinates(const LORInAxialAndSinogramCoordinates<coordT>&);

#if __cplusplus>= 201103L
#if 0
inline
LORInAxialAndNoArcCorrSinogramCoordinates(const LORAs2Points<coordT>&);
#endif

virtual
#ifndef STIR_NO_COVARIANT_RETURN_TYPES
self_type*
#else
LOR<coordT>*
#endif
clone() const { return new self_type(*this); }
self_type* clone() const override
{ return new self_type(*this); }

virtual
Succeeded
Expand Down
2 changes: 1 addition & 1 deletion src/include/stir/LORCoordinates.inl
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ LORInAxialAndNoArcCorrSinogramCoordinates(const LORInAxialAndSinogramCoordinates
check_state();
}

#if __cplusplus>= 201103L
#if 0
template <class coordT>
LORInAxialAndSinogramCoordinates<coordT>::
LORInAxialAndSinogramCoordinates(const LORAs2Points<coordT>& coords)
Expand Down
2 changes: 1 addition & 1 deletion src/include/stir/listmode/CListRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef __stir_listmode_CListRecord_H__
#define __stir_listmode_CListRecord_H__

#include "ListRecord.h"
#include "stir/listmode/ListRecord.h"

START_NAMESPACE_STIR
class Bin;
Expand Down
2 changes: 0 additions & 2 deletions src/include/stir/listmode/ListEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#ifndef __stir_listmode_ListEvent_H__
#define __stir_listmode_ListEvent_H__

#include "stir/round.h"
#include "stir/Succeeded.h"
#include "stir/Bin.h"
#include "stir/ProjDataInfo.h"
#include "stir/CartesianCoordinate3D.h"
Expand Down
5 changes: 2 additions & 3 deletions src/include/stir/listmode/ListRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
#ifndef __stir_listmode_ListRecord_H__
#define __stir_listmode_ListRecord_H__

#include "ListEvent.h"
#include "ListTime.h"
#include "stir/Succeeded.h"
#include "stir/listmode/ListEvent.h"
#include "stir/listmode/ListTime.h"

START_NAMESPACE_STIR

Expand Down
2 changes: 1 addition & 1 deletion src/include/stir/recon_buildblock/SqrtHessianRowSum.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ class SqrtHessianRowSum:
void compute_approximate_Hessian_row_sum();

protected:
bool _already_setup = false;

private:
bool _already_setup = false;

//! Objective function object
shared_ptr<GeneralisedObjectiveFunction<TargetT> > objective_function_sptr;
Expand Down
3 changes: 2 additions & 1 deletion src/include/stir/scatter/ScatterEstimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,11 @@ class ScatterEstimation: public ParsingObject

std::string output_additive_estimate_prefix;

private:
//! variable to check if we have called set_up()
bool _already_setup;

private:

//! attenuation in 3D
shared_ptr<BinNormalisation> atten_norm_3d_sptr;

Expand Down
2 changes: 1 addition & 1 deletion src/include/stir/scatter/ScatterSimulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ class ScatterSimulation : public RegisteredObject<ScatterSimulation>
int downsample_scanner_dets;

bool downsample_scanner_bool;
bool _already_set_up;

private:
int total_detectors;
Expand All @@ -446,7 +447,6 @@ class ScatterSimulation : public RegisteredObject<ScatterSimulation>
// numbers that we don't want to recompute all the time
mutable float detector_efficiency_no_scatter;

bool _already_set_up;

//! a function that checks if image sizes are ok
/*! It will call \c error() if not.
Expand Down
1 change: 1 addition & 0 deletions src/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ set(swig_stir_dependencies
stir_objectivefunctions.i
stir_priors.i
stir_projdata.i
stir_listmode.i
stir_projectors.i
stir_reconstruction.i
stir_shapes.i
Expand Down
Loading

0 comments on commit d60ba7b

Please sign in to comment.