How to use the csbdeep.utils.move_image_axes function in csbdeep

To help you get started, we’ve selected a few csbdeep examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CSBDeep / CSBDeep / csbdeep / datagen.py View on Github external
def _generator(inputs):
        for x, y, axes_in, mask in inputs:
            axes_in = axes_check_and_normalize(axes_in)
            if axes_in != axes:
                # print('permuting axes from %s to %s' % (axes_in,axes))
                x = move_image_axes(x, axes_in, axes, True)
                y = move_image_axes(y, axes_in, axes, True)
                if mask is not None:
                    mask = move_image_axes(mask, axes_in, axes)
            yield x, y, axes, mask
github CSBDeep / CSBDeep / csbdeep / datagen.py View on Github external
def _generator(inputs):
        for x, y, axes_in, mask in inputs:
            axes_in = axes_check_and_normalize(axes_in)
            if axes_in != axes:
                # print('permuting axes from %s to %s' % (axes_in,axes))
                x = move_image_axes(x, axes_in, axes, True)
                y = move_image_axes(y, axes_in, axes, True)
                if mask is not None:
                    mask = move_image_axes(mask, axes_in, axes)
            yield x, y, axes, mask
github CSBDeep / CSBDeep / csbdeep / data / transform.py View on Github external
def _normalize_data(data,undo=False):
            if undo:
                return move_image_axes(data, axes_out, axes_in)
            else:
                return move_image_axes(data, axes_in, axes_out)
        return _normalize_data
github CSBDeep / CSBDeep / csbdeep / models.py View on Github external
def _permute_axes(data,undo=False):
            if data is None:
                return None
            if undo:
                if channel_in is not None:
                    return move_image_axes(data, axes_out, axes_in, True)
                else:
                    # input is single-channel and has no channel axis
                    data = move_image_axes(data, axes_out, axes_in+'C', True)
                    # output is single-channel -> remove channel axis
                    if data.shape[-1] == 1:
                        data = data[...,0]
                    return data
            else:
                return move_image_axes(data, axes_in, axes_out, True)
        return _permute_axes
github CSBDeep / CSBDeep / csbdeep / data / transform.py View on Github external
def _generator(inputs):
        for x, y, axes_in, mask in inputs:
            axes_in = axes_check_and_normalize(axes_in)
            if axes_in != axes:
                # print('permuting axes from %s to %s' % (axes_in,axes))
                x = move_image_axes(x, axes_in, axes, True)
                y = move_image_axes(y, axes_in, axes, True)
                if mask is not None:
                    mask = move_image_axes(mask, axes_in, axes)
            yield x, y, axes, mask
github CSBDeep / CSBDeep / csbdeep / datagen.py View on Github external
def _generator(inputs):
        for x, y, axes_in, mask in inputs:
            axes_in = axes_check_and_normalize(axes_in)
            if axes_in != axes:
                # print('permuting axes from %s to %s' % (axes_in,axes))
                x = move_image_axes(x, axes_in, axes, True)
                y = move_image_axes(y, axes_in, axes, True)
                if mask is not None:
                    mask = move_image_axes(mask, axes_in, axes)
            yield x, y, axes, mask
github CSBDeep / CSBDeep / csbdeep / models / base_model.py View on Github external
def _permute_axes(data,undo=False):
            if data is None:
                return None
            if undo:
                if 'C' in img_axes_in:
                    return move_image_axes(data, net_axes_out, img_axes_out, True)
                else:
                    # input is single-channel and has no channel axis
                    data = move_image_axes(data, net_axes_out, img_axes_out+'C', True)
                    if data.shape[-1] == 1:
                        # output is single-channel -> remove channel axis
                        data = data[...,0]
                    return data
            else:
                return move_image_axes(data, img_axes_in, net_axes_in, True)
        return _permute_axes
github CSBDeep / CSBDeep / csbdeep / models / base_model.py View on Github external
def _permute_axes(data,undo=False):
            if data is None:
                return None
            if undo:
                if 'C' in img_axes_in:
                    return move_image_axes(data, net_axes_out, img_axes_out, True)
                else:
                    # input is single-channel and has no channel axis
                    data = move_image_axes(data, net_axes_out, img_axes_out+'C', True)
                    if data.shape[-1] == 1:
                        # output is single-channel -> remove channel axis
                        data = data[...,0]
                    return data
            else:
                return move_image_axes(data, img_axes_in, net_axes_in, True)
        return _permute_axes
github CSBDeep / CSBDeep / csbdeep / data / transform.py View on Github external
img.shape == target.shape or _raise(ValueError())

            axes = axes_check_and_normalize(axes)
            _normalize_data = _make_normalize_data(axes)
            # print(axes, img.shape)

            x = img.astype(np.float32, copy=False)

            if psf is not None:
                from scipy.signal import fftconvolve
                # print("blurring with psf")
                _psf = psf.astype(np.float32,copy=False)
                np.min(_psf) >= 0 or _raise(ValueError('psf has negative values.'))
                _psf /= np.sum(_psf)
                if psf_axes is not None:
                    _psf = move_image_axes(_psf, psf_axes, axes, True)
                x.ndim == _psf.ndim or _raise(ValueError('image and psf must have the same number of dimensions.'))

                if 'C' in axes:
                    ch = axes_dict(axes)['C']
                    n_channels = x.shape[ch]
                    # convolve with psf separately for every channel
                    if _psf.shape[ch] == 1 and n_channels > 1:
                        warnings.warn('applying same psf to every channel of the image.')
                    if _psf.shape[ch] in (1,n_channels):
                        x = np.stack([
                            fftconvolve(
                                np.take(x,   i,axis=ch),
                                np.take(_psf,i,axis=ch,mode='clip'),
                                mode='same'
                            )
                            for i in range(n_channels)