Beispiel #1
0
def resample(source, target, interpolation="continuous"):
    source, source_affine = source
    target, target_affine = target

    input_image = VolumeImg(source[:], source_affine, "arbitrary", interpolation=interpolation)

    resampled_image = input_image.as_volume_img(target_affine, target.shape)

    return resampled_image.get_data()
Beispiel #2
0
def resample(source, target, interpolation='continuous'):
    source, source_affine = source
    target, target_affine = target

    input_image = VolumeImg(source[:],
                            source_affine,
                            'arbitrary',
                            interpolation=interpolation)

    resampled_image = input_image.as_volume_img(target_affine, target.shape)

    return resampled_image.get_data()
Beispiel #3
0
def resample(source, target, interpolation='continuous', return_affine=False):
    source, source_affine = source
    target, target_affine = target

    input_image = VolumeImg(source[:],
                            source_affine,
                            'arbitrary',
                            interpolation=interpolation
                            )

    resampled_image = input_image.as_volume_img(target_affine, target.shape)

    if return_affine:
        return resampled_image.get_data(), resampled_image.get_affine()
    else:
        return resampled_image.get_data()
Beispiel #4
0
    def resample(self, target, interpolation="continuous"):
        """ resample to target - st after 
        inputs:
            target: (shape, affine) tuple 
                 data: numpy array, affine: numpy array
            interpolation: 'nearest' or 'continuous'
        returns:
            interpolated_data
        """
        target_shape, target_affine = target
        input_image = VolumeImg(
            self._data[:], self.affine, "arbitrary", interpolation=interpolation  # why do we need self.data[:]?
        )
        resampled_img = input_image.as_volume_img(target_affine, target_shape)

        assert np.all(resampled_img.affine == target_affine), "resampled_img.affine != target_affine"

        return resampled_img.get_data()