1
|
|
|
def nInput_datasets(self): |
2
|
|
|
# Called immediately after the plugin is loaded in to the framework |
3
|
|
|
return 1 |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
def nOutput_datasets(self): |
7
|
|
|
# Called immediately after the plugin is loaded in to the framework |
8
|
|
|
return 1 |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
def setup(self): |
12
|
|
|
# This method is called after the number of in/out datasets associated |
13
|
|
|
# with the plugin has been established. It tells the framework all |
14
|
|
|
# the information it needs to know about the data transport to-and-from |
15
|
|
|
# the plugin. |
16
|
|
|
|
17
|
|
|
# ================== Input and output datasets ========================= |
18
|
|
|
# in_datasets and out_datasets are instances of the Data class. |
19
|
|
|
# in_datasets were either created in the loader or as output from |
20
|
|
|
# previous plugins. out_datasets objects have already been created at |
21
|
|
|
# this point, but they are empty and need to be populated. |
22
|
|
|
|
23
|
|
|
# Get the Data instances associated with this plugin |
24
|
|
|
in_dataset, out_dataset = self.get_datasets() |
25
|
|
|
|
26
|
|
|
# see https://savu.readthedocs.io/en/latest/api/savu.data.data_structures.data_create/ |
27
|
|
|
# for more information on creating datasets. |
28
|
|
|
|
29
|
|
|
# Populate the output dataset(s) |
30
|
|
|
out_dataset[0].create_dataset(in_dataset[0]) |
31
|
|
|
|
32
|
|
|
# ================== Input and output plugin datasets ================== |
33
|
|
|
# in_pData and out_pData are instances of the PluginData class. |
34
|
|
|
# All in_datasets and out_datasets above have an in/out_pData object |
35
|
|
|
# attached to them temporarily for the duration of the plugin, |
36
|
|
|
# giving access to additional plugin-specific dataset details. At this |
37
|
|
|
# point they have been created but not yet populated. |
38
|
|
|
|
39
|
|
|
# Get the PluginData instances attached to the Data instances above |
40
|
|
|
in_pData, out_pData = self.get_plugin_datasets() |
41
|
|
|
|
42
|
|
|
# Each plugin dataset must call this method and define the data access |
43
|
|
|
# pattern and number of frames required. |
44
|
|
|
in_pData[0].plugin_data_setup('SINOGRAM', 'single') |
45
|
|
|
|
46
|
|
|
# 'single', 'multiple' or an int (should only be used if essential) |
47
|
|
|
out_pData[0].plugin_data_setup('SINOGRAM', 'single') |
48
|
|
|
|
49
|
|
|
# All dataset information can be accessed via the Data and PluginData |
50
|
|
|
# instances |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
def pre_process(self): |
54
|
|
|
# This method is called once before any processing has begun. |
55
|
|
|
# Access parameters from the doc string in the parameters dictionary |
56
|
|
|
# e.g. self.parameters['example'] |
57
|
|
|
pass |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
def process_frames(self, data): |
61
|
|
|
# This function is called in a loop by the framework until all the |
62
|
|
|
# data has been processed. |
63
|
|
|
|
64
|
|
|
# Each iteration of the loop will receive a list of numpy arrays |
65
|
|
|
# (data) containing nInput_datasets with the data sliced as requested |
66
|
|
|
# in the setup method (SINOGRAM in this case). If 'multiple' or an |
67
|
|
|
# integer number of max_frames are requested the array with have an |
68
|
|
|
# extra dimension. |
69
|
|
|
|
70
|
|
|
# This plugin has one output dataset, so a single numpy array (a |
71
|
|
|
# SINOGRAM in this case) should be returned to the framework. |
72
|
|
|
return data[0] |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
def post_process(self): |
76
|
|
|
# This method is called once after all processing has completed |
77
|
|
|
# (after an MPI barrier). |
78
|
|
|
pass |
79
|
|
|
|
80
|
|
|
|