summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdoardo Pasca <edo.paskino@gmail.com>2018-02-22 15:48:57 +0000
committerEdoardo Pasca <edo.paskino@gmail.com>2018-02-22 15:48:57 +0000
commit7058cd5eb3d5f3f2a0a57d981411cd6707fe2d6b (patch)
tree6a22112bcc0b0c9ec1b75c985a866488fc9db020
parentf884577bb7e3c816438c1cb70aa8b3b260dd9581 (diff)
parent99e5fec9999a5f00e31a567df7dd98cd69e30880 (diff)
downloadframework-7058cd5eb3d5f3f2a0a57d981411cd6707fe2d6b.tar.gz
framework-7058cd5eb3d5f3f2a0a57d981411cd6707fe2d6b.tar.bz2
framework-7058cd5eb3d5f3f2a0a57d981411cd6707fe2d6b.tar.xz
framework-7058cd5eb3d5f3f2a0a57d981411cd6707fe2d6b.zip
Merge branch 'master' of https://github.com/vais-ral/CCPi-ReconstructionFramework
-rw-r--r--Wrappers/Python/ccpi/reconstruction/algs.py2
-rw-r--r--Wrappers/Python/ccpi/reconstruction/ops.py2
-rw-r--r--Wrappers/Python/conda-recipe/build.sh2
-rw-r--r--Wrappers/Python/setup.py2
-rw-r--r--Wrappers/Python/test/DemoRecIP.py6
-rw-r--r--data/IP_data70channels.matbin0 -> 8710147 bytes
-rw-r--r--data/__pycache__/read_IPdata.cpython-35.pycbin0 -> 1674 bytes
-rw-r--r--data/read_IPdata.py58
8 files changed, 65 insertions, 7 deletions
diff --git a/Wrappers/Python/ccpi/reconstruction/algs.py b/Wrappers/Python/ccpi/reconstruction/algs.py
index bfe9570..d957298 100644
--- a/Wrappers/Python/ccpi/reconstruction/algs.py
+++ b/Wrappers/Python/ccpi/reconstruction/algs.py
@@ -20,7 +20,7 @@
import numpy
import time
-from funcs import BaseFunction
+from ccpi.reconstruction.funcs import BaseFunction
def FISTA(x_init, f=None, g=None, opt=None):
diff --git a/Wrappers/Python/ccpi/reconstruction/ops.py b/Wrappers/Python/ccpi/reconstruction/ops.py
index af8ead6..82f18ac 100644
--- a/Wrappers/Python/ccpi/reconstruction/ops.py
+++ b/Wrappers/Python/ccpi/reconstruction/ops.py
@@ -19,7 +19,7 @@
import numpy
from scipy.sparse.linalg import svds
-from framework import DataSet, VolumeData, SinogramData, DataSetProcessor
+from ccpi.framework import DataSet, VolumeData, SinogramData, DataSetProcessor
# Maybe operators need to know what types they take as inputs/outputs
# to not just use generic DataSet
diff --git a/Wrappers/Python/conda-recipe/build.sh b/Wrappers/Python/conda-recipe/build.sh
index 0c6ad30..5dd97b0 100644
--- a/Wrappers/Python/conda-recipe/build.sh
+++ b/Wrappers/Python/conda-recipe/build.sh
@@ -5,5 +5,5 @@ fi
mkdir ${SRC_DIR}/ccpi
cp -r "${RECIPE_DIR}/../../../" ${SRC_DIR}/ccpi
-cd ${SRC_DIR}/ccpi/Wrappers/python
+cd ${SRC_DIR}/ccpi/Wrappers/Python
$PYTHON setup.py install
diff --git a/Wrappers/Python/setup.py b/Wrappers/Python/setup.py
index 8ee6b58..bbd210f 100644
--- a/Wrappers/Python/setup.py
+++ b/Wrappers/Python/setup.py
@@ -35,7 +35,7 @@ if cil_version == '':
setup(
name="ccpi-common",
version=cil_version,
- packages=['ccpi'],
+ packages=['ccpi' , 'ccpi.reconstruction'],
# Project uses reStructuredText, so ensure that the docutils get
# installed or upgraded on the target machine
diff --git a/Wrappers/Python/test/DemoRecIP.py b/Wrappers/Python/test/DemoRecIP.py
index 790e90e..483a202 100644
--- a/Wrappers/Python/test/DemoRecIP.py
+++ b/Wrappers/Python/test/DemoRecIP.py
@@ -8,13 +8,13 @@ import numpy as np
import matplotlib.pyplot as plt
import sys
-sys.path.append('../data/')
+#sys.path.append('../../../data/')
from read_IPdata import read_IPdata
from ccpi.reconstruction.astra_ops import AstraProjector
-from ccpi.reconstruction.funcs import Norm2sq
+from ccpi.reconstruction.funcs import Norm2sq , BaseFunction
from ccpi.reconstruction.algs import FISTA
-from ccpi.reconstruction.ops import BaseFunction
+#from ccpi.reconstruction.funcs import BaseFunction
from ccpi.framework import VolumeData, SinogramData
diff --git a/data/IP_data70channels.mat b/data/IP_data70channels.mat
new file mode 100644
index 0000000..19b9421
--- /dev/null
+++ b/data/IP_data70channels.mat
Binary files differ
diff --git a/data/__pycache__/read_IPdata.cpython-35.pyc b/data/__pycache__/read_IPdata.cpython-35.pyc
new file mode 100644
index 0000000..b062cf9
--- /dev/null
+++ b/data/__pycache__/read_IPdata.cpython-35.pyc
Binary files differ
diff --git a/data/read_IPdata.py b/data/read_IPdata.py
new file mode 100644
index 0000000..2e6a525
--- /dev/null
+++ b/data/read_IPdata.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+function to read IP data and provide a dictionary with data and parameters as an output
+"""
+from scipy import io
+import numpy as np
+from collections import defaultdict
+
+def read_IPdata():
+ # read data from mat file (specify the location)
+ alldata = io.loadmat('IP_data70channels.mat')
+ data_raw = alldata.get('Data_raw') # here is raw projection data
+ Phantom_ideal = alldata.get('Phantom_ideal') # here is 70 channels ideal phantom
+ Photon_flux = alldata.get('Photon_flux') # photon flux for normalization
+ del alldata
+
+ # extract geometry-related parameters
+ proj_numb,detectors_numb,channels = np.shape(data_raw)
+ im_size = np.size(Phantom_ideal,1)
+
+ theta = np.linspace(0,proj_numb-1,proj_numb)*360/proj_numb # projection angles
+ dom_width = 1.0 # width of domain in cm
+ src_to_rotc = 3.0 # dist. from source to rotation center
+ src_to_det = 5.0 # dist. from source to detector
+ det_width = 2.0 # detector width
+
+ # negative log normalisation of the raw data (avoiding of log(0))
+ data_norm = np.zeros(np.shape(data_raw))
+ for i in range(0,channels):
+ slice1 = data_raw[:,:,i]
+ indx = np.nonzero(slice1>0)
+ slice2 = np.zeros((proj_numb,detectors_numb), 'float32')
+ slice2[indx] = -np.log(slice1[indx]/Photon_flux[i])
+ indx2 = np.nonzero(slice1==0)
+ slice3 = np.zeros((proj_numb,detectors_numb), 'float32')
+ slice3[indx2] = np.log(slice2[indx2]+Photon_flux[i])
+ data_norm[:,:,i] = slice2 + slice3
+ del indx, indx2, slice1, slice2, slice3
+ data_norm = np.float32(data_norm*(im_size/dom_width))
+
+ #build a dictionary for data and related parameters
+ dataDICT = defaultdict(list)
+ dataDICT['data_norm'].append(data_norm)
+ dataDICT['data_raw'].append(data_raw)
+ dataDICT['Photon_flux'].append(Photon_flux)
+ dataDICT['Phantom_ideal'].append(Phantom_ideal)
+ dataDICT['theta'].append(theta)
+ dataDICT['proj_numb'].append(proj_numb)
+ dataDICT['detectors_numb'].append(detectors_numb)
+ dataDICT['channels'].append(channels)
+ dataDICT['im_size'].append(im_size)
+ dataDICT['dom_width'].append(dom_width)
+ dataDICT['src_to_rotc'].append(src_to_rotc)
+ dataDICT['src_to_det'].append(src_to_det)
+ dataDICT['det_width'].append(det_width)
+
+ return (dataDICT) \ No newline at end of file