Skip to content

Commit 8f6f440

Browse files
authored
Merge pull request #28 from lukepolson/j_paper
J paper
2 parents 95b42e2 + a685bc5 commit 8f6f440

36 files changed

+4728
-4204
lines changed

.gitignore

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
*__pycache__*
2-
paper/jats
3-
paper/paper
4-
paper/*.png
5-
paper/*.pdf
6-
*code-workspace
7-
SlicerSPECTRecon/__pycache__/
8-
testing
9-
SlicerSPECTRecon/Logic/rough.ipynb
10-
.vscode
1+
*__pycache__*
2+
paper/jats
3+
paper/paper
4+
paper/*.png
5+
paper/*.pdf
6+
*code-workspace
7+
SlicerSPECTRecon/__pycache__/
8+
SlicerSPECTRecon/Logic/rough.ipynb
9+
.vscode

CONTRIBUTING.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
# Contributing to SlicerSPECTRecon
2-
3-
First off, thanks for your interest in contributing! There are many potential options for contributions to this library: most notably, implementation of conversion from alternative sources to dicom format, implementation of different prior functions, implementation of additional reconstruction algorithms, etc. If you wish to contribute:
4-
5-
**Bugs**
6-
1. Open an issue.
7-
2. Provide as much context as you can about what you're running into.
8-
3. Provide project and platform versions.
9-
10-
**New Features**
11-
12-
The recommended method of contributing is as follows:
13-
1. Create an issue on the [issues page](https://github.com/PyTomography/slicer_spect_recon/issues)
14-
2. Fork the repository to your own account
15-
3. Fix issue and push changes to your own fork on GitHub
16-
4. Create a pull request from your fork (whatever branch you worked on) to the development branch in the main repository.
17-
18-
## Setup
19-
20-
To activate and use this module please follow these steps:
21-
22-
1. Either `unzip` the source code or `clone` it from GitHub.
23-
2. Add the respective path in `Slicer` by *Edit -> Application settings -> Modules -> Additional module paths -> Add -> OK*.
24-
3. `Restart` Slicer to apply the changes.
25-
4. `Choose` the module under *Modules -> Tomographic Reconstruction -> SlicerSPECTRecon*.
26-
27-
## Testing
28-
29-
The tests in `Logic/SlicerSPECTReconTest` can be run in `Slicer` itself. Therefore, the module has to be already imported and activated.
30-
31-
Additionally, you have to enable the `developer mode` under *Edit -> Application settings -> Developer -> Enable developer mode -> OK*.
32-
33-
After reloading Slicer, you should see a column `Reload and Test`. To run the tests and changes to the source code, just click this button. This reimports the module with the current changes and runs the code against the given tests.
34-
35-
## Sample Data
36-
37-
The links to the example data (sample patient and simind files) are in the sample_data.txt file in the `Resources` folder.
38-
39-
## Contribute
40-
41-
If you'd like to contribute, you can find an orientation on the Slicer [documentation for developers](https://www.slicer.org/wiki/Documentation/Nightly/Developers).
42-
43-
## License
44-
45-
SlicerSPECTRecon is subject to the `MIT License`, which can be found in the project's root.
1+
# Contributing to SlicerSPECTRecon
2+
3+
First off, thanks for your interest in contributing! There are many potential options for contributions to this library: most notably, implementation of conversion from alternative sources to dicom format, implementation of different prior functions, implementation of additional reconstruction algorithms, etc. If you wish to contribute:
4+
5+
**Bugs**
6+
1. Open an issue.
7+
2. Provide as much context as you can about what you're running into.
8+
3. Provide project and platform versions.
9+
10+
**New Features**
11+
12+
The recommended method of contributing is as follows:
13+
1. Create an issue on the [issues page](https://github.com/PyTomography/slicer_spect_recon/issues)
14+
2. Fork the repository to your own account
15+
3. Fix issue and push changes to your own fork on GitHub
16+
4. Create a pull request from your fork (whatever branch you worked on) to the development branch in the main repository.
17+
18+
## Setup
19+
20+
To activate and use this module please follow these steps:
21+
22+
1. Either `unzip` the source code or `clone` it from GitHub.
23+
2. Add the respective path in `Slicer` by *Edit -> Application settings -> Modules -> Additional module paths -> Add -> OK*.
24+
3. `Restart` Slicer to apply the changes.
25+
4. `Choose` the module under *Modules -> Tomographic Reconstruction -> SlicerSPECTRecon*.
26+
27+
## Testing
28+
29+
The tests in `Logic/SlicerSPECTReconTest` can be run in `Slicer` itself. Therefore, the module has to be already imported and activated.
30+
31+
Additionally, you have to enable the `developer mode` under *Edit -> Application settings -> Developer -> Enable developer mode -> OK*.
32+
33+
After reloading Slicer, you should see a column `Reload and Test`. To run the tests and changes to the source code, just click this button. This reimports the module with the current changes and runs the code against the given tests.
34+
35+
## Sample Data
36+
37+
The links to the example data (sample patient and simind files) are in the sample_data.txt file in the `Resources` folder.
38+
39+
## Contribute
40+
41+
If you'd like to contribute, you can find an orientation on the Slicer [documentation for developers](https://www.slicer.org/wiki/Documentation/Nightly/Developers).
42+
43+
## License
44+
45+
SlicerSPECTRecon is subject to the `MIT License`, which can be found in the project's root.

LICENSE.txt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
MIT License
2-
3-
Copyright (c) [2024] [Obed Dzikunu]
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1+
MIT License
2+
3+
Copyright (c) [2024] [Obed Dzikunu]
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.

README.md

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
# SPECT Tomographic Reconstruction 3D Slicer Extension
2-
3-
This is the official repository for the `Slicer` extension `SlicerSPECTRecon`.
4-
5-
This module enables the reconstruction of raw SPECT projection data, providing customizable options for image modeling and image reconstruction. The module has a SIMIND to DICOM converter to permit reconstruction of SIMIND Monte Carlo data.
6-
7-
The module is divided into the following sections:
8-
9-
- Data Converters: Provides tools for converting data from various sources into the DICOM format.
10-
- Input Data: Users can select data from multiple bed positions after loading the projection data into the 3D Slicer DICOM database.
11-
- System Modeling: Allows users to define transforms that are used to build the system matrix.
12-
- Likelihood: Allows users to choose their preferred likelihood function.
13-
- Reconstruction Algorithm: Provides the option of selecting a preferred reconstruction algorithm and their associated parameters
14-
15-
Please refer to the `User_Manual.md` file for further information
16-
17-
## User interface
18-
19-
- Inputs
20-
- Input volume: input SPECT/CT dicom files, simind file (convert to dicom using the data converter)
21-
- Outputs
22-
- Reconstructed volume: The volume will be saved under the specified name (or as the dataset name appended with _reconstructed) and will be located within the Subject Hierarchy in the Data Module.
23-
24-
## Resources
25-
26-
The following link collection should facilitate understanding the code in this extension:
27-
28-
- [Slicer Utils](https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/util.py)
29-
- [DICOM Introduction](https://www.slicer.org/wiki/Documentation/Nightly/FAQ/DICOM)
30-
- [DICOM Structure](https://www.slicer.org/wiki/Documentation/4.0/Modules/CreateDICOMSeries)
31-
- [DICOM Browser](https://dicom.innolitics.com/ciods)
32-
- [Subject Hierarchy](https://www.slicer.org/wiki/Documentation/4.5/Modules/SubjectHierarchy)
33-
34-
## Sample Data
35-
36-
The links to the example data (sample patient and simind files) are in the sample_data.txt file in the `Resources` folder.
37-
38-
## Contribute
39-
40-
If you'd like to contribute, you can find an orientation on the Slicer [documentation for developers](https://www.slicer.org/wiki/Documentation/Nightly/Developers).
41-
42-
Please read first the `CONTRIBUTING.md` file for further information on how to contribute. You can also check the Pytomography [readthedocs](https://pytomography.readthedocs.io/en/latest/) for an orientation on Pytomography.
43-
44-
## License
45-
46-
SlicerSPECTRecon is subject to the `MIT License`, which is in the project's root.
47-
48-
## Contact
49-
1+
# SPECT Tomographic Reconstruction 3D Slicer Extension
2+
3+
This is the official repository for the `Slicer` extension `SlicerSPECTRecon`.
4+
5+
This module enables the reconstruction of raw SPECT projection data, providing customizable options for image modeling and image reconstruction. The module has a SIMIND to DICOM converter to permit reconstruction of SIMIND Monte Carlo data.
6+
7+
The module is divided into the following sections:
8+
9+
- Data Converters: Provides tools for converting data from various sources into the DICOM format.
10+
- Input Data: Users can select data from multiple bed positions after loading the projection data into the 3D Slicer DICOM database.
11+
- System Modeling: Allows users to define transforms that are used to build the system matrix.
12+
- Likelihood: Allows users to choose their preferred likelihood function.
13+
- Reconstruction Algorithm: Provides the option of selecting a preferred reconstruction algorithm and their associated parameters
14+
15+
Please refer to the `User_Manual.md` file for further information
16+
17+
## User interface
18+
19+
- Inputs
20+
- Input volume: input SPECT/CT dicom files, simind file (convert to dicom using the data converter)
21+
- Outputs
22+
- Reconstructed volume: The volume will be saved under the specified name (or as the dataset name appended with _reconstructed) and will be located within the Subject Hierarchy in the Data Module.
23+
24+
## Resources
25+
26+
The following link collection should facilitate understanding the code in this extension:
27+
28+
- [Slicer Utils](https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/util.py)
29+
- [DICOM Introduction](https://www.slicer.org/wiki/Documentation/Nightly/FAQ/DICOM)
30+
- [DICOM Structure](https://www.slicer.org/wiki/Documentation/4.0/Modules/CreateDICOMSeries)
31+
- [DICOM Browser](https://dicom.innolitics.com/ciods)
32+
- [Subject Hierarchy](https://www.slicer.org/wiki/Documentation/4.5/Modules/SubjectHierarchy)
33+
34+
## Sample Data
35+
36+
The links to the example data (sample patient and simind files) are in the sample_data.txt file in the `Resources` folder.
37+
38+
## Contribute
39+
40+
If you'd like to contribute, you can find an orientation on the Slicer [documentation for developers](https://www.slicer.org/wiki/Documentation/Nightly/Developers).
41+
42+
Please read first the `CONTRIBUTING.md` file for further information on how to contribute. You can also check the Pytomography [readthedocs](https://pytomography.readthedocs.io/en/latest/) for an orientation on Pytomography.
43+
44+
## License
45+
46+
SlicerSPECTRecon is subject to the `MIT License`, which is in the project's root.
47+
48+
## Contact
49+
5050
Please post any questions to the [Pytomography Discourse Forum](https://pytomography.discourse.group/).

SlicerSPECTRecon/CMakeLists.txt

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
1-
#-----------------------------------------------------------------------------
2-
set(MODULE_NAME SlicerSPECTRecon)
3-
4-
#-----------------------------------------------------------------------------
5-
set(MODULE_PYTHON_SCRIPTS
6-
${MODULE_NAME}.py
7-
Logic/algorithms.py
8-
Logic/getmetadatautils.py
9-
Logic/likelihood.py
10-
Logic/priors.py
11-
Logic/simindToDicom.py
12-
Logic/SlicerSPECTReconLogic.py
13-
Logic/SlicerSPECTReconTest.py
14-
Logic/systemMatrix.py
15-
Logic/transforms.py
16-
Logic/volumeutils.py
17-
Logic/vtkkmrmlutils.py
18-
Logic/simindToDicomConverterTest.py
19-
Logic/testutils_builder.py
20-
Logic/dicomvalues.py
21-
)
22-
23-
set(MODULE_PYTHON_RESOURCES
24-
Resources/Icons/${MODULE_NAME}.png
25-
Resources/UI/${MODULE_NAME}.ui
26-
Resources/algorithmTestSettings.json
27-
Resources/psfMeta.json
28-
Resources/sampleDataMetaData.json
29-
)
30-
31-
#-----------------------------------------------------------------------------
32-
slicerMacroBuildScriptedModule(
33-
NAME ${MODULE_NAME}
34-
SCRIPTS ${MODULE_PYTHON_SCRIPTS}
35-
RESOURCES ${MODULE_PYTHON_RESOURCES}
36-
WITH_GENERIC_TESTS
37-
)
38-
39-
#-----------------------------------------------------------------------------
40-
if(BUILD_TESTING)
41-
42-
# Register the unittest subclass in the main script as a ctest.
43-
# Note that the test will also be available at runtime.
44-
# slicer_add_python_unittest(SCRIPT ${MODULE_NAME}.py)
45-
46-
# Additional build-time testing
47-
add_subdirectory(Logic)
48-
endif()
1+
#-----------------------------------------------------------------------------
2+
set(MODULE_NAME SlicerSPECTRecon)
3+
4+
#-----------------------------------------------------------------------------
5+
set(MODULE_PYTHON_SCRIPTS
6+
${MODULE_NAME}.py
7+
Logic/Algorithms.py
8+
Logic/Callbacks.py
9+
Logic/MetadataUtils.py
10+
Logic/Priors.py
11+
Logic/SimindToDicom.py
12+
Logic/SlicerSPECTReconLogic.py
13+
Logic/VolumeUtils.py
14+
Logic/VtkkmrmlUtils.py
15+
Testing/Python/reconstruction.py
16+
Testing/Python/simind_to_dicom.py
17+
Testing/Python/utils.py
18+
)
19+
20+
set(MODULE_PYTHON_RESOURCES
21+
Resources/Icons/${MODULE_NAME}.png
22+
Resources/UI/${MODULE_NAME}.ui
23+
Resources/algorithmTestSettings.json
24+
Resources/psfMeta.json
25+
Resources/sampleDataMetaData.json
26+
)
27+
28+
#-----------------------------------------------------------------------------
29+
slicerMacroBuildScriptedModule(
30+
NAME ${MODULE_NAME}
31+
SCRIPTS ${MODULE_PYTHON_SCRIPTS}
32+
RESOURCES ${MODULE_PYTHON_RESOURCES}
33+
WITH_GENERIC_TESTS
34+
)
35+
36+
#-----------------------------------------------------------------------------
37+
if(BUILD_TESTING)
38+
39+
# Register the unittest subclass in the main script as a ctest.
40+
# Note that the test will also be available at runtime.
41+
# slicer_add_python_unittest(SCRIPT ${MODULE_NAME}.py)
42+
43+
# Additional build-time testing
44+
add_subdirectory(Logic)
45+
endif()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from pytomography.algorithms import OSEM, BSREM, OSMAPOSL
2+
3+
def selectAlgorithm(algorithm, likelihood, prior):
4+
if algorithm == "OSEM":
5+
reconstruction_algorithm = OSEM(likelihood)
6+
return reconstruction_algorithm
7+
elif algorithm == "BSREM":
8+
reconstruction_algorithm = BSREM(likelihood, prior=prior)
9+
return reconstruction_algorithm
10+
elif algorithm == "OSMAPOSL":
11+
reconstruction_algorithm = OSMAPOSL(likelihood, prior=prior)
12+
return reconstruction_algorithm
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
slicer_add_python_unittest(SCRIPT SlicerSPECTReconTest.py SLICER_ARGS --no-main-window)
2-
slicer_add_python_unittest(SCRIPT simindToDicomConverterTest.py SLICER_ARGS --no-main-window)
1+
slicer_add_python_unittest(SCRIPT ./../Testing/Python/reconstruction.py SLICER_ARGS --no-main-window)
2+
slicer_add_python_unittest(SCRIPT ./../Testing/Python/simind_To_dicom.py SLICER_ARGS --no-main-window)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import slicer
2+
from pytomography.callbacks import Callback, DataStorageCallback
3+
4+
class LoadingCallback(Callback):
5+
def __init__(self, progressDialog, n_iters, n_subsets):
6+
self.progressDialog = progressDialog
7+
self.total_subiterations = n_iters*n_subsets
8+
self.n_subsets = n_subsets
9+
10+
def run(self, object, n_iter, n_subset):
11+
self.progressDialog.value = int((n_iter*self.n_subsets+n_subset+1)/self.total_subiterations * 100)
12+
slicer.app.processEvents()
13+
return object
14+
15+
class DataStorageWithLoadingCallback(DataStorageCallback):
16+
def __init__(self, likelihood, object_prediction, progressDialog, n_iters, n_subsets):
17+
super().__init__(likelihood, object_prediction)
18+
self.progressDialog = progressDialog
19+
self.total_subiterations = n_iters*n_subsets
20+
self.n_subsets = n_subsets
21+
22+
def run(self, object, n_iter, n_subset):
23+
object = super().run(object, n_iter, n_subset)
24+
self.progressDialog.value = int((n_iter*self.n_subsets+n_subset+1)/self.total_subiterations * 100)
25+
slicer.app.processEvents()
26+
return object

0 commit comments

Comments
 (0)