SPECT#
Data used in the tutorials can be downloaded here.
Introduction#
The use cases below are basic introductions for how to use the library, and demonstrate complete reconstruction pipelines for SIMIND (Monte Carlo) and DICOM (clinical) phantom data using OSEM. They are a good starting point for learning the library.
Available Algorithms#
The tutorials below demonstrates some of the available reconstruction algorithms of the library, and borrows code from the introduction tutorials above.
Additional Use Cases#
The tutorials below demonstrate some additional use cases for SPECT reconstruction, such as reconstructing and stitching multi-bed positions, reconstructing multiple photopeaks, and estimating uncertainty in reconstructed images
Unique Systems#
Some SPECT systems have unique properties that require special handling. The tutorials below demonstrate how to handle these systems.
Advanced PSF Models#
The tutorials below demonstrate how to use PSF models obtained via the SPECTPSFToolbox for Ac-225 reconstruction, though they can be adapted for other isotopes.
Cardiac Functionality#
The tutorials below demonstrate reconstruction and reorientation of cardiac SPECT data.
Useful Code Snippets#
The following contains some useful code snippets you may require when working with PyTomography.
1import os
2from pytomography.io.SPECT import simind
3
4path = '/disk1/pytomography_tutorial_data/simind_tutorial/'
5
6# SIMIND simulation files for simulation of only a liver region
7photopeak_path_liver = os.path.join(path, 'multi_projections', 'liver', 'photopeak.h00')
8upperscatter_path_liver = os.path.join(path, 'multi_projections', 'liver', 'lowerscatter.h00')
9lowerscatter_path_liver = os.path.join(path, 'multi_projections', 'liver', 'upperscatter.h00')
10
11# SIMIND simulation files for simulation of all anatomical regions
12organs = ['bkg', 'liver', 'l_lung', 'r_lung', 'l_kidney', 'r_kidney','salivary', 'bladder']
13headerfiles = [os.path.join(path, 'multi_projections', organ, 'photopeak.h00') for organ in organs]
14headerfiles_lower = [os.path.join(path, 'multi_projections', organ, 'lowerscatter.h00') for organ in organs]
15headerfiles_upper = [os.path.join(path, 'multi_projections', organ, 'upperscatter.h00') for organ in organs]
16
17# 1. To load multiple energy windows for one region, we provide the paths as a list
18photopeak_liver = simind.get_projections([photopeak_path_liver, upperscatter_path_liver, lowerscatter_path_liver])
19print(photopeak_liver.shape)
20
21# 2. To load a single energy window and combine multiple regions, we provide the list as [[<list>]]. This will scale each SIMIND set of projections by the corresponding activities (combining projections together):
22activities = [2500, 450, 7, 7, 100, 100, 20, 90] # MBq
23photopeak_allregions = simind.get_projections([headerfiles], weights=activities)
24print(photopeak_allregions.shape)
25
26# 3. To load multiple energy windows for multiple regions, we provide the list as [[<list>], [<list>], [<list>]]:
27activities = [2500, 450, 7, 7, 100, 100, 20, 90] # MBq
28projections_allregions = simind.get_projections([headerfiles, headerfiles_lower, headerfiles_upper], weights=activities)
29print(projections_allregions.shape)
1from pytomography.io.SPECT import simind
2from pytomography.io.SPECT.shared import subsample_metadata, subsample_amap, subsample_projections
3import os
4
5# CHANGE THIS TO WHERE YOU DOWNLOADED THE TUTORIAL DATA
6PATH = '/disk1/pytomography_tutorial_data'
7
8data_path = os.path.join(PATH, 'simind_tutorial', 'lu177_SYME_jaszak')
9photopeak_path = os.path.join(data_path,'tot_w4.h00')
10attenuation_path = os.path.join(data_path, 'amap.h00')
11
12object_meta, proj_meta = simind.get_metadata(photopeak_path)
13photopeak = simind.get_projections(photopeak_path)
14amap = simind.get_attenuation_map(attenuation_path)
15
16# Projection data can be subsampled in pixels (via average pooling) and angles via
17photopeak_subsampled = subsample_projections(
18 projections = photopeak,
19 N_pixel = 2, # from 128x128 to 64x64
20 N_angle = 2, # every 2nd angle
21 N_angle_start = 1, # angle to start at
22)
23
24# If you subsample the photopeak, you also have to adjust the metadata:
25object_meta_subsampled, proj_meta_subsampled = subsample_metadata(
26 object_meta = object_meta,
27 proj_meta = proj_meta,
28 N_pixel = 2,
29 N_angle = 2,
30 N_angle_start = 1,
31)
32
33# And the attenuation map (if you use attenuation correction):
34attenuation_map = subsample_amap(
35 amap = amap,
36 N_pixel = 2,
37)
38
39# You can then proceed to use the updated metadata/projections to build the system matrix and likelihood as normal