STIR
STIR copied to clipboard
Feature suggestions for ProjData Visualization
Relevant directory: https://github.com/UCL/STIR/tree/master/examples/python/projdata_visualisation
#1319 Added a TOF slider. The following are suggestions of changes to be made to ProjData Visualization
Further TOF improvements:
- [ ] Add a checkbox to sum over TOF indices, as suggested here
- [ ] Allow multiple ProjData matplotlib canvas widgets that can be controlled by a set of single sliders (assumption of this suggestion)
- [ ] Add a TOF data demonstration
General
- [x] Improve the "hideous" UI (I wrote it 😄). Example
mainLayout.addWidget(self.ProjDataVisualisationGroupBox, 1, 1)
->mainLayout.addWidget(self.ProjDataVisualisationGroupBox, 1, 0, 1, 2)
might help by expanding the matplotlib canvas. However window size would vary. - [x] Add error handling for loading projdata with no binary or error when reading binary. The error should be displayed in the application window (see here)
- [ ] Colormap limit consistency and options to set values. Currently, the 2D slice determines the colormap and the limits. These should be consistent when sliders are adjusted.
Suggestion: Add error handling for loading projdata with no binary or error when reading binary. The error should be displayed in the application window.
$ python3 examples/python/projdata_visualisation/ProjDataVisualisation.py
ProjDataVisualisationBackend.load_data: Loading data from file: /home/rts/devel/stir/examples/PET_simulation/scatter_template.hs
WARNING:
Interfile warning: I did not recognise the scanner neither from
'originating_system' or 'number of detectors per ring' and 'number of rings'.
WARNING: Interfile warning: 'default_bin size (cm)' invalid.
WARNING: Interfile warning: 'axial crystals per singles unit' invalid.
WARNING: Interfile warning: 'transaxial crystals per singles unit' invalid.
WARNING: Interfile warning: 'distance between crystals in axial direction (cm)' invalid.
WARNING: Interfile warning: 'distance between crystals in transaxial direction (cm)' invalid.
WARNING: Interfile warning: 'distance between blocks in axial direction (cm)' invalid.
WARNING: Interfile warning: 'distance between blocks in transaxial direction (cm)' invalid.
WARNING: Scanner unknown: transaxial block info is not set (probably irrelevant unless you use a projector or normalisation that needs this block info)
WARNING: Scanner unknown: transaxial bucket info is not set (probably irrelevant unless you use dead-time correction that needs this info)
WARNING: Scanner unknown: axial block info is not set (probably irrelevant unless you use a projector or normalisation that needs this block info)
WARNING: Scanner unknown: axial bucket info is not set (probably irrelevant unless you use dead-time correction that needs this info)
WARNING: Scanner unknown: transaxial singles_unit info is not set (probably irrelevant unless you use dead-time correction that needs this info)
WARNING: Scanner unknown: axial singles_unit info is not set (probably irrelevant unless you use dead-time correction that needs this info)
WARNING: Interfile parsing ended up with the following scanner:
Scanner parameters:=
Scanner type := unknown
Number of rings := 8
Number of detectors per ring := 64
Inner ring diameter (cm) := 88.62
Average depth of interaction (cm) := 0.84
Distance between rings (cm) := 1.962
Default bin size (cm) := -1
View offset (degrees) := 0
Maximum number of non-arc-corrected bins := 35
Default number of arc-corrected bins := 0
Energy resolution := 0.16
Reference energy (in keV) := 511
Number of blocks per bucket in transaxial direction := 0
Number of blocks per bucket in axial direction := 0
Number of crystals per block in axial direction := 0
Number of crystals per block in transaxial direction := 0
Number of detector layers := 1
Number of crystals per singles unit in axial direction := -1
Number of crystals per singles unit in transaxial direction := -1
Scanner geometry (BlocksOnCylindrical/Cylindrical/Generic) := Cylindrical
End scanner parameters:=
WARNING: read_data: error after reading from stream.
ERROR: ProjDataFromStream: error reading data
ProjDataVisualisationBackend.load_data: Error loading data from file: /home/rts/devel/stir/examples/PET_simulation/scatter_template.hs
Traceback (most recent call last):
File "/home/rts/devel/stir/examples/python/projdata_visualisation/ProjDataVisualisation.py", line 239, in browse_file_system_for_projdata
self.load_projdata(filename[0])
File "/home/rts/devel/stir/examples/python/projdata_visualisation/ProjDataVisualisation.py", line 260, in load_projdata
self.refresh_UI_configuration()
File "/home/rts/devel/stir/examples/python/projdata_visualisation/ProjDataVisualisation.py", line 167, in refresh_UI_configuration
self.update_display_image()
File "/home/rts/devel/stir/examples/python/projdata_visualisation/ProjDataVisualisation.py", line 182, in update_display_image
image = self.get_sinogram_numpy_array()
File "/home/rts/devel/stir/examples/python/projdata_visualisation/ProjDataVisualisation.py", line 226, in get_sinogram_numpy_array
self.stir_interface.segment_data.get_sinogram(self.get_bin().axial_pos_num))
AttributeError: 'NoneType' object has no attribute 'get_sinogram'
Add a checkbox to sum over TOF indices, as suggested https://github.com/UCL/STIR/pull/1319#issuecomment-1887589084
I have to give up soon but here is a note on this. Adding a checkbox should be done to the ModeSelectionGroupBox
, as added in #1321.
Segments are unique for each TOF index and so requires a new segment to be loaded.
def timing_pos_refresh(self):
"""This function is called when the user changes the TOF bin value."""
new_segment_num = self.UI_slider_spinboxes[ProjDataDims.SEGMENT_NUM].value()
new_timing_pos = self.UI_slider_spinboxes[ProjDataDims.TIMING_POS].value()
self.stir_interface.segment_data = self.stir_interface.get_segment_data(new_segment_num, new_timing_pos)
self.UI_controller_UI_change_trigger()
To sum each TOF index, we would need to load every TOF bins segment, convert to numpy and sum. It would be more convenient to do this on the cpp side.