Skip to content

Commit 9d85afb

Browse files
committed
🎉 adds various final changes #4 (PR#19 ready to be merged):
* imports #13 (comment) #12, * imports #13 (comment) #12, * __init__.py #13 (comment) #12, * relative imports #13 (comment) #12, * removes src/Readme and episodes/data/Untitled.txt #4 > #19 (comment) * adds ITK-SNAP visualisation coordinate system #4
1 parent dca2985 commit 9d85afb

11 files changed

Lines changed: 47 additions & 62 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ episodes/*html
99
site/*
1010
!site/README.md
1111

12+
## Temporal files for ITK-SNAP registration
13+
**Untitled.txt
14+
1215
# History files
1316
.Rhistory
1417
.Rapp.history

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ git clone git@github.com:HealthBioscienceIDEAS/Medical-Image-Registration-Short-
2323
```
2424

2525
## Maintainers
26+
This project exists thanks to all mainteners. Sort list by last name (alphabetically).
2627
* [Dave Cash](https://github.com/davecash75)
2728
* [Jamie Mcclelland](https://github.com/jamie-mcclelland)
2829

2930
## Contributors
30-
This project exists thanks to all the people who contribute.
31+
This project exists thanks to all the people who contribute. Sort list by last name (alphabetically).
3132
* [Dave Cash](https://github.com/davecash75)
32-
* [Jamie Mcclelland](https://github.com/jamie-mcclelland)
3333
* [Milan Malfait](https://github.com/milanmlft)
34+
* [Jamie Mcclelland](https://github.com/jamie-mcclelland)
3435
* [Zakaria Senousy](https://github.com/zsenousy)
3536
* [Stephen Thompson](https://github.com/thompson318)
3637
* [Miguel Xochicale](https://github.com/mxochicale)

episodes/data/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Demo data
1+
# Medical Data Imaging
22

33
## CT-vs-PET-Ventilation-Imaging
44
CT Ventilation as a Functional Imaging Modality for Lung Cancer Radiotherapy from [TCIA](https://www.cancerimagingarchive.net/collection/ct-vs-pet-ventilation-imaging/).
@@ -39,7 +39,12 @@ Data paths look like these:
3939
```
4040

4141

42-
### Data is converted using:
42+
### Citations & Data Usage Policy
43+
Data Citation Required: Users must abide by [the TCIA Data Usage Policy and Restrictions](https://www.cancerimagingarchive.net/data-usage-policies-and-restrictions/).
44+
Attribution must include the following citation, including the Digital Object Identifier:
45+
> Eslick, E. M., Kipritidis, J., Gradinscak, D., Stevens, M. J., Bailey, D. L., Harris, B., Booth, J. T., & Keall, P. J. (2022). CT Ventilation as a functional imaging modality for lung cancer radiotherapy (CT-vs-PET-Ventilation-Imaging) (Version 1) [Data set]. The Cancer Imaging Archive. https://doi.org/10.7937/3ppx-7s22
46+
47+
### Data is converted from DICOM to nifti using `dicom2nifti`:
4348
```
4449
from pathlib import Path
4550
import dicom2nifti
@@ -50,5 +55,5 @@ dicom2nifti.convert_directory(dicoms, ".", compression=True, reorient=True)
5055

5156
## Demons Image Registration Exercise Data
5257

53-
Please check `data` folder inside `episodes` for accessing `cine_MR_img_1.png`, `cine_MR_img_2.png`, and `cine_MR_img_3.png` that are used for demonReg.py and `exampleSolution3.py`.
58+
Please check [`data`](https://github.com/HealthBioscienceIDEAS/Medical-Image-Registration-Short-Course/tree/main/episodes/data) folder inside `episodes` for accessing `cine_MR_img_1.png`, `cine_MR_img_2.png`, and `cine_MR_img_3.png` that are used for [`demonReg.py`](https://github.com/HealthBioscienceIDEAS/Medical-Image-Registration-Short-Course/blob/main/src/mirc/utils/demonsReg.py) and [`exampleSolution3.py`](https://github.com/HealthBioscienceIDEAS/Medical-Image-Registration-Short-Course/blob/main/src/mirc/examples/exampleSolution3.py).
5459

episodes/data/Untitled.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

episodes/excthreesteps.Rmd

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ Open terminal, activate `mirVE` environment and run python
2525
conda activate mirVE
2626
python
2727
```
28+
:::::::::::::::::::::::::::::::::::::: spoiler
29+
30+
## How to avoid `ModuleNotFoundError: No module named VARIABLE`?
31+
32+
You need to export relative imports, using the following notation for either linux or windows (might be similar to mac)
33+
34+
```bash
35+
#WINDOWS
36+
set PYTHONPATH=%PYTHONPATH%;C:\path\to\your\project\
37+
#LINUX
38+
export PYTHONPATH="${PYTHONPATH}:/path/to/your/project/"
39+
```
40+
41+
::::::::::::::::::::::::::::::::::::::
2842

2943
This document explains the implementation of a 2D image registration algorithm using the Demons algorithm. The implementation includes visualisation updates within a single window containing three panes for easier comparison of source, target, and warped images.
3044

@@ -460,4 +474,4 @@ demonsReg(cine_MR_img_1, cine_MR_img_2)
460474
<video width="800" height="450" controls>
461475
<source src="fig/final_results_vid.mp4" type="video/mp4">
462476
Your browser does not support the video tag.
463-
</video>
477+
</video>
330 KB
Loading

episodes/itksnap.Rmd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,10 @@ system (i.e. the values increase as you move to the right and anterior of the pa
508508
Therefore, the world coordinates decrease as the voxel indices increase.
509509

510510
#### ITK-SNAP visualisation coordinate system
511-
TOADD
511+
ITK-SNAP provides the option, `Tools>Reorient Image`, to set image orientation using three-letter code (**RAI** code), describing the image rows, columns, and slice map to the anatomical coordinates.
512+
For example, the code **ASL** means that image rows (X) run from **A**nterior to **P**osterior, image columns (Y) run from **S**uperior to **I**nferior, and images slices (Z) run from **L**eft to **R**ight.
513+
514+
![Figure. ITK-SNAP Reorient image](fig/itk-snap-tools-reorient-image.png)
512515

513516
## Modifying `NifTi` images and headers with Nibabel
514517

@@ -916,7 +919,7 @@ For manual image registration in ITK-SNAP go to Tools > image registration
916919

917920
![Figure. ITK-SNAP main window](fig/itk-snap-image-manual-registration.png)
918921

919-
* Automatic registration (affine)
922+
* Automatic registration (affine)
920923
You can use [niftyreg](https://nipype.readthedocs.io/en/latest/api/generated/nipype.interfaces.niftyreg.reg.html), [Reg_aladin](http://cmictig.cs.ucl.ac.uk/wiki/index.php/Reg_aladin) or [DL methods](https://github.com/Project-MONAI/tutorials/tree/main/3d_registration).
921924

922925
## References

src/Readme

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/mirc/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""mirc"""
2+
3+
__version__ = "0.0.1"
Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,29 @@
11
"""
22
example solution for the image registration exercises 3 for module MPHY0025 (IPMI)
33
4-
Jamie McClelland
5-
UCL
4+
Author: Jamie McClelland UCL
5+
Contributors: Zakaria Senousy and Miguel Xochicale UCL-ARC
66
"""
7-
#%%
8-
# set MATPLOTLIB to use qt backend - this will display figures in separate windows and
9-
# is required for the animation to display correctly
107
import matplotlib.pyplot as plt
11-
import demonsReg
8+
from src.mirc.utils.demonsReg import demonsReg
9+
from src.mirc.utils.utils3 import dispImage, dispDefField, calcJacobian
10+
import numpy as np
11+
import skimage.io
1212
#%matplotlib qt
1313

14-
#%%
15-
# Load in the three 2D images required for these exercises using the imread function from the
16-
# scikit-image python library
17-
import skimage.io
1814
cine_MR_img_1 = skimage.io.imread('cine_MR_1.png')
1915
cine_MR_img_2 = skimage.io.imread('cine_MR_2.png')
2016
cine_MR_img_3 = skimage.io.imread('cine_MR_3.png')
2117

2218

23-
#%%
24-
import numpy as np
25-
# ***************
26-
# ADD CODE HERE TO CONVERT ALL THE IMAGES TO DOUBLE DATA TYPE AND TO REORIENTATE THEM
27-
# INTO 'STANDARD ORIENTATION'
2819
cine_MR_img_1 = np.double(cine_MR_img_1)
2920
cine_MR_img_2 = np.double(cine_MR_img_2)
3021
cine_MR_img_3 = np.double(cine_MR_img_3)
3122

3223
cine_MR_img_1 = np.flip(cine_MR_img_1.T, 1)
3324
cine_MR_img_2 = np.flip(cine_MR_img_2.T, 1)
3425
cine_MR_img_3 = np.flip(cine_MR_img_3.T, 1)
35-
# ***************
3626

37-
from utils3 import dispImage
38-
# ***************
39-
# ADD CODE HERE TO DISPLAY EACH IMAGE IN A SEPARATE FIGURE
4027
plt.figure()
4128
dispImage(cine_MR_img_1)
4229
plt.figure()
@@ -47,38 +34,25 @@
4734
dispImage(cine_MR_img_1 - cine_MR_img_2)
4835
plt.figure()
4936
dispImage(cine_MR_img_1 - cine_MR_img_3)
50-
# ***************
5137

52-
#%%
5338
plt.close('all')
5439

55-
from demonsReg import demonsReg
5640

57-
#%%
5841
[warped_image_def, def_field_def] = demonsReg(cine_MR_img_1, cine_MR_img_2)
59-
60-
#%%
6142
[warped_image, def_field] = demonsReg(cine_MR_img_1, cine_MR_img_2, sigma_elastic=0)
62-
63-
#%%
6443
[warped_image, def_field] = demonsReg(cine_MR_img_1, cine_MR_img_2, sigma_fluid=0)
6544

66-
from utils3 import dispDefField
6745
plt.figure()
6846
dispImage(warped_image_def)
6947
plt.figure()
7048
dispDefField(def_field_def, spacing=2)
7149

72-
#%%
7350
[warped_image, def_field] = demonsReg(cine_MR_img_1, cine_MR_img_2, num_lev=1)
7451

75-
#%%
7652
[warped_image, def_field] = demonsReg(cine_MR_img_1, cine_MR_img_2, num_lev=6)
7753

78-
#%%
7954
[warped_image_add, def_field_add] = demonsReg(cine_MR_img_1, cine_MR_img_2, sigma_elastic=0.5)
8055

81-
from utils3 import calcJacobian
8256
[J, J_Mat] = calcJacobian(def_field_add)
8357
plt.figure()
8458
dispImage(J)
@@ -87,9 +61,7 @@
8761
plt.figure()
8862
dispImage(J<=0)
8963

90-
#%%
9164
[warped_image_comp, def_field_comp] = demonsReg(cine_MR_img_1, cine_MR_img_2, sigma_elastic=0.5, use_composition=True)
92-
from utils3 import calcJacobian
9365
[J, J_Mat] = calcJacobian(def_field_comp)
9466
plt.figure()
9567
dispImage(J)
@@ -101,24 +73,18 @@
10173
dispImage(warped_image_add)
10274

10375

104-
#%%
10576
[warped_image, def_field] = demonsReg(cine_MR_img_1, cine_MR_img_2, check_MSD=False, disp_freq=50)
10677

107-
#%%
10878
[warped_image, def_field] = demonsReg(cine_MR_img_1, cine_MR_img_2, check_MSD=False, disp_freq=50, max_it=500)
10979

110-
#%%
11180
[warped_image, def_field] = demonsReg(cine_MR_img_1, cine_MR_img_2, use_target_grad=True)
11281

11382
plt.figure()
11483
dispImage(warped_image_def)
11584
plt.figure()
11685
dispDefField(def_field_def, spacing=2)
11786

118-
#%%
11987
[warped_image, def_field] = demonsReg(cine_MR_img_1, cine_MR_img_3, sigma_elastic=0, sigma_fluid=5, use_composition=True, num_lev=6, disp_freq=0)
120-
#%%
12188
[warped_image, def_field] = demonsReg(cine_MR_img_3, cine_MR_img_1, sigma_elastic=0.6, sigma_fluid=0.5, use_composition=True, num_lev=6, disp_freq=0)
12289

12390

124-
# %%

0 commit comments

Comments
 (0)