diff --git a/scilpy/image/resample_volume.py b/scilpy/image/resample_volume.py deleted file mode 100644 index 98ee3964f..000000000 --- a/scilpy/image/resample_volume.py +++ /dev/null @@ -1,119 +0,0 @@ -# -*- coding: utf-8 -*- - -import logging - -from scilpy.image.reslice import reslice # Don't use Dipy's reslice. Buggy. -import nibabel as nib -import numpy as np - - -def _interp_code_to_order(interp_code): - orders = {'nn': 0, 'lin': 1, 'quad': 2, 'cubic': 3} - return orders[interp_code] - - -def resample_volume(img, ref=None, res=None, iso_min=False, zoom=None, - interp='lin', enforce_dimensions=False): - """ - Function to resample a dataset to match the resolution of another - reference dataset or to the resolution specified as in argument. - One of the following options must be chosen: ref, res or iso_min. - - Parameters - ---------- - img: nib.Nifti1Image - Image to resample. - ref: nib.Nifti1Image - Reference volume to resample to. This method is used only if ref is not - None. (default: None) - res: tuple, shape (3,) or int, optional - Resolution to resample to. If the value it is set to is Y, it will - resample to an isotropic resolution of Y x Y x Y. This method is used - only if res is not None. (default: None) - iso_min: bool, optional - If true, resample the volume to R x R x R with R being the smallest - current voxel dimension. If false, this method is not used. - zoom: tuple, shape (3,) or float, optional - Set the zoom property of the image at the value specified. - interp: str, optional - Interpolation mode. 'nn' = nearest neighbour, 'lin' = linear, - 'quad' = quadratic, 'cubic' = cubic. (Default: linear) - enforce_dimensions: bool, optional - If True, enforce the reference volume dimension (only if res is not - None). (Default = False) - - Returns - ------- - resampled_image: nib.Nifti1Image - Resampled image. - """ - data = np.asanyarray(img.dataobj) - original_res = data.shape - affine = img.affine - original_zooms = img.header.get_zooms()[:3] - - if ref is not None: - if iso_min or zoom or res: - raise ValueError('Please only provide one option amongst ref, res ' - ', zoom or iso_min.') - ref_img = nib.load(ref) - new_zooms = ref_img.header.get_zooms()[:3] - elif res is not None: - if iso_min or zoom: - raise ValueError('Please only provide one option amongst ref, res ' - ', zoom or iso_min.') - if len(res) == 1: - res = res * 3 - new_zooms = tuple((o / r) * z for o, r, - z in zip(original_res, res, original_zooms)) - - elif iso_min: - if zoom: - raise ValueError('Please only provide one option amongst ref, res ' - ', zoom or iso_min.') - min_zoom = min(original_zooms) - new_zooms = (min_zoom, min_zoom, min_zoom) - elif zoom: - new_zooms = zoom - if len(zoom) == 1: - new_zooms = zoom * 3 - else: - raise ValueError("You must choose the resampling method. Either with" - "a reference volume, or a chosen isometric resolution" - ", or an isometric resampling to the smallest current" - " voxel dimension!") - - interp_choices = ['nn', 'lin', 'quad', 'cubic'] - if interp not in interp_choices: - raise ValueError("interp must be one of 'nn', 'lin', 'quad', 'cubic'.") - - logging.debug('Data shape: %s', data.shape) - logging.debug('Data affine: %s', affine) - logging.debug('Data affine setup: %s', nib.aff2axcodes(affine)) - logging.debug('Resampling data to %s with mode %s', new_zooms, interp) - - data2, affine2 = reslice(data, affine, original_zooms, new_zooms, - _interp_code_to_order(interp)) - - logging.debug('Resampled data shape: %s', data2.shape) - logging.debug('Resampled data affine: %s', affine2) - logging.debug('Resampled data affine setup: %s', nib.aff2axcodes(affine2)) - - if enforce_dimensions: - if ref is None: - raise ValueError('enforce_dimensions can only be used with the ref' - 'method.') - else: - computed_dims = data2.shape - ref_dims = ref_img.shape[:3] - if computed_dims != ref_dims: - fix_dim_volume = np.zeros(ref_dims) - x_dim = min(computed_dims[0], ref_dims[0]) - y_dim = min(computed_dims[1], ref_dims[1]) - z_dim = min(computed_dims[2], ref_dims[2]) - - fix_dim_volume[:x_dim, :y_dim, :z_dim] = \ - data2[:x_dim, :y_dim, :z_dim] - data2 = fix_dim_volume - - return nib.Nifti1Image(data2.astype(data.dtype), affine2) diff --git a/scilpy/image/utils.py b/scilpy/image/utils.py index 4b7b4939a..189e3db78 100644 --- a/scilpy/image/utils.py +++ b/scilpy/image/utils.py @@ -4,37 +4,9 @@ import nibabel as nib import numpy as np -import six from sklearn.cluster import KMeans -def count_non_zero_voxels(image): - """ - Count number of non zero voxels - - Parameters: - ----------- - image: string - Path to the image - """ - if isinstance(image, six.string_types): - nb_object = nib.load(image) - else: - nb_object = image - - data = nb_object.get_fdata(dtype=np.float32, caching='unchanged') - - # Count the number of non-zero voxels. - if len(data.shape) >= 4: - axes_to_sum = np.arange(3, len(data.shape)) - nb_voxels = np.count_nonzero(np.sum(np.absolute(data), - axis=tuple(axes_to_sum))) - else: - nb_voxels = np.count_nonzero(data) - - return nb_voxels - - def volume_iterator(img, blocksize=1, start=0, end=0): """Generator that iterates on volumes of data. diff --git a/scilpy/image/operations.py b/scilpy/image/volume_math.py similarity index 100% rename from scilpy/image/operations.py rename to scilpy/image/volume_math.py diff --git a/scilpy/utils/image.py b/scilpy/image/volume_operations.py similarity index 57% rename from scilpy/utils/image.py rename to scilpy/image/volume_operations.py index de8812e7a..dd5ab0c41 100644 --- a/scilpy/utils/image.py +++ b/scilpy/image/volume_operations.py @@ -10,17 +10,84 @@ RigidTransform3D) from dipy.io.gradients import read_bvals_bvecs from dipy.io.utils import get_reference_info -from dipy.segment.mask import median_otsu +from dipy.segment.mask import crop, median_otsu import nibabel as nib import numpy as np +from scilpy.image.reslice import reslice # Don't use Dipy's reslice. Buggy. from scipy.ndimage import binary_dilation + from scilpy.io.image import get_data_as_mask from scilpy.utils.bvec_bval_tools import identify_shells +from scilpy.utils.util import voxel_to_world, world_to_voxel + + +def count_non_zero_voxels(image): + """ + Count number of non-zero voxels + + Parameters: + ----------- + image: string + Path to the image + """ + # Count the number of non-zero voxels. + if len(image.shape) >= 4: + axes_to_sum = np.arange(3, len(image.shape)) + nb_voxels = np.count_nonzero(np.sum(np.absolute(image), + axis=tuple(axes_to_sum))) + else: + nb_voxels = np.count_nonzero(image) + + return nb_voxels -def transform_anatomy(transfo, reference, moving, filename_to_save, - interp='linear', keep_dtype=False): +def flip_volume(data, axes): + """ + data: np.ndarray + axes: a list containing any number of values amongst ['x', 'y', 'z']. + """ + if 'x' in axes: + data = data[::-1, ...] + + if 'y' in axes: + data = data[:, ::-1, ...] + + if 'z' in axes: + data = data[:, :, ::-1, ...] + + return data + + +def crop_volume(img: nib.Nifti1Image, wbbox): + """Applies cropping from a world space defined bounding box and fixes the + affine to keep data aligned. + + wbbox: WorldBoundingBox from the scrip scil_crop_volume. ToDo. Update this. + """ + data = img.get_fdata(dtype=np.float32, caching='unchanged') + affine = img.affine + + voxel_bb_mins = world_to_voxel(wbbox.minimums, affine) + voxel_bb_maxs = world_to_voxel(wbbox.maximums, affine) + + # Prevent from trying to crop outside data boundaries by clipping bbox + extent = list(data.shape[:3]) + for i in range(3): + voxel_bb_mins[i] = max(0, voxel_bb_mins[i]) + voxel_bb_maxs[i] = min(extent[i], voxel_bb_maxs[i]) + translation = voxel_to_world(voxel_bb_mins, affine) + + data_crop = np.copy(crop(data, voxel_bb_mins, voxel_bb_maxs)) + + new_affine = np.copy(affine) + new_affine[0:3, 3] = translation[0:3] + + return nib.Nifti1Image(data_crop, new_affine) + + +def apply_transform(transfo, reference, moving, filename_to_save, + interp='linear', keep_dtype=False): """ Apply transformation to an image using Dipy's tool @@ -243,3 +310,115 @@ def compute_snr(dwi, bval, bvec, b0_thr, mask, val[idx]['snr'] = val[idx]['mean'] / val[idx]['std'] return val + + +def _interp_code_to_order(interp_code): + orders = {'nn': 0, 'lin': 1, 'quad': 2, 'cubic': 3} + return orders[interp_code] + + +def resample_volume(img, ref=None, res=None, iso_min=False, zoom=None, + interp='lin', enforce_dimensions=False): + """ + Function to resample a dataset to match the resolution of another + reference dataset or to the resolution specified as in argument. + One of the following options must be chosen: ref, res or iso_min. + + Parameters + ---------- + img: nib.Nifti1Image + Image to resample. + ref: nib.Nifti1Image + Reference volume to resample to. This method is used only if ref is not + None. (default: None) + res: tuple, shape (3,) or int, optional + Resolution to resample to. If the value it is set to is Y, it will + resample to an isotropic resolution of Y x Y x Y. This method is used + only if res is not None. (default: None) + iso_min: bool, optional + If true, resample the volume to R x R x R with R being the smallest + current voxel dimension. If false, this method is not used. + zoom: tuple, shape (3,) or float, optional + Set the zoom property of the image at the value specified. + interp: str, optional + Interpolation mode. 'nn' = nearest neighbour, 'lin' = linear, + 'quad' = quadratic, 'cubic' = cubic. (Default: linear) + enforce_dimensions: bool, optional + If True, enforce the reference volume dimension (only if res is not + None). (Default = False) + + Returns + ------- + resampled_image: nib.Nifti1Image + Resampled image. + """ + data = np.asanyarray(img.dataobj) + original_res = data.shape + affine = img.affine + original_zooms = img.header.get_zooms()[:3] + + if ref is not None: + if iso_min or zoom or res: + raise ValueError('Please only provide one option amongst ref, res ' + ', zoom or iso_min.') + ref_img = nib.load(ref) + new_zooms = ref_img.header.get_zooms()[:3] + elif res is not None: + if iso_min or zoom: + raise ValueError('Please only provide one option amongst ref, res ' + ', zoom or iso_min.') + if len(res) == 1: + res = res * 3 + new_zooms = tuple((o / r) * z for o, r, + z in zip(original_res, res, original_zooms)) + + elif iso_min: + if zoom: + raise ValueError('Please only provide one option amongst ref, res ' + ', zoom or iso_min.') + min_zoom = min(original_zooms) + new_zooms = (min_zoom, min_zoom, min_zoom) + elif zoom: + new_zooms = zoom + if len(zoom) == 1: + new_zooms = zoom * 3 + else: + raise ValueError("You must choose the resampling method. Either with" + "a reference volume, or a chosen isometric resolution" + ", or an isometric resampling to the smallest current" + " voxel dimension!") + + interp_choices = ['nn', 'lin', 'quad', 'cubic'] + if interp not in interp_choices: + raise ValueError("interp must be one of 'nn', 'lin', 'quad', 'cubic'.") + + logging.debug('Data shape: %s', data.shape) + logging.debug('Data affine: %s', affine) + logging.debug('Data affine setup: %s', nib.aff2axcodes(affine)) + logging.debug('Resampling data to %s with mode %s', new_zooms, interp) + + data2, affine2 = reslice(data, affine, original_zooms, new_zooms, + _interp_code_to_order(interp)) + + logging.debug('Resampled data shape: %s', data2.shape) + logging.debug('Resampled data affine: %s', affine2) + logging.debug('Resampled data affine setup: %s', nib.aff2axcodes(affine2)) + + if enforce_dimensions: + if ref is None: + raise ValueError('enforce_dimensions can only be used with the ref' + 'method.') + else: + computed_dims = data2.shape + ref_dims = ref_img.shape[:3] + if computed_dims != ref_dims: + fix_dim_volume = np.zeros(ref_dims) + x_dim = min(computed_dims[0], ref_dims[0]) + y_dim = min(computed_dims[1], ref_dims[1]) + z_dim = min(computed_dims[2], ref_dims[2]) + + fix_dim_volume[:x_dim, :y_dim, :z_dim] = \ + data2[:x_dim, :y_dim, :z_dim] + data2 = fix_dim_volume + + return nib.Nifti1Image(data2.astype(data.dtype), affine2) diff --git a/scilpy/image/datasets.py b/scilpy/image/volume_space_management.py similarity index 99% rename from scilpy/image/datasets.py rename to scilpy/image/volume_space_management.py index b952090f1..b112912e4 100644 --- a/scilpy/image/datasets.py +++ b/scilpy/image/volume_space_management.py @@ -4,6 +4,10 @@ from dipy.core.interpolation import trilinear_interpolate4d, \ nearestneighbor_interpolate from dipy.io.stateful_tractogram import Origin, Space +from dipy.segment.mask import bounding_box + + +from scilpy.utils.util import voxel_to_world class DataVolume(object): diff --git a/scilpy/tracking/propagator.py b/scilpy/tracking/propagator.py index 4793c95a6..bd4ddddd4 100644 --- a/scilpy/tracking/propagator.py +++ b/scilpy/tracking/propagator.py @@ -29,11 +29,11 @@ class AbstractPropagator(object): Propagation depends on the type of data (ex, DTI, fODF) and the way to get a direction from it (ex, det, prob). """ - def __init__(self, dataset, step_size, rk_order, space, origin): + def __init__(self, datavolume, step_size, rk_order, space, origin): """ Parameters ---------- - dataset: scilpy.image.datasets.DataVolume + datavolume: scilpy.image.volume_space_management.DataVolume Trackable Dataset object. step_size: float The step size for tracking. Important: step size should be in the @@ -52,7 +52,7 @@ def __init__(self, dataset, step_size, rk_order, space, origin): Tracker will verify that the propagator has the same internal values as itself. """ - self.dataset = dataset + self.datavolume = datavolume self.origin = origin self.space = space @@ -76,10 +76,10 @@ def reset_data(self, new_data=None): Params ------ new_data: Any - Will replace self.dataset.data. + Will replace self.datavolume.data. """ - self.dataset.data = new_data + self.datavolume.data = new_data def prepare_forward(self, seeding_pos): """ @@ -250,13 +250,13 @@ def _sample_next_direction(self, pos, v_in): class PropagatorOnSphere(AbstractPropagator): - def __init__(self, dataset, step_size, rk_order, dipy_sphere, + def __init__(self, datavolume, step_size, rk_order, dipy_sphere, space, origin): """ Parameters ---------- - dataset: scilpy.image.datasets.DataVolume - Trackable Dataset object. + datavolume: scilpy.image.volume_space_management.DataVolume + Trackable DataVolume object. step_size: float The step size for tracking. rk_order: int @@ -269,7 +269,7 @@ def __init__(self, dataset, step_size, rk_order, dipy_sphere, origin: dipy Origin Origin of the streamlines during tracking. """ - super().__init__(dataset, step_size, rk_order, space, origin) + super().__init__(datavolume, step_size, rk_order, space, origin) self.sphere = dipy.data.get_sphere(dipy_sphere) self.dirs = np.zeros(len(self.sphere.vertices), dtype=np.ndarray) @@ -312,7 +312,7 @@ class ODFPropagator(PropagatorOnSphere): """ Propagator on ODFs/fODFs. Algo can be det or prob. """ - def __init__(self, dataset, step_size, + def __init__(self, datavolume, step_size, rk_order, algo, basis, sf_threshold, sf_threshold_init, theta, dipy_sphere='symmetric724', min_separation_angle=np.pi / 16., @@ -321,8 +321,8 @@ def __init__(self, dataset, step_size, Parameters ---------- - dataset: scilpy.image.datasets.DataVolume - Trackable Dataset object. + datavolume: scilpy.image.volume_space_management.DataVolume + Trackable DataVolume object. step_size: float The step size for tracking. rk_order: int @@ -360,7 +360,7 @@ def __init__(self, dataset, step_size, dipy. Interpolation of the ODF is done in center origin so this choice implies the less data modification. """ - super().__init__(dataset, step_size, rk_order, dipy_sphere, + super().__init__(datavolume, step_size, rk_order, dipy_sphere, space, origin) if self.space == Space.RASMM: @@ -389,7 +389,7 @@ def __init__(self, dataset, step_size, self.sf_threshold = sf_threshold self.sf_threshold_init = sf_threshold_init sh_order, full_basis =\ - get_sh_order_and_fullness(self.dataset.data.shape[-1]) + get_sh_order_and_fullness(self.datavolume.data.shape[-1]) self.basis = basis self.B = sh_to_sf_matrix(self.sphere, sh_order, self.basis, smooth=0.006, return_inv=False, @@ -412,7 +412,7 @@ def _get_sf(self, pos): its maximum amplitude. """ # Interpolation: - sh = self.dataset.get_value_at_coordinate( + sh = self.datavolume.get_value_at_coordinate( *pos, space=self.space, origin=self.origin) sf = np.dot(self.B.T, sh).reshape((-1, 1)) diff --git a/scilpy/tracking/tracker.py b/scilpy/tracking/tracker.py index 38f671a02..1873af41e 100644 --- a/scilpy/tracking/tracker.py +++ b/scilpy/tracking/tracker.py @@ -17,7 +17,7 @@ from dipy.reconst.shm import sh_to_sf_matrix from dipy.tracking.streamlinespeed import compress_streamlines -from scilpy.image.datasets import DataVolume +from scilpy.image.volume_space_management import DataVolume from scilpy.tracking.propagator import AbstractPropagator, PropagationStatus from scilpy.reconst.utils import find_order_from_nb_coeff from scilpy.tracking.seed import SeedGenerator @@ -207,7 +207,7 @@ def _prepare_multiprocessing_pool(self, tmpdir): # Saving data. We will reload it in each process. data_file_name = os.path.join(tmpdir, 'data.npy') - np.save(data_file_name, self.propagator.dataset.data) + np.save(data_file_name, self.propagator.datavolume.data) # Clear data from memory self.propagator.reset_data(new_data=None) diff --git a/scripts/scil_apply_transform_to_bvecs.py b/scripts/scil_apply_transform_to_bvecs.py index d8f926d7e..bbfe26c20 100755 --- a/scripts/scil_apply_transform_to_bvecs.py +++ b/scripts/scil_apply_transform_to_bvecs.py @@ -13,8 +13,6 @@ from scilpy.io.utils import (add_overwrite_arg, assert_inputs_exist, assert_outputs_exist, load_matrix_in_any_format) -from scilpy.utils.filenames import split_name_with_nii -from scilpy.utils.image import transform_anatomy def _build_arg_parser(): diff --git a/scripts/scil_apply_transform_to_image.py b/scripts/scil_apply_transform_to_image.py index db5ce72eb..83f5ce0c9 100755 --- a/scripts/scil_apply_transform_to_image.py +++ b/scripts/scil_apply_transform_to_image.py @@ -15,7 +15,7 @@ from scilpy.io.utils import (add_overwrite_arg, assert_inputs_exist, assert_outputs_exist, load_matrix_in_any_format) from scilpy.utils.filenames import split_name_with_nii -from scilpy.utils.image import transform_anatomy +from scilpy.image.volume_operations import apply_transform def _build_arg_parser(): @@ -63,8 +63,8 @@ def main(): if in_extension not in ['.nii', '.nii.gz']: parser.error('{} is an unsupported format.'.format(args.in_file)) - transform_anatomy(transfo, args.in_target_file, args.in_file, - args.out_name, keep_dtype=args.keep_dtype) + apply_transform(transfo, args.in_target_file, args.in_file, + args.out_name, keep_dtype=args.keep_dtype) if __name__ == "__main__": diff --git a/scripts/scil_compute_bundle_voxel_label_map.py b/scripts/scil_compute_bundle_voxel_label_map.py index 232cab1db..70b81682d 100755 --- a/scripts/scil_compute_bundle_voxel_label_map.py +++ b/scripts/scil_compute_bundle_voxel_label_map.py @@ -22,7 +22,7 @@ import scipy.ndimage as ndi from scipy.spatial import cKDTree -from scilpy.image.operations import correlation +from scilpy.image.volume_math import correlation from scilpy.io.streamlines import load_tractogram_with_reference from scilpy.io.utils import (add_overwrite_arg, add_reference_arg, diff --git a/scripts/scil_compute_local_tracking_dev.py b/scripts/scil_compute_local_tracking_dev.py index 51b59b025..4157631a6 100755 --- a/scripts/scil_compute_local_tracking_dev.py +++ b/scripts/scil_compute_local_tracking_dev.py @@ -59,7 +59,7 @@ add_verbose_arg, assert_inputs_exist, assert_outputs_exist, verify_compression_th) -from scilpy.image.datasets import DataVolume +from scilpy.image.volume_space_management import DataVolume from scilpy.tracking.propagator import ODFPropagator from scilpy.tracking.seed import SeedGenerator from scilpy.tracking.tools import get_theta diff --git a/scripts/scil_connectivity_math.py b/scripts/scil_connectivity_math.py index e7c275b02..b1b0deb06 100755 --- a/scripts/scil_connectivity_math.py +++ b/scripts/scil_connectivity_math.py @@ -17,7 +17,7 @@ import nibabel as nib import numpy as np -from scilpy.image.operations import (get_array_ops, get_operations_doc) +from scilpy.image.volume_math import (get_array_ops, get_operations_doc) from scilpy.io.utils import (add_overwrite_arg, add_verbose_arg, assert_outputs_exist, diff --git a/scripts/scil_count_non_zero_voxels.py b/scripts/scil_count_non_zero_voxels.py index d04b8824a..ebf252ca2 100755 --- a/scripts/scil_count_non_zero_voxels.py +++ b/scripts/scil_count_non_zero_voxels.py @@ -13,7 +13,10 @@ import argparse import os -from scilpy.image.utils import count_non_zero_voxels +import nibabel as nib +import numpy as np + +from scilpy.image.volume_operations import count_non_zero_voxels from scilpy.io.utils import assert_inputs_exist @@ -48,7 +51,9 @@ def main(): # out_filename can exist or not # Load image file - nb_voxels = count_non_zero_voxels(args.in_image) + im = nib.load(args.in_image).get_fdata(dtype=np.float32) + + nb_voxels = count_non_zero_voxels(im) if args.out_filename is not None: open_mode = 'w' diff --git a/scripts/scil_filter_connectivity.py b/scripts/scil_filter_connectivity.py index 026f23193..61752a118 100755 --- a/scripts/scil_filter_connectivity.py +++ b/scripts/scil_filter_connectivity.py @@ -36,7 +36,7 @@ import numpy as np -from scilpy.image.operations import invert +from scilpy.image.volume_math import invert from scilpy.io.utils import (add_overwrite_arg, add_verbose_arg, assert_outputs_exist, load_matrix_in_any_format, diff --git a/scripts/scil_flip_volume.py b/scripts/scil_flip_volume.py index f3b366d04..e0bb96f89 100755 --- a/scripts/scil_flip_volume.py +++ b/scripts/scil_flip_volume.py @@ -9,6 +9,7 @@ import nibabel as nib import numpy as np +from scilpy.image.volume_operations import flip_volume from scilpy.io.utils import (add_overwrite_arg, assert_inputs_exist, assert_outputs_exist) @@ -42,14 +43,7 @@ def main(): affine = vol.affine header = vol.header - if 'x' in args.axes: - data = data[::-1, ...] - - if 'y' in args.axes: - data = data[:, ::-1, ...] - - if 'z' in args.axes: - data = data[:, :, ::-1, ...] + data = flip_volume(data, args.axes) nib.save(nib.Nifti1Image(data, affine, header=header), args.out_image) diff --git a/scripts/scil_image_math.py b/scripts/scil_image_math.py index 26a4fb419..4819280c7 100755 --- a/scripts/scil_image_math.py +++ b/scripts/scil_image_math.py @@ -21,7 +21,7 @@ import nibabel as nib import numpy as np -from scilpy.image.operations import (get_image_ops, get_operations_doc) +from scilpy.image.volume_math import (get_image_ops, get_operations_doc) from scilpy.io.utils import (add_overwrite_arg, add_verbose_arg, assert_outputs_exist) diff --git a/scripts/scil_normalize_connectivity.py b/scripts/scil_normalize_connectivity.py index ff86ccea2..4c4b49d07 100755 --- a/scripts/scil_normalize_connectivity.py +++ b/scripts/scil_normalize_connectivity.py @@ -49,7 +49,7 @@ import numpy as np from scilpy.image.labels import get_data_as_labels -from scilpy.image.operations import normalize_max, normalize_sum, base_10_log +from scilpy.image.volume_math import normalize_max, normalize_sum, base_10_log from scilpy.io.utils import (add_overwrite_arg, assert_inputs_exist, assert_outputs_exist, diff --git a/scripts/scil_resample_volume.py b/scripts/scil_resample_volume.py index ce61da256..88ac7d0b4 100755 --- a/scripts/scil_resample_volume.py +++ b/scripts/scil_resample_volume.py @@ -13,7 +13,7 @@ from scilpy.io.utils import (add_verbose_arg, add_overwrite_arg, assert_inputs_exist, assert_outputs_exist) -from scilpy.image.resample_volume import resample_volume +from scilpy.image.volume_operations import resample_volume def _build_arg_parser(): diff --git a/scripts/scil_reshape_to_reference.py b/scripts/scil_reshape_to_reference.py index a9b62aaf5..4d04a8555 100755 --- a/scripts/scil_reshape_to_reference.py +++ b/scripts/scil_reshape_to_reference.py @@ -17,7 +17,7 @@ from scilpy.io.utils import (add_overwrite_arg, assert_inputs_exist, assert_outputs_exist) -from scilpy.utils.image import transform_anatomy +from scilpy.image.volume_operations import apply_transform def _build_arg_parser(): @@ -50,9 +50,9 @@ def main(): assert_inputs_exist(parser, [args.in_file, args.in_ref_file]) assert_outputs_exist(parser, args, args.out_file) - transform_anatomy(np.eye(4), args.in_ref_file, args.in_file, - args.out_file, interp=args.interpolation, - keep_dtype=args.keep_dtype) + apply_transform(np.eye(4), args.in_ref_file, args.in_file, + args.out_file, interp=args.interpolation, + keep_dtype=args.keep_dtype) if __name__ == "__main__": diff --git a/scripts/scil_screenshot_bundle.py b/scripts/scil_screenshot_bundle.py index d61a52dd9..137bc593f 100755 --- a/scripts/scil_screenshot_bundle.py +++ b/scripts/scil_screenshot_bundle.py @@ -36,7 +36,7 @@ add_verbose_arg, assert_inputs_exist, assert_outputs_exist) -from scilpy.utils.image import register_image +from scilpy.image.volume_operations import register_image from scilpy.viz.screenshot import display_slices from scilpy.viz.utils import get_colormap diff --git a/scripts/scil_screenshot_dti.py b/scripts/scil_screenshot_dti.py index de81a233d..83dae6856 100755 --- a/scripts/scil_screenshot_dti.py +++ b/scripts/scil_screenshot_dti.py @@ -23,7 +23,7 @@ assert_inputs_exist, assert_outputs_exist) from scilpy.utils.bvec_bval_tools import normalize_bvecs, get_shell_indices -from scilpy.utils.image import register_image +from scilpy.image.volume_operations import register_image from scilpy.viz.screenshot import display_slices diff --git a/scripts/scil_snr_in_roi.py b/scripts/scil_snr_in_roi.py index 93a4ac34c..70a2fe4fd 100755 --- a/scripts/scil_snr_in_roi.py +++ b/scripts/scil_snr_in_roi.py @@ -36,7 +36,7 @@ add_verbose_arg, assert_inputs_exist) from scilpy.utils.filenames import split_name_with_nii -from scilpy.utils.image import compute_snr +from scilpy.image.volume_operations import compute_snr def _build_arg_parser(): diff --git a/scripts/scil_visualize_connectivity.py b/scripts/scil_visualize_connectivity.py index f490a0324..4913e1b8a 100755 --- a/scripts/scil_visualize_connectivity.py +++ b/scripts/scil_visualize_connectivity.py @@ -36,7 +36,7 @@ from matplotlib.font_manager import FontProperties import numpy as np -from scilpy.image.operations import EPSILON +from scilpy.image.volume_math import EPSILON from scilpy.io.utils import (add_overwrite_arg, assert_inputs_exist, assert_outputs_exist, load_matrix_in_any_format) from scilpy.viz.chord_chart import chordDiagram, polar2xy