Skip to content

Commit 2e729a4

Browse files
author
hanyoseob
committed
update
2 parents 7e306b5 + 206e95c commit 2e729a4

13 files changed

+98
-211
lines changed

README.md

Lines changed: 67 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,81 @@
1-
# DCGAN
1+
# Parallelbeam CT
22

3-
### Title
4-
[Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks](https://arxiv.org/abs/1511.06434)
3+
### Reference
4+
[Computed Tomography: Principles, Design, Artifacts, and Recent Advances, 3rd.](http://bitly.kr/SOw7Yb1s)
5+
6+
Please read Chapter 3. Image Reconstruction.
57

68
### Abstract
7-
In recent years, supervised learning with convolutional networks (CNNs) has seen huge adoption in computer vision applications. Comparatively, unsupervised learning with CNNs has received less attention. In this work we hope to help bridge the gap between the success of CNNs for supervised learning and unsupervised learning. We introduce a class of CNNs called deep convolutional generative adversarial networks (DCGANs), that have certain architectural constraints, and demonstrate that they are a strong candidate for unsupervised learning. Training on various image datasets, we show convincing evidence that our deep convolutional adversarial pair learns a hierarchy of representations from object parts to scenes in both the generator and discriminator. Additionally, we use the learned features for novel tasks - demonstrating their applicability as general image representations.
8-
9-
## Train
10-
$ python main.py --mode train \
11-
--scope [scope name] \
12-
--name_data [data name] \
13-
--dir_data [data directory] \
14-
--dir_log [log directory] \
15-
--dir_checkpoint [checkpoint directory]
16-
---
17-
$ python main.py --mode train \
18-
--scope dcgan \
19-
--name_data celeba \
20-
--dir_data ./datasets \
21-
--dir_log ./log \
22-
--dir_checkpoint ./checkpoint
9+
X-ray computed tomography (CT) has experienced an explosion of technological development for a quarter century. Six years after the second edition of Computed Tomography, this third edition captures the most recent advances in technology and clinical applications. New to this edition are descriptions of iterative reconstruction, statistical reconstruction, methodologies used to model the CT systems, and the searching methodologies for optimal solutions. A new section on 3D printing introduces approaches by early adopters in the area. Also added is a description and discussion of the size-specific dose estimate, an index that attempts to more accurately reflect the dose absorption of specific-sized patients. The coverage of dual-energy CT has been significantly expanded to include its background, theoretical development, and clinical applications.
10+
11+
## Projection
12+
* Projection operator is implemented based on Ch.3 Equations (3.5) & (3.6).
13+
* Ray-driven method is applied to Projection operator.
14+
15+
* Ch.3 Equation (3.5): `Rotated coordinate` X-ray CT system (`Counterclockwise`).
16+
* ![eq-t-axis](http://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cbg_white%20%5Cfn_cm%20%5Clarge%20t%20%3D%20x%20%5Ccos%28%5Ctheta%29%20+%20y%20%5Csin%28%5Ctheta%29)
17+
* ![eq-s-axis](http://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cbg_white%20%5Cfn_cm%20%5Clarge%20s%20%3D%20-x%20%5Csin%28%5Ctheta%29%20+%20y%20%5Ccos%28%5Ctheta%29)
2318

24-
* Set **[scope name]** uniquely.
25-
* Hyperparameters were written to **arg.txt** under the **[log directory]**.
26-
* To understand hierarchy of directories based on their arguments, see **directories structure** below.
19+
* Ch.3 Equation (3.6): `Line integration` along X-ray.
20+
* ![eq-line-integration](http://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cbg_white%20%5Cfn_cm%20%5Clarge%20p%28t%2C%5Ctheta%29%20%3D%20%5Cint_%7B-%5Cinfty%7D%5E%7B+%5Cinfty%7Df%27%28t%2Cs%29%20ds)
2721

28-
## Test
29-
$ python main.py --mode test \
30-
--scope [scope name] \
31-
--name_data [data name] \
32-
--dir_data [data directory] \
33-
--dir_log [log directory] \
34-
--dir_checkpoint [checkpoint directory] \
35-
--dir_result [result directory]
36-
---
37-
$ python main.py --mode test \
38-
--scope dcgan \
39-
--name_data celeba \
40-
--dir_data ./datasets \
41-
--dir_log ./log \
42-
--dir_checkpoint ./checkpoints \
43-
--dir_result ./results
22+
## Filtering
23+
* Filtering operator is implemented based on Ch.3 Equations (3.21) & (3.29) & (3.30).
4424

45-
* To test using trained network, set **[scope name]** defined in the **train** phase.
46-
* Generated images are saved in the **images** subfolder along with **[result directory]** folder.
47-
* **index.html** is also generated to display the generated images.
25+
* Ch.3 Equation (3.29): `Filtering kernel`
26+
* ![eq-filtering-kernel](http://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cbg_white%20%5Cfn_cm%20%5Clarge%20h%28n%5Cdelta%29%20%3D%20%5Cleft%5C%7B%5Cbegin%7Bmatrix%7D%20%5Cfrac%7B1%7D%7B4%5Cdelta%5E2%7D%2C%20%26%20n%3D0%2C%7E%7E%7E%5C%5C%200%2C%20%26%20n%3Deven%2C%5C%5C%20-%20%5Cfrac%7B1%7D%7B%28n%5Cpi%5Cdelta%29%5E2%7D%20%2C%20%26%20n%3Dodd.%7E%20%5Cend%7Bmatrix%7D%5Cright.)
27+
28+
* Filtering is performed by `convolution ver.` using Ch.3 Equation (3.30) and `FFT ver.` using Equation (3.21).
29+
* Ch.3 Equation (3.30): `convolution ver.`
30+
* ![eq-convolution](http://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cbg_white%20%5Cfn_cm%20%5Clarge%20f%28x%2Cy%29%3D%5Cint_%7B0%7D%5E%7B%5Cpi%7Dd%5Ctheta%5Cint_%7B-t_%7Bm%7D%7D%5E%7B+t_%7Bm%7D%7D%7Bp%28t%27%2C%20%5Ctheta%29h%28t-t%27%29dt%27%7D)
31+
* Ch.3 Equation (3.21): `FFT ver.`
32+
* ![eq-FFT](http://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cbg_white%20%5Cfn_cm%20%5Clarge%20g%28t%2C%5Ctheta%29%20%3D%20g%28x%20%5Ccos%28%5Ctheta%29%20+%20y%20%5Csin%28%5Ctheta%29%29%20%5C%5C%5C%5C%20%7E%7E%7E%7E%7E%7E%7E%7E%7E%7E%7E%7E%7E%3D%20%5Cint_%7B-%5Cinfty%7D%5E%7B+%5Cinfty%7DP%28%5Comega%2C%5Ctheta%29%7C%5Comega%7C%20e%5E%7Bj2%5Cpi%5Comega%28x%5Ccos%28%5Ctheta%29%20+%20y%20%5Csin%28%5Ctheta%29%29%7D%20d%5Comega)
4833

34+
## Backprojection
35+
* Backprojection operator is implemented based on Ch.3 Equation (3.22).
36+
* Pixel-driven method is applied to backprojection operator.
4937

50-
## Tensorboard
51-
$ tensorboard --logdir [log directory]/[scope name]/[data name] \
52-
--port [(optional) 4 digit port number]
53-
---
54-
$ tensorboard --logdir ./log/dcgan/celeba \
55-
--port 6006
56-
57-
After the above comment executes, go **http://localhost:6006**
38+
* Ch.3 Equation (3.22): `Backprojection`
39+
* ![eq-backprojection](http://latex.codecogs.com/gif.latex?%5Cdpi%7B150%7D%20%5Cbg_white%20%5Cfn_cm%20%5Clarge%20f%28x%2C%20y%29%20%3D%5Cint_%7B0%7D%5E%7B%5Cpi%7Dg%28x%20%5Ccos%28%5Ctheta%29%20+%20y%5Csin%28%5Ctheta%29%29d%5Ctheta)
40+
41+
## Parameters
42+
* X-ray CT System parameters
43+
1. dAngle `[degree]` : Rotational range of X-ray source
44+
2. nView `[unit]` : The number of views
45+
3. dView `[degree]` : The step of views
46+
4. DSO `[mm]` : Distance from Source to Object
47+
5. DSD `[mm]` : Distance from Source to Detector
5848

59-
* You can change **[(optional) 4 digit port number]**.
60-
* Default 4 digit port number is **6006**.
49+
* X-ray detector parameters
50+
1. dDctX `[mm]` : Detector pitch
51+
2. nDctX `[unit]` : The number of detectors
52+
3. dOffsetDctX `[float]` : Index of shifted detectors (+, -)
53+
4. compute_filtering `[convolution, fft]` : Filtering method
54+
55+
* Object parameters
56+
1. dImgX, dImgY `[mm]` : Pixel resolutions
57+
2. nImgX, nImgY `[unit]` : The number of pixels
58+
3. dOffsetImgX, dOffsetImgY `[float]` : Index of shifted image (+, -)
6159

6260

6361
## Results
64-
![alt text](./img/generated_images.png "Generated Images by DCGAN")
65-
* The results were generated by a network trained with **celeba** dataset during **10 epochs**.
66-
* After the Test phase runs, execute **display_result.py** to display the figure.
67-
68-
## Directories structure
69-
pytorch-DCGAN
70-
+---[dir_checkpoint]
71-
| \---[scope]
72-
| \---[name_data]
73-
| +---model_epoch00000.pth
74-
| | ...
75-
| \---model_epoch12345.pth
76-
+---[dir_data]
77-
| \---[name_data]
78-
| +---000000.png
79-
| | ...
80-
| \---12345.png
81-
+---[dir_log]
82-
| \---[scope]
83-
| \---[name_data]
84-
| +---arg.txt
85-
| \---events.out.tfevents
86-
\---[dir_result]
87-
\---[scope]
88-
\---[name_data]
89-
+---images
90-
| +---00000-output.png
91-
| | ...
92-
| +---12345-output.png
93-
\---index.html
62+
![alt text](./img/reconstruction_image.png "Reconstructed image using parallel beam CT")
63+
* The results were reconstructed by below hyper parameters.
9464

95-
---
65+
* X-ray CT System parameters
66+
1. dAngle `[degree]` : 360
67+
2. nView `[unit]` : 360
68+
3. dView `[degree]` : 1
69+
4. DSO `[mm]` : 400
70+
5. DSD `[mm]` : 800
9671

97-
pytorch-DCGAN
98-
+---checkpoints
99-
| \---dcgan
100-
| \---celeba
101-
| +---model_epoch00001.pth
102-
| | ...
103-
| \---model_epoch0010.pth
104-
+---datasets
105-
| \---celeba
106-
| +---000001.jpg
107-
| | ...
108-
| \---202599.jpg
109-
+---log
110-
| \---dcgan
111-
| \---celeba
112-
| +---arg.txt
113-
| \---events.out.tfevents
114-
\---results
115-
\---dcgan
116-
\---celeba
117-
+---images
118-
| +---0000-output.png
119-
| | ...
120-
| +---0127-output.png
121-
\---index.html
122-
123-
* Above directory is created by setting arguments when **main.py** is executed.
124-
72+
* X-ray detector parameters
73+
1. dDctX `[mm]` : 0.7
74+
2. nDctX `[unit]` : 400
75+
3. dOffsetDctX `[float]` : 30
76+
4. compute_filtering `[convolution, fft]` : 'fft'
77+
78+
* Object parameters
79+
1. dImgX, dImgY `[mm]` : 1, 1
80+
2. nImgX, nImgY `[unit]` : 256, 256
81+
3. dOffsetImgX, dOffsetImgY `[float]` : 0, 0

lib/backprojection.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% Please read the Ch.3 Image Reconstruction
22

3-
% Implementation for backprojection operator based on Ch. 3 Equation (3.22)
3+
% Implementation for backprojection operator based on Ch.3 Equation (3.22)
44
% Backprojection operator is implemented using pixel-driven method
55
function pdX = backprojection(pdY, param, bfig)
66

@@ -15,7 +15,7 @@
1515
pdX = zeros(param.nImgY, param.nImgX, 'like', pdY);
1616
dCurX = zeros(param.nImgY, param.nImgX, 'like', pdY);
1717

18-
% Ch. 3 Equation (3.22)
18+
% Ch.3 Equation (3.22)
1919
% Backprojection operator
2020
for iview = 0:param.nView-1
2121

lib/filterProjections.m

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

lib/filtering.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
% Please read the Ch. 3 Image Reconstruction
1+
% Please read the Ch.3 Image Reconstruction
22

3+
<<<<<<< HEAD
34
% Implementation for filtering operator based on Ch. 3 Equation (3.28) & (3.29) & (3.30)
5+
=======
6+
% Implementation for filtering operator based on Ch.3 Equation (3.21) & (3.29) & (3.30)
7+
>>>>>>> 206e95ca49e73ad10a88f9d5bfb7f4c016b5c83c
48
% Filtering operator is implemented by both convolution and FFT versions.
59
function [pdFltY, pdFlt] = filtering(pdY, param)
610

@@ -18,7 +22,7 @@
1822
end
1923

2024
case 'fft'
21-
% Ch.3 Equation (3.28)
25+
% Ch.3 Equation (3.21)
2226
% FFT ver.
2327
pdFltY_ = zeros(param.nDctX, 1);
2428

lib/generate_filter.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
1+
% Ch.3 Equation (3.29)
2+
% Generate filter kernel
23
function pdFlt = generate_filter(d, n)
34

45
pdFlt = zeros(2*n - 1, 1);

lib/id2pos.m

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

lib/pos2id.m

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

lib/projection.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
pdY = zeros(param.nDctX, param.nView, 'like', pdX);
2525

26-
% Ch. 3 Equation (3.6)
26+
% Ch.3 Equation (3.6)
2727
% Projection operator
2828
for iview = 0:param.nView-1
2929

@@ -55,7 +55,7 @@
5555
dCurY = 0;
5656

5757

58-
% Ch. 3 Equation (3.6)
58+
% Ch.3 Equation (3.6)
5959
% Line Integration along the s-axis
6060
for ismp = 0:nSample-1
6161

lib/convolution1d.m renamed to util/convolution1d.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
y(i+1) = y(i+1) + ker(((n-1) + i+1) - (j+1) + 1)*x(j+1);
88
end
99
end
10+
1011
end

util/id2pos.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
% Transform from Index in [0, nDct] to Position in [-(dDct*nDct)/2, +(dDct*nDct)/2]
2+
function pos = id2pos(id, d, n)
3+
4+
pos = (id - (n - 1)/2)*d;
5+
6+
end

0 commit comments

Comments
 (0)