Beispiel #1
0
    def getEventDocs(cls, path, descriptor_uid):
        for proj_index in range(cls.num_projections(path)):
            yield embedded_local_event_doc(descriptor_uid,
                                           'projection',
                                           cls, (path, ),
                                           resource_kwargs=dict(
                                               arr='data', slc=proj_index))

        for sino_index in range(cls.num_sinograms(path)):
            yield embedded_local_event_doc(descriptor_uid,
                                           'sinogram',
                                           cls, (path, ),
                                           resource_kwargs=dict(
                                               arr='sino', slc=sino_index))

        for flat_index in range(cls.num_flats(path)):
            yield embedded_local_event_doc(descriptor_uid,
                                           'flat',
                                           cls, (path, ),
                                           resource_kwargs=dict(
                                               arr='data_white',
                                               slc=flat_index))

        for dark_index in range(cls.num_darks(path)):
            yield embedded_local_event_doc(
                descriptor_uid,
                'dark',
                cls, (path, ),
                resource_kwargs=dict(arr='data_dark', slc=dark_index))
Beispiel #2
0
    def getEventDocs(cls, path, descriptor_uid):
        with h5py.File(path, 'r') as h5:
            angles = np.deg2rad(h5['angle'])

        for proj_index in range(cls.num_projections(path)):
            yield embedded_local_event_doc(
                descriptor_uid,
                'projection',
                cls, (path, ),
                resource_kwargs=dict(arr='img_tomo', slc=proj_index),
                metadata={'angle': angles[proj_index]})

        for sino_index in range(cls.num_sinograms(path)):
            yield embedded_local_event_doc(descriptor_uid,
                                           'sinogram',
                                           cls, (path, ),
                                           resource_kwargs=dict(
                                               arr='sino', slc=sino_index))

        for flat_index in range(cls.num_flats(path)):
            yield embedded_local_event_doc(descriptor_uid,
                                           'flat',
                                           cls, (path, ),
                                           resource_kwargs=dict(
                                               arr='img_bkg', slc=flat_index))

        for dark_index in range(cls.num_darks(path)):
            yield embedded_local_event_doc(descriptor_uid,
                                           'dark',
                                           cls, (path, ),
                                           resource_kwargs=dict(
                                               arr='img_dark', slc=dark_index))
Beispiel #3
0
    def getVolumeEvents(cls, path, descriptor_uid):
        with h5py.File(path, 'r') as f:
            root_name = list(f.keys())[0] + '/'
            n = f[root_name + 'data/image/image_cube'].shape[2]
            wavenumbers = f[root_name + 'data/wavenumbers'][:]
            ind_rc_map = f[root_name + 'data/image/ind_rc_map'][:, :]
            ind2rc = {x[0]: tuple(x[1:]) for x in ind_rc_map}
            rc2ind = {tuple(x[1:]): x[0] for x in ind_rc_map}
            imgMask = f[root_name + 'data/image/image_mask'][:, :]
            imgShape = (imgMask.shape[0], imgMask.shape[1])

        for i in range(n):
            yield embedded_local_event_doc(descriptor_uid, 'volume', cls, (path,), resource_kwargs={'E': i},
                                       metadata = {'path': path, 'wavenumbers': wavenumbers, 'rc_index': rc2ind, 'index_rc': ind2rc, 'imgShape': imgShape})
Beispiel #4
0
    def getSpectraEvents(cls, path, descriptor_uid):
        # get a h5 object
        # find the spectra data
        # get spectra index
        # iterate over rows
        with h5py.File(path, 'r') as f:
            root_name = list(f.keys())[0] + '/'
            # get number of rows
            n = f[root_name + 'data/spectra'].shape[0]
            wavenumbers = f[root_name + 'data/wavenumbers'][:]
            ind_rc_map = f[root_name + 'data/image/ind_rc_map'][:,:]
            ind2rc = {x[0]: tuple(x[1:]) for x in ind_rc_map}
            rc2ind = {tuple(x[1:]): x[0] for x in ind_rc_map}
            mask = f[root_name + 'data/image/image_mask'][:, :]
            imgShape = (mask.shape[0], mask.shape[1])

        for i in range(n):
            yield embedded_local_event_doc(descriptor_uid, 'spectra', cls, (path,), resource_kwargs={'i': i},
                                           metadata={'wavenumbers':wavenumbers, 'rc_index': rc2ind, 'index_rc': ind2rc, 'imgShape':imgShape})
Beispiel #5
0
 def getImageEvents(cls, path, descriptor_uid):
     # get a h5 object
     # find the imagecube
     # get imagecube shape
     # iterate over E dimension
     with h5py.File(path, 'r') as f:
         root_name = list(f.keys())[0] + '/'
         # get number of frames
         n = f[root_name + 'data/image/image_cube'].shape[2]
         wavenumbers = f[root_name + 'data/wavenumbers'][:]
         ind_rc_map = f[root_name + 'data/image/ind_rc_map'][:, :]
         ind2rc = {x[0]: tuple(x[1:]) for x in ind_rc_map}
         rc2ind = {tuple(x[1:]): x[0] for x in ind_rc_map}
         imgMask = f[root_name + 'data/image/image_mask'][:, :]
         imgShape = (imgMask.shape[0], imgMask.shape[1])
         
     for i in range(n):
         yield embedded_local_event_doc(descriptor_uid, 'image', cls, (path,), resource_kwargs={'E': i},
                                        metadata={'wavenumbers': wavenumbers, 'rc_index': rc2ind, 'index_rc': ind2rc, 'imgShape': imgShape})