Code Duplication    Length = 34-34 lines in 2 locations

savu/plugins/centering/centering360.py 1 location

@@ 385-418 (lines=34) @@
382
        for name in datasets:
383
            self.exp.index['in_data'][name].meta_data.set(key, value)
384
385
    def setup(self):
386
        self.exp.log(self.name + " Start calculating center of rotation")
387
        # set up the output dataset that is created by the plugin
388
        in_dataset, out_dataset = self.get_datasets()
389
        in_pData, out_pData = self.get_plugin_datasets()
390
        in_pData[0].plugin_data_setup('SINOGRAM', self.get_max_frames())
391
        slice_dirs = list(in_dataset[0].get_slice_dimensions())
392
        self.orig_full_shape = in_dataset[0].get_shape()
393
394
        # reduce the data as per data_subset parameter
395
        self.set_preview(in_dataset[0], self.parameters['preview'])
396
        total_frames = \
397
            self._calc_total_frames(in_dataset[0].get_preview(), slice_dirs)
398
399
        # copy all required information from in_dataset[0]
400
        fullData = in_dataset[0]
401
        new_shape = (np.prod(np.array(fullData.get_shape())[slice_dirs]), 1)
402
        self.orig_shape = \
403
            (np.prod(np.array(self.orig_full_shape)[slice_dirs]), 1)
404
        out_dataset[0].create_dataset(shape=new_shape,
405
                                      axis_labels=['x.pixels', 'y.pixels'],
406
                                      remove=True,
407
                                      transport='hdf5')
408
        out_dataset[0].add_pattern("METADATA", core_dims=(1,), slice_dims=(0,))
409
410
        out_dataset[1].create_dataset(shape=self.orig_shape,
411
                                      axis_labels=['x.pixels', 'y.pixels'],
412
                                      remove=True,
413
                                      transport='hdf5')
414
        out_dataset[1].add_pattern("METADATA", core_dims=(1,), slice_dims=(0,))
415
        out_pData[0].plugin_data_setup('METADATA', self.get_max_frames())
416
        out_pData[1].plugin_data_setup('METADATA', self.get_max_frames())
417
        out_pData[1].meta_data.set('fix_total_frames', total_frames)
418
        self.exp.log(self.name + " End")
419
420
    def _calc_total_frames(self, preview, slice_dims):
421
        starts, stops, steps, _ = preview.get_starts_stops_steps()

savu/plugins/centering/vo_centering.py 1 location

@@ 265-298 (lines=34) @@
262
        for name in datasets:
263
            self.exp.index['in_data'][name].meta_data.set(key, value)
264
265
    def setup(self):
266
        self.exp.log(self.name + " Start calculating center of rotation")
267
        # set up the output dataset that is created by the plugin
268
        in_dataset, out_dataset = self.get_datasets()
269
        in_pData, out_pData = self.get_plugin_datasets()
270
        in_pData[0].plugin_data_setup('SINOGRAM', self.get_max_frames())
271
        slice_dirs = list(in_dataset[0].get_slice_dimensions())
272
        self.orig_full_shape = in_dataset[0].get_shape()
273
274
        # reduce the data as per data_subset parameter
275
        self.set_preview(in_dataset[0], self.parameters['preview'])
276
        total_frames = \
277
            self._calc_total_frames(in_dataset[0].get_preview(), slice_dirs)
278
279
        # copy all required information from in_dataset[0]
280
        fullData = in_dataset[0]
281
        new_shape = (np.prod(np.array(fullData.get_shape())[slice_dirs]), 1)
282
        self.orig_shape = \
283
            (np.prod(np.array(self.orig_full_shape)[slice_dirs]), 1)
284
        out_dataset[0].create_dataset(shape=new_shape,
285
                                      axis_labels=['x.pixels', 'y.pixels'],
286
                                      remove=True,
287
                                      transport='hdf5')
288
        out_dataset[0].add_pattern("METADATA", core_dims=(1,), slice_dims=(0,))
289
290
        out_dataset[1].create_dataset(shape=self.orig_shape,
291
                                      axis_labels=['x.pixels', 'y.pixels'],
292
                                      remove=True,
293
                                      transport='hdf5')
294
        out_dataset[1].add_pattern("METADATA", core_dims=(1,), slice_dims=(0,))
295
        out_pData[0].plugin_data_setup('METADATA', self.get_max_frames())
296
        out_pData[1].plugin_data_setup('METADATA', self.get_max_frames())
297
        out_pData[1].meta_data.set('fix_total_frames', total_frames)
298
        self.exp.log(self.name + " End")
299
300
    def _calc_total_frames(self, preview, slice_dims):
301
        starts, stops, steps, _ = preview.get_starts_stops_steps()