Code Duplication    Length = 15-18 lines in 2 locations

savu/plugins/corrections/auto_crop_estimate.py 1 location

@@ 49-66 (lines=18) @@
46
    def __init__(self):
47
        super(AutoCropEstimate, self).__init__("AutoCropEstimate")
48
49
    def setup(self):
50
        # set up the output dataset that is created by the plugin
51
        in_dataset, out_dataset = self.get_datasets()
52
        # set information relating to the plugin data
53
        in_pData, out_pData = self.get_plugin_datasets()
54
        in_pData[0].plugin_data_setup('PROJECTION', self.get_max_frames())
55
        self.orig_full_shape = in_dataset[0].get_shape() # includes flats/darks/projections
56
57
        fullData = in_dataset[0]
58
        slice_dirs = list(in_dataset[0].get_slice_dimensions())
59
        self.new_shape = (np.prod(np.array(fullData.get_shape())[slice_dirs]), 4)
60
61
        out_dataset[0].create_dataset(shape=self.new_shape ,
62
                                      axis_labels=['x.pixels', 'y.pixels'],
63
                                      remove=True,
64
                                      transport='hdf5')
65
        out_dataset[0].add_pattern("METADATA", core_dims=(1,), slice_dims=(0,))
66
        out_pData[0].plugin_data_setup('METADATA', self.get_max_frames())
67
68
    def process_frames(self, data):        
69
        proj2D = data[0] # get 2D projection image [DetectorHoriz, DetectorVert]        

savu/plugins/simulation/tomo_phantom_quantification.py 1 location

@@ 36-50 (lines=15) @@
33
    def __init__(self):
34
        super(TomoPhantomQuantification, self).__init__("TomoPhantomQuantification")
35
36
    def setup(self):
37
        in_dataset, out_dataset = self.get_datasets()
38
        in_pData, out_pData = self.get_plugin_datasets()
39
        in_pData[0].plugin_data_setup('VOLUME_XZ', 'single')
40
        in_pData[1].plugin_data_setup('VOLUME_XZ', 'single')
41
42
        fullData = in_dataset[0]
43
        slice_dirs = list(in_dataset[0].get_slice_dimensions())
44
        self.new_shape = (np.prod(np.array(fullData.get_shape())[slice_dirs]), 1)
45
        out_dataset[0].create_dataset(shape=self.new_shape,
46
                                      axis_labels=['quantval', 'value'],
47
                                      remove=True,
48
                                      transport='hdf5')
49
        out_dataset[0].add_pattern("METADATA", core_dims=(1,), slice_dims=(0,))
50
        out_pData[0].plugin_data_setup('METADATA', self.get_max_frames())
51
52
    def process_frames(self, data):
53
        data_temp1 = data[0]