Skip to content

Commit

Permalink
Merge pull request #228 from danieldeidda/spect_ex
Browse files Browse the repository at this point in the history
[ci skip] making SPECT solution and exercise consistent
  • Loading branch information
KrisThielemans authored May 16, 2024
2 parents 4581d44 + 4d42abc commit c5bb3dc
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 39 deletions.
44 changes: 37 additions & 7 deletions notebooks/SPECT/SPECT_OSEM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
"A notebook to demonstrate the setup and basic OSEM reconstruction of a 2-dimensional dummy image using SIRF's SPECT projector"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Authors: Daniel Deidda and Sam Porter \n",
"\n",
"CCP SyneRBI Synergistic Image Reconstruction Framework (SIRF). \n",
"Copyright 2022 - 2024 National Physical Laboratory \n",
"Copyright 2022 - 2024, 2021 University College London\n",
"\n",
"This is software developed for the Collaborative Computational Project in Synergistic Reconstruction for Biomedical Imaging (http://www.ccpsynerbi.ac.uk/).\n",
"\n",
"SPDX-License-Identifier: Apache-2.0"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -183,7 +198,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we need to create the acquisition model by first creating an acquisition matrix (SPECTUBMatrix) object and apply this to a sirf Acquisition Model (AcquisitionModelUsingMatrix) object"
"Now we need to create the acquisition model by first creating an acquisition matrix (SPECTUBMatrix) object, add attenuation, PSF, and apply this to a sirf Acquisition Model \n",
"(AcquisitionModelUsingMatrix) object. Hint (help(spect.SPECTUBMatrix))"
]
},
{
Expand All @@ -192,7 +208,9 @@
"metadata": {},
"outputs": [],
"source": [
"### Acquisition Model code here ###"
"### Acquisition Model code here ###\n",
"# acq_model_matrix =?\n",
"help(spect.SPECTUBMatrix)"
]
},
{
Expand Down Expand Up @@ -239,12 +257,21 @@
"metadata": {},
"outputs": [],
"source": [
"### Objective Function code here ###\n",
"# create objective function\n",
"obj_fun = spect.make_Poisson_loglikelihood(noisy_data)\n",
"\n",
"### and now we apply a different resolution mdoel ### and\n",
"acq_model_matrix.set_resolution_model(0.1,0.1,full_3D=False)\n",
"acq_model_2 = spect.AcquisitionModelUsingMatrix(acq_model_matrix)\n",
"obj_fun.set_acquisition_model(acq_model_2)\n",
"\n",
"# create OSEM reconstructor object\n",
"num_subsets = 21 # number of subsets for OSEM reconstruction\n",
"num_subiters = 42 #number of subiterations (i.e two full iterations)\n",
"\n",
"### OSEM reconstructor code here ###"
"OSEM_reconstructor = spect.OSMAPOSLReconstructor()\n",
"OSEM_reconstructor.set_objective_function(obj_fun)\n",
"OSEM_reconstructor.set_num_subsets(num_subsets)\n",
"OSEM_reconstructor.set_num_subiterations(num_subiters)"
]
},
{
Expand Down Expand Up @@ -326,12 +353,15 @@
},
"language_info": {
"codemirror_mode": {
"name": "ipython"
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python"
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
7 changes: 5 additions & 2 deletions notebooks/SPECT/SPECT_OSEM_measured_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,15 @@
},
"language_info": {
"codemirror_mode": {
"name": "ipython"
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python"
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
40 changes: 20 additions & 20 deletions notebooks/SPECT/SPECT_OSEM_measured_data_solution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "962178b0",
"id": "0",
"metadata": {},
"source": [
"Simple OSEM reconstruction demo for real data: \n",
Expand All @@ -28,7 +28,7 @@
},
{
"cell_type": "markdown",
"id": "d91eaa49",
"id": "1",
"metadata": {},
"source": [
"In this exercise you are going to apply what you learned in the previous notebooks about SPECT reconstruction to reconstruct real data. \n"
Expand All @@ -37,7 +37,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f80fd2f7",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -63,7 +63,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9e8458d6",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -75,7 +75,7 @@
},
{
"cell_type": "markdown",
"id": "08524093",
"id": "4",
"metadata": {},
"source": [
"The following is not needed if the data is already downloaded"
Expand All @@ -84,7 +84,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "bbca69aa",
"id": "5",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -97,7 +97,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "931f651d",
"id": "6",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -110,7 +110,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6ec9dcbc",
"id": "7",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -120,7 +120,7 @@
},
{
"cell_type": "markdown",
"id": "54ce83d9",
"id": "8",
"metadata": {},
"source": [
"# Exercise 1: Simple Reconstruction:\n",
Expand All @@ -130,7 +130,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "58584f1f",
"id": "9",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -145,7 +145,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "850fd91f",
"id": "10",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -158,7 +158,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d14521ed",
"id": "11",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -173,7 +173,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4479d023",
"id": "12",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -188,7 +188,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0663ab88",
"id": "13",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -200,7 +200,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "82b2fcec",
"id": "14",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -216,7 +216,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "dd1042e3",
"id": "15",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -231,7 +231,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "51264d96",
"id": "16",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -244,7 +244,7 @@
},
{
"cell_type": "markdown",
"id": "57e0ffc1",
"id": "17",
"metadata": {},
"source": [
"# Exercise 2: PSF Reconstruction:\n",
Expand All @@ -260,7 +260,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3f5fce65",
"id": "18",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -282,7 +282,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0c56f23b",
"id": "19",
"metadata": {},
"outputs": [],
"source": [
Expand Down
Loading

0 comments on commit c5bb3dc

Please sign in to comment.