fepegar / torchio

Compare 5bce14f ... +1 ... 6d23a1f

Coverage Reach
transforms/augmentation/intensity/random_labels_to_image.py transforms/augmentation/intensity/random_motion.py transforms/augmentation/intensity/random_ghosting.py transforms/augmentation/intensity/random_swap.py transforms/augmentation/intensity/random_bias_field.py transforms/augmentation/intensity/random_spike.py transforms/augmentation/intensity/random_gamma.py transforms/augmentation/intensity/random_blur.py transforms/augmentation/intensity/random_noise.py transforms/augmentation/intensity/__init__.py transforms/augmentation/spatial/random_affine.py transforms/augmentation/spatial/random_elastic_deformation.py transforms/augmentation/spatial/random_flip.py transforms/augmentation/spatial/random_anisotropy.py transforms/augmentation/spatial/__init__.py transforms/augmentation/composition.py transforms/augmentation/random_transform.py transforms/augmentation/__init__.py transforms/preprocessing/spatial/resample.py transforms/preprocessing/spatial/crop_or_pad.py transforms/preprocessing/spatial/pad.py transforms/preprocessing/spatial/resize.py transforms/preprocessing/spatial/crop.py transforms/preprocessing/spatial/ensure_shape_multiple.py transforms/preprocessing/spatial/to_canonical.py transforms/preprocessing/spatial/copy_affine.py transforms/preprocessing/spatial/bounds_transform.py transforms/preprocessing/intensity/histogram_standardization.py transforms/preprocessing/intensity/rescale.py transforms/preprocessing/intensity/mask.py transforms/preprocessing/intensity/z_normalization.py transforms/preprocessing/intensity/clamp.py transforms/preprocessing/intensity/normalization_transform.py transforms/preprocessing/intensity/__init__.py transforms/preprocessing/label/remap_labels.py transforms/preprocessing/label/one_hot.py transforms/preprocessing/label/keep_largest_component.py transforms/preprocessing/label/sequential_labels.py transforms/preprocessing/label/contour.py transforms/preprocessing/label/remove_labels.py transforms/preprocessing/label/label_transform.py transforms/preprocessing/__init__.py transforms/transform.py transforms/data_parser.py transforms/__init__.py transforms/lambda_transform.py transforms/interpolation.py transforms/intensity_transform.py transforms/fourier.py transforms/spatial_transform.py data/image.py data/sampler/weighted.py data/sampler/grid.py data/sampler/label.py data/sampler/sampler.py data/sampler/uniform.py data/sampler/__init__.py data/io.py data/subject.py data/queue.py data/inference/aggregator.py data/inference/__init__.py data/dataset.py data/__init__.py utils.py visualization.py cli/apply_transform.py cli/print_info.py typing.py constants.py __init__.py reference.py

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 2 of 5 files from the diff.

@@ -29,6 +29,10 @@
Loading
29 29
    topic on ScienceDirect contains useful articles explaining interpolation of
30 30
    displacement fields using cubic B-splines.
31 31
32 +
    .. warning:: This transform is slow as it requires expensive computations.
33 +
        If your images are large you might want to use
34 +
        math:`~torchio.transforms.RandomAffine` instead.
35 +
32 36
    Args:
33 37
        num_control_points: Number of control points along each dimension of
34 38
            the coarse grid :math:`(n_x, n_y, n_z)`.
@@ -212,11 +216,16 @@
Loading
212 216
            'max_displacement',
213 217
        )
214 218
215 -
    @staticmethod
216 219
    def get_bspline_transform(
220 +
            self,
217 221
            image: sitk.Image,
218 -
            control_points: np.ndarray,
219 222
            ) -> sitk.BSplineTransformInitializer:
223 +
        control_points = self.control_points.copy()
224 +
        if self.invert_transform:
225 +
            control_points *= -1
226 +
        is_2d = image.GetSize()[2] == 1
227 +
        if is_2d:
228 +
            control_points[..., -1] = 0  # no displacement in IS axis
220 229
        num_control_points = control_points.shape[:-1]
221 230
        mesh_shape = [n - SPLINE_ORDER for n in num_control_points]
222 231
        bspline_transform = sitk.BSplineTransformInitializer(image, mesh_shape)
@@ -248,20 +257,14 @@
Loading
248 257
        if no_displacement:
249 258
            return subject
250 259
        subject.check_consistent_spatial_shape()
251 -
        control_points = self.control_points.copy()
252 -
        if self.invert_transform:
253 -
            control_points *= -1
254 260
        for image in self.get_images(subject):
255 261
            if not isinstance(image, ScalarImage):
256 262
                interpolation = 'nearest'
257 263
            else:
258 264
                interpolation = self.image_interpolation
259 -
            if image.is_2d():
260 -
                control_points[..., -1] = 0  # no displacement in IS axis
261 265
            transformed = self.apply_bspline_transform(
262 266
                image.data,
263 267
                image.affine,
264 -
                control_points,
265 268
                interpolation,
266 269
            )
267 270
            image.set_data(transformed)
@@ -271,18 +274,14 @@
Loading
271 274
            self,
272 275
            tensor: torch.Tensor,
273 276
            affine: np.ndarray,
274 -
            control_points: np.ndarray,
275 277
            interpolation: str,
276 278
            ) -> torch.Tensor:
277 279
        assert tensor.dim() == 4
278 280
        results = []
279 281
        for component in tensor:
280 282
            image = nib_to_sitk(component[np.newaxis], affine, force_3d=True)
281 283
            floating = reference = image
282 -
            bspline_transform = self.get_bspline_transform(
283 -
                image,
284 -
                control_points,
285 -
            )
284 +
            bspline_transform = self.get_bspline_transform(image)
286 285
            self.parse_free_form_transform(
287 286
                bspline_transform,
288 287
                self.max_displacement,

@@ -2,7 +2,7 @@
Loading
2 2
3 3
__author__ = """Fernando Perez-Garcia"""
4 4
__email__ = 'fepegar@gmail.com'
5 -
__version__ = '0.18.55'
5 +
__version__ = '0.18.56'
6 6
7 7
8 8
from . import utils

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
torchio 95.51%
Project Totals (72 files) 95.51%
Loading