Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single scatter #143

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/pytomography/io/SPECT/dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ def get_scatter_from_TEW(
file: str, index_peak: int, index_lower: int, index_upper: int
) -> torch.Tensor:
"""Gets an estimate of scatter projection data from a DICOM file using the triple energy window method.
If there is only one scatter window, set both index_lower and index_upper to the lower index.
The upper scatter window will be set to zero

Args:
file (str): Filepath of the DICOM file
Expand All @@ -211,9 +213,13 @@ def get_scatter_from_TEW(
ww_lower = get_window_width(ds, index_lower)
ww_upper = get_window_width(ds, index_upper)
projections_all = get_projections(file)
projections_upper = projections_all[index_upper]
if index_lower == index_upper:
projections_upper = projections_all[index_upper].detach().clone()
projections_upper[:] = 0
scatter = compute_TEW(
projections_all[index_lower],
projections_all[index_upper],
projections_upper,
ww_lower,
ww_upper,
ww_peak,
Expand Down Expand Up @@ -589,4 +595,4 @@ def save_dcm(
# Set the pixel data
ds_i.PixelData = pixel_data[i].tobytes()
ds_i.save_as(os.path.join(save_path, f'{ds.SOPInstanceUID}.dcm'))