-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1288 from KrisThielemans/SWIGlistmode
SWIG: expose more LOR and listmode classes
- Loading branch information
Showing
11 changed files
with
251 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Copyright (C) 2023 University College London | ||
Copyright (C) 2022 National Physical Laboratory | ||
This file is part of STIR. | ||
SPDX-License-Identifier: Apache-2.0 | ||
See STIR/LICENSE.txt for details | ||
*/ | ||
/*! | ||
\file | ||
\brief Interface file for SWIG: stir::LOR and derived classes | ||
\author Kris Thielemans | ||
\author Daniel Deidda | ||
*/ | ||
|
||
%shared_ptr(stir::LOR<float>); | ||
%shared_ptr(stir::LORAs2Points<float>); | ||
%shared_ptr(stir::LORInAxialAndNoArcCorrSinogramCoordinates<float>); | ||
%shared_ptr(stir::LORInAxialAndSinogramCoordinates<float>); | ||
%shared_ptr(stir::PointOnCylinder<float>); | ||
%shared_ptr(stir::LORInCylinderCoordinates<float>); | ||
|
||
#if 0 | ||
// TODO enable this in STIR version 6 (breaks backwards compatibility | ||
%attributeref(stir::LORInAxialAndNoArcCorrSinogramCoordinates<float>, float, z1); | ||
%attributeref(stir::LORInAxialAndNoArcCorrSinogramCoordinates<float>, float, z2); | ||
%attributeref(stir::LORInAxialAndNoArcCorrSinogramCoordinates<float>, float, beta); | ||
%attributeref(stir::LORInAxialAndNoArcCorrSinogramCoordinates<float>, float, phi); | ||
#else | ||
%ignore *::z1() const; | ||
%ignore *::z2() const; | ||
%ignore *::beta() const; | ||
%ignore *::phi() const; | ||
#endif | ||
%ignore *::check_state; | ||
|
||
%attributeref(stir::PointOnCylinder<float>, float, z); | ||
%attributeref(stir::PointOnCylinder<float>, float, psi); | ||
|
||
%include "stir/LORCoordinates.h" | ||
|
||
%template(LOR) stir::LOR<float>; | ||
%template(LORInAxialAndNoArcCorrSinogramCoordinates) stir::LORInAxialAndNoArcCorrSinogramCoordinates<float>; | ||
%template(LORAs2Points) stir::LORAs2Points<float>; | ||
%template(LORInAxialAndSinogramCoordinates) stir::LORInAxialAndSinogramCoordinates<float>; | ||
%template(PointOnCylinder) stir::PointOnCylinder<float>; | ||
%template(LORInCylinderCoordinates) stir::LORInCylinderCoordinates<float>; |
Oops, something went wrong.