mock.py 23.6 KB
Newer Older
payno's avatar
payno committed
1
2
# coding: utf-8
#/*##########################################################################
3
# Copyright (C) 2016 European Synchrotron Radiation Facility
payno's avatar
payno committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#############################################################################*/
"""
Utils to mock scans
"""

__authors__ = ["H. Payno"]
__license__ = "MIT"
30
__date__ = "30/09/2019"
payno's avatar
payno committed
31
32
33
34
35
36
37

import h5py
import numpy
import os
from xml.etree import cElementTree
import fabio
import fabio.edfimage
38
from .hdf5scan import ImageKey, HDF5TomoScan
payno's avatar
payno committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52


class _ScanMock:
    """Base class to mock as scan (radios, darks, refs, reconstructions...)"""

    PIXEL_SIZE = 0.457

    def __init__(self, scan_path, n_radio, n_ini_radio=None, n_extra_radio=0,
                 scan_range=360, n_recons=0, n_pag_recons=0, recons_vol=False,
                 dim=200, ref_n=0, dark_n=0, scene='noise'):
        """

        :param scan_path:
        :param n_radio:
53
        :param n_ini_radio:
payno's avatar
payno committed
54
55
56
57
58
59
60
61
62
63
        :param n_extra_radio:
        :param scan_range:
        :param n_recons:
        :param n_pag_recons:
        :param recons_vol:
        :param dim:
        :param ref_n:
        :param dark_n:
        :param str scene: scene type.
                          * 'noise': generate radios from numpy.random
64
65
                          * `increase value`: first frame value will be0, then second 1...
                          * `arange`: arange through frames
payno's avatar
payno committed
66
67
68
69
70
71
72
73
74
75
                          * 'perfect-sphere: generate a sphere which just fit in the
                          detector dimensions
        TODO: add some differente scene type.
        """
        self.det_width = dim
        self.det_height = dim
        self.scan_path = scan_path
        self.n_radio = n_radio
        self.scene = scene

76
77
78
        if not os.path.exists(scan_path):
            os.mkdir(scan_path)

payno's avatar
payno committed
79
80
81
        self.write_metadata(n_radio=n_radio, scan_range=scan_range,
                            ref_n=ref_n, dark_n=dark_n)

Pierre Paleo's avatar
Pierre Paleo committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
        if n_ini_radio is None:
            n_ini_radio = n_radio + n_extra_radio
            call_acqui_end = True
        else:
            call_acqui_end = False

        for i_radio in range(n_ini_radio):
            self.add_radio(i_radio)
        for i_extra_radio in range(n_extra_radio):
            self.add_radio(n_radio+i_extra_radio)
        for i_recons in range(n_recons):
            self.add_reconstruction(i_recons)
        for i_recons in range(n_pag_recons):
            self.add_pag_reconstruction(i_recons)
        if recons_vol is True:
            self.add_recons_vol()

        if call_acqui_end is True:
            self.end_acquisition()

payno's avatar
payno committed
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
    def add_radio(self, index=None):
        raise NotImplementedError('Base class')

    def add_reconstruction(self, index=None):
        raise NotImplementedError('Base class')

    def add_pag_reconstruction(self, index=None):
        raise NotImplementedError('Base class')

    def add_recons_vol(self):
        raise NotImplementedError('Base class')

    def write_metadata(self, n_radio, scan_range, ref_n, dark_n):
        raise NotImplementedError('Base class')

    def end_acquisition(self):
        raise NotImplementedError('Base class')

    def _get_radio_data(self, index):
        if self.scene == 'noise':
            return numpy.random.random((self.det_height * self.det_width)).reshape((self.det_width, self.det_height))
123
124
125
126
127
128
        elif self.scene == 'increasing value':
            return numpy.zeros((self.det_width, self.det_height)) + index
        elif self.scene == 'arange':
            start = index * (self.det_height * self.det_width)
            stop = (index + 1) * (self.det_height * self.det_width)
            return numpy.arange(start=start, stop=stop).reshape(self.det_width, self.det_height)
payno's avatar
payno committed
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
        elif self.scene == 'perfect-sphere':
            background = numpy.zeros((self.det_height * self.det_width))
            radius = min(background.shape)

            def _compute_radius_to_center(data):
                assert data.ndim is 2
                xcenter = (data.shape[2]) // 2
                ycenter = (data.shape[1]) // 2
                y, x = numpy.ogrid[:data.shape[0], :data.shape[1]]
                r = numpy.sqrt((x - xcenter) ** 2 + (y - ycenter) ** 2)
                return r

            radii = _compute_radius_to_center(background)
            scale = 1
            background[radii < radius * scale] = 1.0
            return background
145
146
        else:
            raise ValueError('selected scene %s is no managed' % self.scene)
payno's avatar
payno committed
147
148


Pierre Paleo's avatar
Pierre Paleo committed
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
class MockHDF5(_ScanMock):
    """
    Mock an acquisition in a hdf5 file.

    note: for now the Mock class only manage one initial ref and one final
    """
    _PROJ_COUNT = 1

    def __init__(self, scan_path, n_proj, n_ini_proj=None, n_alignement_proj=0,
                 scan_range=360, n_recons=0, n_pag_recons=0, recons_vol=False,
                 dim=200, create_ini_dark=True, create_ini_ref=True,
                 create_final_ref=False, n_refs=10):
        """

        :param scan_path: directory of the file containing the hdf5 acquisition
        :param n_proj: number of projections (does not contain alignement proj)
        :param n_ini_proj: number of projection do add in the constructor
        :param n_alignement_proj: number of alignment projection
        :param int scan_range:
        :param n_recons:
        :param n_pag_recons:
        :param recons_vol:
        :param dim: frame dim - only manage square fame for now
        :param create_ini_dark: create one initial dark frame on construction
        :param create_ini_ref: create the initial serie of ref (n_ref) on
                               construction (after creation of the dark)
        :param create_final_ref: create the final serie of ref (n_ref) on
                               construction (after creation of the dark)
        :param n_refs: number of refs per serie
        """
        self.rotation_angle = numpy.linspace(start=0, stop=scan_range,
                                             num=n_proj + 1)
        self.rotation_angle_return = numpy.linspace(start=scan_range, stop=0,
                                                    num=n_alignement_proj)
        self.scan_master_file = os.path.join(scan_path, os.path.basename((scan_path)) + '.h5')
        self._n_refs = n_refs
        self.scan_entry = 'entry'

        super(MockHDF5, self).__init__(scan_path=scan_path, n_radio=n_proj,
                                       n_ini_radio=n_ini_proj,
                                       n_extra_radio=n_alignement_proj,
                                       scan_range=scan_range,
                                       n_recons=n_recons,
                                       n_pag_recons=n_pag_recons,
                                       recons_vol=recons_vol, dim=dim)
        if create_ini_dark:
            self.add_initial_dark()
        if create_ini_ref:
            self.add_initial_ref()
        if n_ini_proj is not None:
            for i_radio in range(n_ini_proj):
                self.add_radio(index=i_radio)
        if create_final_ref:
            self.add_final_ref()
        self.scan = HDF5TomoScan(scan=self.scan_master_file, entry='entry')

    def add_initial_dark(self):
        dark = numpy.random.random((self.det_height * self.det_width)).reshape(
            (1, self.det_width, self.det_height))
        self._append_frame(data_=dark,
                           rotation_angle=self.rotation_angle[-1],
                           image_key=ImageKey.DARK_FIELD.value,
                           image_key_control=ImageKey.DARK_FIELD.value)

    def add_initial_ref(self):
        for i in range(self._n_refs):
            flat = numpy.random.random((self.det_height * self.det_width)).reshape(
                (1, self.det_width, self.det_height))
            self._append_frame(data_=flat,
                               rotation_angle=self.rotation_angle[0],
                               image_key=ImageKey.FLAT_FIELD.value,
                               image_key_control=ImageKey.FLAT_FIELD.value)

    def add_final_ref(self):
        for i in range(self._n_refs):
            flat = numpy.random.random((self.det_height * self.det_width)).reshape(
                (1, self.det_width, self.det_height))
            self._append_frame(data_=flat,
                               rotation_angle=self.rotation_angle[-1],
                               image_key=ImageKey.FLAT_FIELD.value,
                               image_key_control=ImageKey.FLAT_FIELD.value)

    def add_radio(self, index=None):
        radio = self._get_radio_data(index=index)
        radio = radio.reshape((1, self.det_height, self.det_width))
        self._append_frame(data_=radio,
                           rotation_angle=self.rotation_angle[index],
                           image_key=ImageKey.PROJECTION.value,
                           image_key_control=ImageKey.PROJECTION.value)

    def add_alignment_radio(self, index, angle):
        radio = self._get_radio_data(index=index)
        radio = radio.reshape((1, self.det_height, self.det_width))
        self._append_frame(data_=radio,
                           rotation_angle=angle,
                           image_key=ImageKey.PROJECTION.value,
                           image_key_control=ImageKey.ALIGNMENT.value)

    def _append_frame(self, data_, rotation_angle, image_key,
                      image_key_control):

        with h5py.File(self.scan_master_file, 'r+') as h5_file:
            entry_one = h5_file.require_group(self.scan_entry)
            instrument_grp = entry_one.require_group('instrument')
            detector_grp = instrument_grp.require_group('detector')
            sample_grp = entry_one.require_group('sample')

            # add data
            if 'data' in detector_grp:
                # read and remove data
                current_dataset = detector_grp['data'][()]
                new_dataset = numpy.append(current_dataset, data_)
                del detector_grp['data']
                shape = list(current_dataset.shape)
                shape[0] += 1
                new_dataset = new_dataset.reshape(shape)
            else:
                new_dataset = data_

            # add rotation angle
            if 'rotation_angle' in sample_grp:
                new_rot_angle = sample_grp['rotation_angle'][()]
                new_rot_angle = numpy.append(new_rot_angle, rotation_angle)
                del sample_grp['rotation_angle']
            else:
                new_rot_angle = [rotation_angle, ]

            # add image_key
            if 'image_key' in detector_grp:
                new_image_key = detector_grp['image_key'][()]
                new_image_key = numpy.append(new_image_key,
                                             image_key)
                del detector_grp['image_key']
            else:
                new_image_key = [image_key, ]

            # add image_key_control
            if 'image_key_control' in detector_grp:
                new_image_key_control = detector_grp['image_key_control'][()]
                new_image_key_control = numpy.append(new_image_key_control, image_key_control)
                del detector_grp['image_key_control']
            else:
                new_image_key_control = [image_key_control, ]

            # add count_time
            if 'count_time' in detector_grp:
                new_count_time = detector_grp['count_time'][()]
                new_count_time = numpy.append(new_count_time, self._PROJ_COUNT)
                del detector_grp['count_time']
            else:
                new_count_time = [self._PROJ_COUNT, ]

        with h5py.File(self.scan_master_file, 'a') as h5_file:
            entry_one = h5_file.require_group(self.scan_entry)
            instrument_grp = entry_one.require_group('instrument')
            if 'NX_class' not in instrument_grp.attrs:
                instrument_grp.attrs['NX_class'] = 'NXinstrument'
            detector_grp = instrument_grp.require_group('detector')
            if 'NX_class' not in detector_grp.attrs:
                detector_grp.attrs['NX_class'] = 'NXdetector'
            sample_grp = entry_one.require_group('sample')
            if 'NX_class' not in sample_grp.attrs:
                sample_grp.attrs['NX_class'] = 'NXsample'
            # write camera information
            detector_grp['data'] = new_dataset
            detector_grp['image_key'] = new_image_key
            detector_grp['image_key_control'] = new_image_key_control
            detector_grp['count_time'] = new_count_time
            # write sample information
            sample_grp['rotation_angle'] = new_rot_angle

    def write_metadata(self, n_radio, scan_range, ref_n, dark_n):
        with h5py.File(self.scan_master_file, 'a') as h5_file:
            entry_one = h5_file.require_group(self.scan_entry)
            instrument_grp = entry_one.require_group('instrument')
            detector_grp = instrument_grp.require_group('detector')
            sample_grp = entry_one.require_group('sample')

            entry_one.attrs["NX_class"] = u"NXentry"
            entry_one.attrs["definition"] = u"NXtomo"
            if 'size' not in detector_grp:
                detector_grp['size'] = (self.det_width, self.det_height)
            if 'x_pixel_size' not in detector_grp:
                detector_grp['x_pixel_size'] = _ScanMock.PIXEL_SIZE
            if 'y_pixel_size' not in detector_grp:
                detector_grp['y_pixel_size'] = _ScanMock.PIXEL_SIZE

    def end_acquisition(self):
        # no specific operation to do
        pass

payno's avatar
payno committed
340
341
342


class MockEDF(_ScanMock):
343
344
    """Mock a EDF acquisition
    """
payno's avatar
payno committed
345

346
    _RECONS_PATTERN = '_slice_'
payno's avatar
payno committed
347

348
    _PAG_RECONS_PATTERN = '_slice_pag_'
payno's avatar
payno committed
349
350
351

    def __init__(self, scan_path, n_radio, n_ini_radio=None, n_extra_radio=0,
                 scan_range=360, n_recons=0, n_pag_recons=0, recons_vol=False,
352
                 dim=200, scene='noise'):
payno's avatar
payno committed
353
        self._last_radio_index = -1
354
355
        super(MockEDF, self).__init__(scan_path=scan_path,
                                      n_radio=n_radio,
356
357
358
359
360
                                      n_ini_radio=n_ini_radio,
                                      n_extra_radio=n_extra_radio,
                                      scan_range=scan_range,
                                      n_recons=n_recons,
                                      n_pag_recons=n_pag_recons,
361
362
363
364
365
366
367
368
369
370
371
372
373
374
                                      recons_vol=recons_vol,
                                      dim=dim,
                                      scene=scene)
        if n_ini_radio:
            for i_radio in range(n_ini_radio):
                self.add_radio(i_radio)
        for i_extra_radio in range(n_extra_radio):
            self.add_radio(i_extra_radio)
        for i_recons in range(n_recons):
            self.add_reconstruction(i_recons)
        for i_recons in range(n_pag_recons):
            self.add_pag_reconstruction(i_recons)
        if recons_vol is True:
            self.add_recons_vol()
payno's avatar
payno committed
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406

    def get_info_file(self):
        return os.path.join(self.scan_path, os.path.basename(self.scan_path) + '.info')

    def end_acquisition(self):
        # create xml file
        xml_file = os.path.join(self.scan_path, os.path.basename(self.scan_path) + '.xml')
        if not os.path.exists(xml_file):
            # write the final xml file
            root = cElementTree.Element("root")
            tree = cElementTree.ElementTree(root)
            tree.write(xml_file)

    def write_metadata(self, n_radio, scan_range, ref_n, dark_n):
        info_file = self.get_info_file()
        if not os.path.exists(info_file):
            # write the info file
            with open(self.get_info_file(), 'w') as info_file:
                info_file.write('TOMO_N=    ' + str(n_radio) + '\n')
                info_file.write('ScanRange= ' + str(scan_range) + '\n')
                info_file.write('REF_N=     ' + str(ref_n) + '\n')
                info_file.write('REF_ON=    ' + str(n_radio) + '\n')
                info_file.write('DARK_N=    ' + str(dark_n) + '\n')
                info_file.write('Dim_1=     ' + str(self.det_width) + '\n')
                info_file.write('Dim_2=     ' + str(self.det_height) + '\n')
                info_file.write('Col_beg=    0' + '\n')
                info_file.write('Col_end=   ' + str(self.det_width) + '\n')
                info_file.write('Row_beg=    0' + '\n')
                info_file.write('Row_end=    ' + str(self.det_height) + '\n')
                info_file.write('PixelSize=  ' + str(_ScanMock.PIXEL_SIZE) + '\n')

    def add_radio(self, index=None):
407
        if index is not None:
payno's avatar
payno committed
408
409
410
411
412
            self._last_radio_index = index
            index_ = index
        else:
            self._last_radio_index += 1
            index_ = self._last_radio_index
413
414
415
416
        file_name = os.path.basename(self.scan_path) + '_{0:04d}'.format(index_) + ".edf"
        f = os.path.join(self.scan_path, file_name)
        if not os.path.exists(f):
            data = self._get_radio_data(index=index_)
417
            assert data is not None
418
419
420
421
            assert data.shape == (self.det_width, self.det_height)
            edf_writer = fabio.edfimage.EdfImage(data=data,
                                                 header={"tata": "toto"})
            edf_writer.write(f)
payno's avatar
payno committed
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547

    @staticmethod
    def mockReconstruction(folder, nRecons=5, nPagRecons=0, volFile=False):
        """
        create reconstruction files into the given folder

        :param str folder: the path of the folder where to save the reconstruction
        :param nRecons: the number of reconstruction to mock
        :param nPagRecons: the number of paganin reconstruction to mock
        :param volFile: true if we want to add a volFile with reconstruction
        """
        assert type(nRecons) is int and nRecons >= 0
        basename = os.path.basename(folder)
        dim = 200
        for i in range(nRecons):
            f = os.path.join(folder, basename + str(
                MockEDF._RECONS_PATTERN + str(i) + ".edf"))
            data = numpy.zeros((dim, dim))
            data[::i + 2, ::i + 2] = 1.0
            edf_writer = fabio.edfimage.EdfImage(data=data,
                                                 header={"tata": "toto"})
            edf_writer.write(f)

        for i in range(nPagRecons):
            f = os.path.join(folder, basename + str(
                MockEDF._PAG_RECONS_PATTERN + str(i) + ".edf"))
            data = numpy.zeros((dim, dim))
            data[::i + 2, ::i + 2] = 1.0
            edf_writer = fabio.edfimage.EdfImage(data=data,
                                                 header={"tata": "toto"})
            edf_writer.write(f)

        if volFile is True:
            volFile = os.path.join(folder, basename + '.vol')
            infoVolFile = os.path.join(folder, basename + '.vol.info')
            dataShape = (nRecons, dim, dim)
            data = numpy.random.random(nRecons * dim * dim).reshape(
                nRecons, dim, dim)
            data.astype(numpy.float32).tofile(volFile)
            MockEDF._createVolInfoFile(filePath=infoVolFile, shape=dataShape)

    @staticmethod
    def _createVolInfoFile(filePath, shape, voxelSize=1, valMin=0.0,
                           valMax=1.0,
                           s1=0.0, s2=1.0, S1=0.0, S2=1.0):
        assert len(shape) is 3
        f = open(filePath, 'w')
        f.writelines("\n".join([
            '! PyHST_SLAVE VOLUME INFO FILE',
            'NUM_X =  %s' % shape[2],
            'NUM_Y =  %s' % shape[1],
            'NUM_Z =  %s' % shape[0],
            'voxelSize =  %s' % voxelSize,
            'BYTEORDER = LOWBYTEFIRST',
            'ValMin =  %s' % valMin,
            'ValMax =  %s' % valMax,
            's1 =  %s' % s1,
            's2 =  %s' % s2,
            'S1 =  %s' % S1,
            'S2 =  %s' % S2
        ]))
        f.close()

    @staticmethod
    def fastMockAcquisition(folder, n_radio=20, n_extra_radio=0,
                            scan_range=360):
        """
        Simple function creating an acquisition into the given directory
        This won't complete data, scan.info of scan.xml files but just create the
        structure that data watcher is able to detect in edf mode.
        """
        assert type(n_radio) is int and n_radio > 0
        basename = os.path.basename(folder)
        dim = 200
        if not os.path.exists(folder):
            os.mkdir(folder)

        # create info file
        info_file = os.path.join(folder, basename + '.info')
        if not os.path.exists(info_file):
            # write the info file
            with open(info_file, 'w') as info_file:
                info_file.write(
                    'TOMO_N=                 ' + str(n_radio) + '\n')
                info_file.write(
                    'ScanRange=                 ' + str(scan_range) + '\n')

        # create scan files
        for i in range((n_radio + n_extra_radio)):
            file_name = basename + '_{0:04d}'.format(i) + ".edf"
            f = os.path.join(folder, file_name)
            if not os.path.exists(f):
                data = numpy.random.random(dim * dim).reshape(dim, dim)
                edf_writer = fabio.edfimage.EdfImage(data=data,
                                                     header={
                                                         "tata": "toto"})
                edf_writer.write(f)

        # create xml file
        xml_file = os.path.join(folder, basename + '.xml')
        if not os.path.exists(xml_file):
            # write the final xml file
            root = cElementTree.Element("root")
            tree = cElementTree.ElementTree(root)
            tree.write(xml_file)

    @staticmethod
    def mockScan(scanID, nRadio=5, nRecons=1, nPagRecons=0, dim=10,
                 scan_range=360, n_extra_radio=0):
        """
        Create some random radios and reconstruction in the folder

        :param str scanID: the folder where to save the radios and scans
        :param int nRadio: The number of radios to create
        :param int nRecons: the number of reconstruction to mock
        :param int nRecons: the number of paganin reconstruction to mock
        :param int dim: dimension of the files (nb row/columns)
        :param int scan_range: scan range, usually 180 or 360
        :param int n_extra_radio: number of radio run after the full range is made
                                  usually used to observe any sample movement
                                  during acquisition
        """
        assert type(scanID) is str
        assert type(nRadio) is int
        assert type(nRecons) is int
        assert type(dim) is int
548
        from ..scanfactory import ScanFactory  # avoid cyclic import
payno's avatar
payno committed
549
550
551
552
553
554
555

        MockEDF.fastMockAcquisition(folder=scanID, n_radio=nRadio,
                                    scan_range=scan_range, n_extra_radio=n_extra_radio)
        MockEDF.mockReconstruction(folder=scanID,
                                   nRecons=nRecons,
                                   nPagRecons=nPagRecons)
        return ScanFactory.create_scan_object(scanID)