Skip to content

Commit

Permalink
add --list-bin option to list_lm_events
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisThielemans committed Jan 12, 2024
1 parent e72c7ce commit d8a8826
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
5 changes: 5 additions & 0 deletions documentation/release_6.0.htm
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ <h4>General</h4>
If the radionuclide name is recognised to the STIR database, its values for half-life etc
are used, as opposed to what was recorded in the file (if anything).
</li>
<li>
<tt>list_lm_events</tt> now has an additional option <tt>--event-bin</tt> which lists the bin
assigned for the event (according to the "native" projection data, i.e. without any mashing).<br>
In addition, the <tt>--event-LOR<tt> option now also works for SPECT (it was disabled by accident).
</li>
</ul>

<h4>Python (and MATLAB)</h4>
Expand Down
30 changes: 24 additions & 6 deletions src/listmode_utilities/list_lm_events.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "stir/listmode/CListEventCylindricalScannerWithDiscreteDetectors.h"
#include "stir/Succeeded.h"
#include "stir/IO/read_from_file.h"

#include "stir/stream.h"
#include "stir/Scanner.h"
#include <iostream>
#include <vector>
Expand All @@ -55,6 +55,7 @@ int main(int argc, char *argv[])
bool list_time=true;
bool list_coincidence=false;
bool list_event_LOR=false;
bool list_event_bin=false;
bool list_gating=true;
bool list_unknown=false;
unsigned long num_events_to_list = 0;
Expand All @@ -80,6 +81,10 @@ int main(int argc, char *argv[])
{
list_event_LOR = atoi(argv[1])!=0;
}
else if (strcmp(argv[0], "--event-bin")==0)
{
list_event_bin = atoi(argv[1])!=0;
}
else if (strcmp(argv[0], "--unknown")==0)
{
list_unknown = atoi(argv[1])!=0;
Expand All @@ -99,18 +104,23 @@ int main(int argc, char *argv[])
<< "--time 0|1 : list time events or not (default: 1)\n"
<< "--gating 0|1 : list gating events or not (default: 1)\n"
<< "--coincidence 0|1 0|1): list coincidence event info or not (default: 0)\n"
<< "--event-LOR 0|1 : ((identical to --SPECT-event) list LOR end-points if coincidence/gamma event or not (default: 0)\n"
<< "--event-LOR 0|1 : (identical to --SPECT-event) list LOR end-points if coincidence/gamma event, or not (default: 0)\n"
<< "--event-bin 0|1 : bin coordinates if coincidence/gamma event, or not (default: 0)\n"
<< "--unknown 0|1 : list if event of unknown type encountered or not (default: 0)\n"
<< "--num-events-to-list <num> : limit number of events written to stdout\n"
<< "\n--event-bin uses the \"native\" projection data info associated to the\n"
<< " list-mode file, i.e. without any mashing in views/TOF etc).\n"
<< "\nNote that for some PET scanners, coincidences are listed with crystal info.\n"
<< "For others, you should list LOR coordinates (as well) as the 'coincidence' option will only list prompt/delayed info.\n";
<< " For others, you should list LOR coordinates or bins (as well) as the 'coincidence' option\n"
<< " will only list prompt/delayed info.\n";
return EXIT_FAILURE;
}

if ( list_event_LOR)
cout << "LORs will be listed as 2 points (z1,y1,x1)-(z2,y2,x2).\n";

shared_ptr<ListModeData> lm_data_ptr(read_from_file<ListModeData>(argv[0]));
auto proj_data_info_sptr = lm_data_ptr->get_proj_data_info_sptr();

cout << "Scanner: " << lm_data_ptr->get_scanner().get_name() << endl;

Expand Down Expand Up @@ -181,9 +191,7 @@ int main(int argc, char *argv[])
}
if (list_event_LOR)
{
if (auto event_ptr =
dynamic_cast<CListEvent *>(&record.event())) // cast not necessary, but looks same as above
if (event_ptr!=0)
if (auto event_ptr = &record.event())
{
LORAs2Points<float> lor;
lor=event_ptr->get_LOR();
Expand All @@ -200,6 +208,16 @@ int main(int argc, char *argv[])
}
}
}
if (list_event_bin)
{
if (auto event_ptr = &record.event())
{
Bin bin;
event_ptr->get_bin(bin, *proj_data_info_sptr);
cout << " bin " << bin;
listed = true;
}
}
if (!recognised && list_unknown)
{
cout << "Unknown type";
Expand Down

0 comments on commit d8a8826

Please sign in to comment.