1
|
|
|
# Copyright 2014 Diamond Light Source Ltd. |
2
|
|
|
# |
3
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
4
|
|
|
# you may not use this file except in compliance with the License. |
5
|
|
|
# You may obtain a copy of the License at |
6
|
|
|
# |
7
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
8
|
|
|
# |
9
|
|
|
# Unless required by applicable law or agreed to in writing, software |
10
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
11
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12
|
|
|
# See the License for the specific language governing permissions and |
13
|
|
|
# limitations under the License. |
14
|
|
|
|
15
|
|
|
""" |
16
|
|
|
.. module:: tomophantom_loader |
17
|
|
|
:platform: Unix |
18
|
|
|
:synopsis: A full-field tomography loader that creates a NeXus file in \ |
19
|
|
|
NXtomo format and contains tomographic synthetic data generated hdf5 dataset of a \ |
20
|
|
|
specified size. |
21
|
|
|
|
22
|
|
|
.. moduleauthor:: Daniil Kazantsev <[email protected]> |
23
|
|
|
|
24
|
|
|
""" |
25
|
|
|
|
26
|
|
|
import numpy as np |
27
|
|
|
|
28
|
|
|
from savu.plugins.utils import register_plugin |
29
|
|
|
from savu.plugins.loaders.base_tomophantom_loader import BaseTomophantomLoader |
30
|
|
|
from savu.data.data_structures.data_types.data_plus_darks_and_flats \ |
31
|
|
|
import ImageKey |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
@register_plugin |
35
|
|
|
class TomoPhantomLoader(BaseTomophantomLoader): |
36
|
|
|
def __init__(self, name='TomoPhantomLoader'): |
37
|
|
|
super(TomoPhantomLoader, self).__init__(name) |
38
|
|
|
|
39
|
|
|
def setup(self): |
40
|
|
|
data_obj,data_obj2 = super(TomoPhantomLoader, self).setup() |
41
|
|
|
|
42
|
|
|
image_key = self.__set_image_key(data_obj) |
43
|
|
|
data_obj.data = ImageKey(data_obj, image_key, 0) |
44
|
|
|
data_obj.set_shape(data_obj.data.shape) |
45
|
|
|
self.set_data_reduction_params(data_obj) |
46
|
|
|
|
47
|
|
|
data_obj2.set_shape(data_obj2.data.shape) |
48
|
|
|
self.set_data_reduction_params(data_obj2) |
49
|
|
|
|
50
|
|
|
def __set_image_key(self, data_obj): |
51
|
|
|
proj_slice = \ |
52
|
|
|
data_obj.get_data_patterns()['PROJECTION']['slice_dims'][0] |
53
|
|
|
image_key = np.zeros(data_obj.data.shape[proj_slice], dtype=int) |
54
|
|
|
return image_key |
55
|
|
|
|