From e014c7b9babeee0b36ce5bc73f51d1a8a508cdad Mon Sep 17 00:00:00 2001 From: crousseau Date: Fri, 1 Oct 2021 12:32:58 +0200 Subject: [PATCH 01/87] Initial commit --- .gitignore | 115 +++++++++ .travis.yml | 98 ++++++++ LICENSE | 21 ++ README.md | 8 + imio/__init__.py | 0 imio/load.py | 482 ++++++++++++++++++++++++++++++++++++++ imio/save.py | 83 +++++++ imio/utils.py | 74 ++++++ pytest.ini | 2 + setup.py | 41 ++++ tests/tests/__init__.py | 0 tests/tests/test_imio.py | 63 +++++ travis/deploy_linux.sh | 3 + travis/install_unix.sh | 8 + travis/install_windows.sh | 31 +++ travis/test.sh | 4 + 16 files changed, 1033 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 imio/__init__.py create mode 100644 imio/load.py create mode 100644 imio/save.py create mode 100644 imio/utils.py create mode 100644 pytest.ini create mode 100644 setup.py create mode 100644 tests/tests/__init__.py create mode 100644 tests/tests/test_imio.py create mode 100644 travis/deploy_linux.sh create mode 100644 travis/install_unix.sh create mode 100644 travis/install_windows.sh create mode 100644 travis/test.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ce5f8d --- /dev/null +++ b/.gitignore @@ -0,0 +1,115 @@ +# Custom config files +*.conf.custom + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +doc/build/ + +# pydocmd +_build/ +mkdocs.yml + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +.idea/ + +*.~lock.* diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..82ecd1e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,98 @@ +after_success: + - pip install coveralls + - coveralls + +stages: + - test + - name: deploy + if: + tag IS present AND repo = adamltyson/imio + + +jobs: + include: + - stage: test + name: "Ubuntu Bionic python 3.6" + language: python + os: linux + env: MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh + dist: bionic + python: 3.6 + before_install: source travis/install_unix.sh + script: bash travis/test.sh + - stage: test + name: "Ubuntu Bionic python 3.7" + language: python + os: linux + env: MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh + dist: bionic + python: 3.7 + before_install: source travis/install_unix.sh + script: bash travis/test.sh + - stage: test + name: "Ubuntu Xenial python 3.6" + language: python + os: linux + env: MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh + dist: xenial + python: 3.6 + before_install: source travis/install_unix.sh + script: bash travis/test.sh + - stage: test + name: "Ubuntu Xenial python 3.7" + language: python + os: linux + env: MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh + dist: xenial + python: 3.7 + before_install: source travis/install_unix.sh + script: bash travis/test.sh + - stage: test + name: "Windows Python 3.6" + language: shell + env: TRAVIS_PYTHON_VERSION=3.6 + os: windows + before_install: source travis/install_windows.sh + script: bash travis/test.sh + - stage: test + name: "Windows Python 3.7" + language: shell + env: TRAVIS_PYTHON_VERSION=3.7 + os: windows + before_install: source travis/install_windows.sh + script: bash travis/test.sh + - stage: test + name: "macOS Python 3.6" + os: osx + language: shell + env: + - TRAVIS_PYTHON_VERSION=3.6 + - MINICONDA_URL=https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh + before_install: source travis/install_unix.sh + script: bash travis/test.sh + - stage: test + name: "macOS Python 3.7" + os: osx + language: shell + env: + - TRAVIS_PYTHON_VERSION=3.7 + - MINICONDA_URL=https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh + before_install: source travis/install_unix.sh + script: bash travis/test.sh + - stage: deploy + os: bionic + name: "Deploy Linux" + language: python + before_install: source travis/install_unix.sh + script: bash travis/deploy_linux.sh +notifications: + email: + recipients: + - adam.tyson@ucl.ac.uk + on_success: change + on_failure: always + +env: + global: + - TWINE_USERNAME=__token__ + # TWINE_PASSWORD is set to a PyPI API token in Travis settings \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f18c80c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Adam Tyson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ece47b7 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# imio +Loading and saving of image data. + + +### To install +```bash +pip install imio +``` diff --git a/imio/__init__.py b/imio/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/imio/load.py b/imio/load.py new file mode 100644 index 0000000..30602b4 --- /dev/null +++ b/imio/load.py @@ -0,0 +1,482 @@ +import os +import math +import nrrd +import logging +import tifffile +import warnings +import numpy as np + +from skimage import transform +from tqdm import tqdm +from natsort import natsorted +from concurrent.futures import ProcessPoolExecutor + +from imlib.general.system import get_sorted_file_paths, get_num_processes + +from .utils import check_mem, scale_z + +with warnings.catch_warnings(): + warnings.simplefilter("ignore") + import nibabel as nib + + +def load_any( + src_path, + x_scaling_factor=1.0, + y_scaling_factor=1.0, + z_scaling_factor=1.0, + anti_aliasing=True, + load_parallel=False, + sort_input_file=False, + as_numpy=False, + n_free_cpus=2, +): + """ + This function will guess the type of data and hence call the appropriate + function from this module to load the given brain. + + .. warning:: x and y scaling not used at the moment if loading a + complete image + + :param str src_path: Can be the path of a nifty file, tiff file, + tiff files folder or text file containing a list of paths + :param float x_scaling_factor: The scaling of the brain along the x + dimension (applied on loading before return) + :param float y_scaling_factor: The scaling of the brain along the y + dimension (applied on loading before return) + :param float z_scaling_factor: The scaling of the brain along the z + dimension (applied on loading before return) + :param bool anti_aliasing: Whether to apply a Gaussian filter to smooth + the image prior to down-scaling. It is crucial to filter when + down-sampling the image to avoid aliasing artifacts. + :param bool load_parallel: Load planes in parallel using multiprocessing + for faster data loading + :param bool sort_input_file: If set to true and the input is a filepaths + file, it will be naturally sorted + :param bool as_numpy: Whether to convert the image to a numpy array in + memory (rather than a memmap). Only relevant for .nii files. + :param bool verbose: Print more information about the process + :param int n_free_cpus: Number of cpu cores to leave free. + :return: The loaded brain + :rtype: np.ndarray + """ + src_path = str(src_path) + + if os.path.isdir(src_path): + logging.debug("Data type is: directory of files") + img = load_from_folder( + src_path, + x_scaling_factor, + y_scaling_factor, + z_scaling_factor, + anti_aliasing=anti_aliasing, + file_extension=".tif", + load_parallel=load_parallel, + n_free_cpus=n_free_cpus, + ) + elif src_path.endswith(".txt"): + logging.debug("Data type is: list of file paths") + img = load_img_sequence( + src_path, + x_scaling_factor, + y_scaling_factor, + z_scaling_factor, + anti_aliasing=anti_aliasing, + load_parallel=load_parallel, + sort=sort_input_file, + n_free_cpus=n_free_cpus, + ) + elif src_path.endswith((".tif", ".tiff")): + logging.debug("Data type is: tif stack") + img = load_img_stack( + src_path, + x_scaling_factor, + y_scaling_factor, + z_scaling_factor, + anti_aliasing=anti_aliasing, + ) + elif src_path.endswith(".nrrd"): + logging.debug("Data type is: nrrd") + img = load_nrrd(src_path) + elif src_path.endswith((".nii", ".nii.gz")): + logging.debug("Data type is: NifTI") + img = load_nii(src_path, as_array=True, as_numpy=as_numpy) + else: + raise NotImplementedError( + "Could not guess data type for path {}".format(src_path) + ) + + return img + + +def load_nrrd(src_path): + """ + Load an .nrrd file as a numpy array + + :param str src_path: The path of the image to be loaded + :return: The loaded brain array + :rtype: np.ndarray + """ + src_path = str(src_path) + stack, _ = nrrd.read(src_path) + return stack + + +def load_img_stack( + stack_path, + x_scaling_factor, + y_scaling_factor, + z_scaling_factor, + anti_aliasing=True, +): + """ + Load a tiff stack as a numpy array + + :param str stack_path: The path of the image to be loaded + :param float x_scaling_factor: The scaling of the brain along the x + dimension (applied on loading before return) + :param float y_scaling_factor: The scaling of the brain along the y + dimension (applied on loading before return) + :param float z_scaling_factor: The scaling of the brain along the z + dimension (applied on loading before return) + :param bool anti_aliasing: Whether to apply a Gaussian filter to smooth + the image prior to down-scaling. It is crucial to filter when + down-sampling the image to avoid aliasing artifacts. + :return: The loaded brain array + :rtype: np.ndarray + """ + stack_path = str(stack_path) + logging.debug(f"Loading: {stack_path}") + stack = tifffile.imread(stack_path) + + # Downsampled plane by plane because the 3D downsampling in scipy etc + # uses too much RAM + + if not (x_scaling_factor == y_scaling_factor == 1): + downsampled_stack = [] + logging.debug("Downsampling stack in X/Y") + for plane in tqdm(range(0, len(stack))): + downsampled_stack.append( + transform.rescale( + stack[plane], + (y_scaling_factor, x_scaling_factor), + mode="constant", + preserve_range=True, + anti_aliasing=anti_aliasing, + ) + ) + + logging.debug("Converting downsampled stack to array") + stack = np.array(downsampled_stack) + + if stack.ndim == 3: + stack = np.rollaxis(stack, 0, 3) + if z_scaling_factor != 1: + logging.debug("Downsampling stack in Z") + stack = scale_z(stack, z_scaling_factor) + return stack + + +def load_nii(src_path, as_array=False, as_numpy=False): + """ + Load a brain from a nifti file + + :param str src_path: The path to the nifty file on the filesystem + :param bool as_array: Whether to convert the brain to a numpy array of + keep it as nifty object + :param bool as_numpy: Whether to convert the image to a numpy array in + memory (rather than a memmap) + :return: The loaded brain (format depends on the above flag) + """ + src_path = str(src_path) + nii_img = nib.load(src_path) + if as_array: + image = nii_img.get_data() + if as_numpy: + image = np.array(image) + + return image + else: + return nii_img + + +def load_from_folder( + src_folder, + x_scaling_factor, + y_scaling_factor, + z_scaling_factor, + anti_aliasing=True, + file_extension="", + load_parallel=False, + n_free_cpus=2, +): + """ + Load a brain from a folder. All tiff files will be read sorted and assumed + to belong to the same sample. + Optionally a name_filter string can be supplied which will have to be + present in the file names for them + to be considered part of the sample + + :param str src_folder: + :param float x_scaling_factor: The scaling of the brain along the x + dimension (applied on loading before return) + :param float y_scaling_factor: The scaling of the brain along the y + dimension (applied on loading before return) + :param float z_scaling_factor: The scaling of the brain along the z + dimension + :param bool anti_aliasing: Whether to apply a Gaussian filter to smooth + the image prior to down-scaling. It is crucial to filter when + down-sampling the image to avoid aliasing artifacts. + :param str file_extension: will have to be present in the file names for them\ + to be considered part of the sample + :param bool load_parallel: Use multiprocessing to speedup image loading + :param int n_free_cpus: Number of cpu cores to leave free. + :return: The loaded and scaled brain + :rtype: np.ndarray + """ + paths = get_sorted_file_paths(src_folder, file_extension=file_extension) + + return load_image_series( + paths, + x_scaling_factor, + y_scaling_factor, + z_scaling_factor, + load_parallel=load_parallel, + n_free_cpus=n_free_cpus, + anti_aliasing=anti_aliasing, + ) + + +def load_img_sequence( + img_sequence_file_path, + x_scaling_factor, + y_scaling_factor, + z_scaling_factor, + anti_aliasing=True, + load_parallel=False, + sort=False, + n_free_cpus=2, +): + """ + Load a brain from a sequence of files specified in a text file containing + an ordered list of paths + + :param str img_sequence_file_path: The path to the file containing the + ordered list of image paths (one per line) + :param float x_scaling_factor: The scaling of the brain along the x + dimension (applied on loading before return) + :param float y_scaling_factor: The scaling of the brain along the y + dimension (applied on loading before return) + :param float z_scaling_factor: The scaling of the brain along the z + dimension + :param bool anti_aliasing: Whether to apply a Gaussian filter to smooth + the image prior to down-scaling. It is crucial to filter when + down-sampling the image to avoid aliasing artifacts. + :param bool load_parallel: Use multiprocessing to speedup image loading + :param bool sort: If set to true will perform a natural sort of the + file paths in the list + :param int n_free_cpus: Number of cpu cores to leave free. + :return: The loaded and scaled brain + :rtype: np.ndarray + """ + img_sequence_file_path = str(img_sequence_file_path) + with open(img_sequence_file_path, "r") as in_file: + paths = in_file.readlines() + paths = [p.strip() for p in paths] + if sort: + paths = natsorted(paths) + + return load_image_series( + paths, + x_scaling_factor, + y_scaling_factor, + z_scaling_factor, + load_parallel=load_parallel, + n_free_cpus=n_free_cpus, + anti_aliasing=anti_aliasing, + ) + + +def load_image_series( + paths, + x_scaling_factor, + y_scaling_factor, + z_scaling_factor, + anti_aliasing=True, + load_parallel=False, + n_free_cpus=2, +): + """ + Load a brain from a sequence of files specified in a text file containing + an ordered list of paths + + :param lost paths: Ordered list of image paths + :param float x_scaling_factor: The scaling of the brain along the x + dimension (applied on loading before return) + :param float y_scaling_factor: The scaling of the brain along the y + dimension (applied on loading before return) + :param float z_scaling_factor: The scaling of the brain along the z + dimension + :param bool anti_aliasing: Whether to apply a Gaussian filter to smooth + the image prior to down-scaling. It is crucial to filter when + down-sampling the image to avoid aliasing artifacts. + :param bool load_parallel: Use multiprocessing to speedup image loading + :param int n_free_cpus: Number of cpu cores to leave free. + :return: The loaded and scaled brain + :rtype: np.ndarray + """ + + if load_parallel: + img = threaded_load_from_sequence( + paths, + x_scaling_factor, + y_scaling_factor, + n_free_cpus=n_free_cpus, + anti_aliasing=anti_aliasing, + ) + else: + img = load_from_paths_sequence( + paths, + x_scaling_factor, + y_scaling_factor, + anti_aliasing=anti_aliasing, + ) + if z_scaling_factor != 1: + img = scale_z(img, z_scaling_factor) + + return img + + +def threaded_load_from_sequence( + paths_sequence, + x_scaling_factor=1.0, + y_scaling_factor=1.0, + anti_aliasing=True, + n_free_cpus=2, +): + """ + Use multiprocessing to load a brain from a sequence of image paths. + + :param list paths_sequence: The sorted list of the planes paths on the + filesystem + :param float x_scaling_factor: The scaling of the brain along the x + dimension (applied on loading before return) + :param float y_scaling_factor: The scaling of the brain along the y + dimension (applied on loading before return) + :param bool anti_aliasing: Whether to apply a Gaussian filter to smooth + the image prior to down-scaling. It is crucial to filter when + down-sampling the image to avoid aliasing artifacts. + :param int n_free_cpus: Number of cpu cores to leave free. + :return: The loaded and scaled brain + :rtype: np.ndarray + """ + + stacks = [] + n_processes = get_num_processes(min_free_cpu_cores=n_free_cpus) + + # WARNING: will not work with interactive interpreter. + pool = ProcessPoolExecutor(max_workers=n_processes) + # FIXME: should detect and switch to other method + + n_paths_per_subsequence = math.ceil(len(paths_sequence) / n_processes) + for i in range(n_processes): + start_idx = i * n_paths_per_subsequence + if start_idx >= len(paths_sequence): + break + else: + end_idx = start_idx + n_paths_per_subsequence + end_idx = end_idx if end_idx < len(paths_sequence) else -1 + sub_paths = paths_sequence[start_idx:end_idx] + + process = pool.submit( + load_from_paths_sequence, + sub_paths, + x_scaling_factor, + y_scaling_factor, + anti_aliasing=anti_aliasing, + ) + stacks.append(process) + stack = np.dstack([s.result() for s in stacks]) + return stack + + +def load_from_paths_sequence( + paths_sequence, + x_scaling_factor=1.0, + y_scaling_factor=1.0, + anti_aliasing=True, +): + # TODO: Optimise - load threaded and process by batch + """ + A single core version of the function to load a brain from a sequence of + image paths. + + :param list paths_sequence: The sorted list of the planes paths on the + filesystem + :param float x_scaling_factor: The scaling of the brain along the x + dimension (applied on loading before return) + :param float y_scaling_factor: The scaling of the brain along the y + dimension (applied on loading before return) + :param bool anti_aliasing: Whether to apply a Gaussian filter to smooth + the image prior to down-scaling. It is crucial to filter when + down-sampling the image to avoid aliasing artifacts. + :return: The loaded and scaled brain + :rtype: np.ndarray + """ + for i, p in enumerate( + tqdm(paths_sequence, desc="Loading images", unit="plane") + ): + img = tifffile.imread(p) + if i == 0: + check_mem( + img.nbytes * x_scaling_factor * y_scaling_factor, + len(paths_sequence), + ) + # TEST: add test case for shape rounding + volume = np.empty( + ( + int(round(img.shape[0] * x_scaling_factor)), + int(round(img.shape[1] * y_scaling_factor)), + len(paths_sequence), + ), + dtype=img.dtype, + ) + if x_scaling_factor != 1 and y_scaling_factor != 1: + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + img = transform.rescale( + img, + (x_scaling_factor, y_scaling_factor), + mode="constant", + preserve_range=True, + anti_aliasing=anti_aliasing, + ) + volume[:, :, i] = img + return volume + + +def generate_paths_sequence_file( + input_folder, + output_file_path, + sort=True, + prefix=None, + suffix=None, + match_string=None, +): + input_folder = str(input_folder) + paths = [] + for root, dirs, files in os.walk(input_folder): + for filename in files: + if prefix is not None and not filename.startswith(prefix): + continue + if suffix is not None and not filename.endswith(suffix): + continue + if match_string is not None and match_string not in filename: + continue + paths.append(os.path.join(root, filename)) + + if sort: + paths = natsorted(paths) + + with open(output_file_path, "w") as out_file: + out_file.writelines(paths) diff --git a/imio/save.py b/imio/save.py new file mode 100644 index 0000000..c999f70 --- /dev/null +++ b/imio/save.py @@ -0,0 +1,83 @@ +import os +import math +import nrrd +import logging +import tifffile +import warnings +import numpy as np + +from skimage import transform +from tqdm import tqdm +from natsort import natsorted +from concurrent.futures import ProcessPoolExecutor + +from imlib.general.system import get_sorted_file_paths, get_num_processes + +from .utils import check_mem, scale_z + +with warnings.catch_warnings(): + warnings.simplefilter("ignore") + import nibabel as nib + + +def to_nii(img, dest_path, scale=None, affine_transform=None): + # TODO: see if we want also real units scale + + """ + Write the brain volume to disk as nifty image. + + :param img: A nifty image object or numpy array brain + :param str dest_path: The path where to save the brain. + :param tuple scale: A tuple of floats to indicate the 'zooms' of the nifty + image + :param np.ndarray affine_transform: A 4x4 matrix indicating the transform + to save in the metadata of the image (required only if not nibabel input) + :return: + """ + dest_path = str(dest_path) + if affine_transform is None: + affine_transform = np.eye(4) + if not isinstance(img, nib.Nifti1Image): + img = nib.Nifti1Image(img, affine_transform) + if scale is not None: + img.header.set_zooms(scale) + nib.save(img, dest_path) + + +def to_tiff(img_volume, dest_path): + """ + Saves the image volume (numpy array) to a tiff stack + + :param np.ndarray img_volume: The image to be saved + :param dest_path: Where to save the tiff stack + :return: + """ + dest_path = str(dest_path) + tifffile.imsave(dest_path, img_volume) + + +def to_tiffs(img_volume, path_prefix, path_suffix="", pad_width=4): + """ + Save the image volume (numpy array) as a sequence of tiff planes. + Each plane will have a filepath of the following for: + pathprefix_zeroPaddedIndex_suffix.tif + + :param np.ndarray img_volume: The image to be saved + :param str path_prefix: The prefix for each plane + :param str path_suffix: The suffix for each plane + :param int pad_width: The number of digits on which the index of the + image (z plane number) will be padded + :return: + """ + z_size = img_volume.shape[-1] + if z_size > 10 ** pad_width: + raise ValueError( + "Not enough padding digits {} for value" + " {}".format(pad_width, z_size) + ) + for i in range(z_size): + img = img_volume[:, :, i] + dest_path = "{}_{}{}.tif".format( + path_prefix, str(i).zfill(pad_width), path_suffix + ) + tifffile.imsave(dest_path, img) diff --git a/imio/utils.py b/imio/utils.py new file mode 100644 index 0000000..226849d --- /dev/null +++ b/imio/utils.py @@ -0,0 +1,74 @@ +import logging +import os +import glob +import psutil + +import numpy as np +from scipy.ndimage import zoom + +from natsort import natsorted +from slurmio import slurmio + + +class ImioLoadException(Exception): + pass + + +def check_mem(img_byte_size, n_imgs): + """ + Check how much memory is available on the system and compares it to the + size the stack specified by img_byte_size and n_imgs would take + once loaded + + Raises an error in case memory is insufficient to load that stack + + :param int img_byte_size: The size in bytes of an individual image plane + :param int n_imgs: The number of image planes to load + :raises: BrainLoadException if not enough memory is available + """ + total_size = img_byte_size * n_imgs + free_mem = psutil.virtual_memory().available + if total_size >= free_mem: + raise ImioLoadException( + "Not enough memory on the system to complete loading operation" + "Needed {}, only {} available.".format(total_size, free_mem) + ) + + +def scale_z(volume, scaling_factor): + """ + Scale the given brain along the z dimension + + :param np.ndarray volume: A brain typically as a numpy array + :param float scaling_factor: + :return: + """ + + volume = np.swapaxes(volume, 1, 2) + volume = zoom(volume, (1, scaling_factor, 1), order=1) + return np.swapaxes(volume, 1, 2) + + +def get_size_image_from_file_paths(file_path, file_extension="tif"): + """ + Returns the size of an image (which is a list of 2D files), without loading + the whole image + :param str file_path: File containing file_paths in a text file, + or as a list. + :param str file_extension: Optional file extension (if a directory + is passed) + :return: Dict of image sizes + """ + file_path = str(file_path) + + img_paths = get_sorted_file_paths(file_path, file_extension=file_extension) + z_shape = len(img_paths) + + logging.debug( + "Loading file: {} to check raw image size" "".format(img_paths[0]) + ) + image_0 = load_any(img_paths[0]) + y_shape, x_shape = image_0.shape + + image_shape = {"x": x_shape, "y": y_shape, "z": z_shape} + return image_shape diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..0bfb381 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --cov=imio diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..21269a1 --- /dev/null +++ b/setup.py @@ -0,0 +1,41 @@ +from setuptools import setup, find_packages + +requirements = [ + "numpy", + "scikit-image", + "tifffile", + "pynrrd", + "nibabel", + "tqdm", + "natsort", + "psutil", + "slurmio >= 0.0.5", + "imlib", + "nibabel >= 2.1.0", +] + +setup( + name="imio", + version="0.0.1a", + description="Loading and saving of image data.", + install_requires=requirements, + extras_require={"dev": ["black", "pytest-cov", "pytest", "coverage",]}, + python_requires=">=3.6", + packages=find_packages(), + include_package_data=True, + url="https://github.com/adamltyson/imio", + author="Adam Tyson", + author_email="adam.tyson@ucl.ac.uk", + classifiers=[ + "Development Status :: 3 - Alpha", + "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows :: Windows 10", + "Programming Language :: Python", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + ], + zip_safe=False, +) diff --git a/tests/tests/__init__.py b/tests/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/tests/test_imio.py b/tests/tests/test_imio.py new file mode 100644 index 0000000..35bdd4d --- /dev/null +++ b/tests/tests/test_imio.py @@ -0,0 +1,63 @@ +import os +import pytest + +import numpy as np + +from tifffile import tifffile +from imio import load, save, utils + + +@pytest.fixture() +def layer(): + return np.tile(np.array([1, 2, 3, 4]), (4, 1)) + + +@pytest.fixture() +def start_array(layer): + volume = np.dstack((layer, 2 * layer, 3 * layer, 4 * layer)) + return volume + + +def test_tiff_io(tmpdir, layer): + folder = str(tmpdir) + dest_path = os.path.join(folder, "layer.tiff") + tifffile.imsave(dest_path, layer) + reloaded = tifffile.imread(dest_path) + assert (reloaded == layer).all() + + +def test_to_tiffs(tmpdir, start_array): + folder = str(tmpdir) + save.to_tiffs(start_array, os.path.join(folder, "start_array")) + reloaded_array = load.load_from_folder(folder, 1, 1, 1) + assert (reloaded_array == start_array).all() + + +def test_load_img_sequence(tmpdir, start_array): + folder = str(tmpdir.mkdir("sub")) + save.to_tiffs(start_array, os.path.join(folder, "start_array")) + img_sequence_file = tmpdir.join("imgs_file.txt") + img_sequence_file.write( + "\n".join( + [ + os.path.join(folder, fname) + for fname in sorted(os.listdir(folder)) + ] + ) + ) + reloaded_array = load.load_img_sequence(str(img_sequence_file), 1, 1, 1) + assert (reloaded_array == start_array).all() + + +def test_to_nii(tmpdir, start_array): # Also tests load_nii + folder = str(tmpdir) + nii_path = os.path.join(folder, "test_array.nii") + save.to_nii(start_array, nii_path) + assert (load.load_nii(nii_path).get_data() == start_array).all() + + +def test_scale_z(start_array): + assert ( + utils.scale_z(start_array, 0.5).shape[-1] == start_array.shape[-1] / 2 + ) + assert utils.scale_z(start_array, 2).shape[-1] == start_array.shape[-1] * 2 diff --git a/travis/deploy_linux.sh b/travis/deploy_linux.sh new file mode 100644 index 0000000..fddde26 --- /dev/null +++ b/travis/deploy_linux.sh @@ -0,0 +1,3 @@ +python setup.py bdist_wheel sdist +pip install twine +twine upload dist/* --skip-existing diff --git a/travis/install_unix.sh b/travis/install_unix.sh new file mode 100644 index 0000000..b3f5dbd --- /dev/null +++ b/travis/install_unix.sh @@ -0,0 +1,8 @@ +wget $MINICONDA_URL -O miniconda.sh; +bash miniconda.sh -b -p $HOME/miniconda +export PATH="$HOME/miniconda/bin:$PATH" +hash -r +conda config --set always_yes yes --set changeps1 no +conda info -a +conda create -n test-environment python=$TRAVIS_PYTHON_VERSION +source activate test-environment diff --git a/travis/install_windows.sh b/travis/install_windows.sh new file mode 100644 index 0000000..b0ce091 --- /dev/null +++ b/travis/install_windows.sh @@ -0,0 +1,31 @@ +export MINICONDA_PATH=$HOME/miniconda; +export MINICONDA_PATH_WIN=`cygpath --windows $MINICONDA_PATH`; +export MINICONDA_SUB_PATH=$MINICONDA_PATH/Scripts; +export MINICONDA_LIB_BIN_PATH=$MINICONDA_PATH/Library/bin; + +choco install openssl.light; + +echo "folder $MINICONDA_SUB_PATH does not exist" +echo "installing miniconda for windows"; +choco install miniconda3 --params="'/JustMe /AddToPath:1 /D:$MINICONDA_PATH_WIN'"; + +export PATH="$MINICONDA_PATH:$MINICONDA_SUB_PATH:$MINICONDA_LIB_BIN_PATH:$PATH"; + +# begin checking miniconda existance +echo "checking if folder $MINICONDA_SUB_PATH exists" +if [[ -d $MINICONDA_SUB_PATH ]]; then + echo "folder $MINICONDA_SUB_PATH exists" +else + echo "folder $MINICONDA_SUB_PATH does not exist" +fi; +# end checking miniconda existance + +source $MINICONDA_PATH/etc/profile.d/conda.sh; +hash -r; +python --version +conda config --set always_yes yes --set changeps1 no; +conda update -q conda; +conda info -a + +conda create -n test-environment python=$TRAVIS_PYTHON_VERSION +source activate test-environment diff --git a/travis/test.sh b/travis/test.sh new file mode 100644 index 0000000..5691b63 --- /dev/null +++ b/travis/test.sh @@ -0,0 +1,4 @@ +pip install -e .[dev] +conda info -a +black ./ -l 79 --target-version py37 --check +pytest --cov=imio \ No newline at end of file From 4a20910fd945e12fd8980748cde9fe5a7fee8c2d Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 15 Jul 2020 19:10:37 +0100 Subject: [PATCH 02/87] bump --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 21269a1..87b013a 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.0.1a", + version="0.0.1", description="Loading and saving of image data.", install_requires=requirements, extras_require={"dev": ["black", "pytest-cov", "pytest", "coverage",]}, From c74a57e05a2c2907446af65d136ca58aa3fb6171 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 15 Jul 2020 20:01:42 +0100 Subject: [PATCH 03/87] bump --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 87b013a..64fc507 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.0.1", + version="0.0.2", description="Loading and saving of image data.", install_requires=requirements, extras_require={"dev": ["black", "pytest-cov", "pytest", "coverage",]}, From 4e767140e24fbf27d4b151dd7f2b0e0f6819dc80 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 15 Jul 2020 20:02:08 +0100 Subject: [PATCH 04/87] bump --- imio/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imio/__init__.py b/imio/__init__.py index e69de29..9ece77b 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -0,0 +1,6 @@ +__author__ = "Adam Tyson, Charly Rousseau" +__version__ = "0.0.2" + +from imio.load import * +from imio.save import * +from imio.utils import * From 1a386cf578bcf81561a51e5f1414c7e9f1eb063c Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 16 Jul 2020 17:51:45 +0100 Subject: [PATCH 05/87] add bump2version --- setup.cfg | 13 +++++++++++++ setup.py | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..f2b5995 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,13 @@ +[bumpversion] +current_version = 0.0.2 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version="{current_version}" +replace = version="{new_version}" + +[bumpversion:file:imio/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + diff --git a/setup.py b/setup.py index 64fc507..da226c4 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,9 @@ version="0.0.2", description="Loading and saving of image data.", install_requires=requirements, - extras_require={"dev": ["black", "pytest-cov", "pytest", "coverage",]}, + extras_require={ + "dev": ["black", "pytest-cov", "pytest", "coverage", "bump2version"] + }, python_requires=">=3.6", packages=find_packages(), include_package_data=True, From 09d0378eeeb70834a577fae1a5423f436a387906 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 16 Jul 2020 17:51:49 +0100 Subject: [PATCH 06/87] =?UTF-8?q?Bump=20version:=200.0.2=20=E2=86=92=200.0?= =?UTF-8?q?.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 3 +-- setup.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index 9ece77b..85eb9a4 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Adam Tyson, Charly Rousseau" -__version__ = "0.0.2" +__version__ = "0.0.3" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index f2b5995..9527d6e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.0.2 +current_version = 0.0.3 commit = True tag = True @@ -10,4 +10,3 @@ replace = version="{new_version}" [bumpversion:file:imio/__init__.py] search = __version__ = "{current_version}" replace = __version__ = "{new_version}" - diff --git a/setup.py b/setup.py index da226c4..95a746e 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.0.2", + version="0.0.3", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From 8c2c522074cd19f6b8421b17f4b13bd015153068 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 16 Jul 2020 18:33:31 +0100 Subject: [PATCH 07/87] add pre commit hooks --- .pre-commit-config.yaml | 11 +++++++++++ imio/load.py | 4 ++-- imio/save.py | 3 ++- imio/utils.py | 1 - pyproject.toml | 16 ++++++++++++++++ setup.cfg | 6 ++++++ setup.py | 10 +++++++++- tests/tests/test_imio.py | 1 + 8 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9c975a0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +repos: +- repo: https://github.com/python/black + rev: 19.10b0 + hooks: + - id: black + pass_filenames: true +- repo: https://gitlab.com/pycqa/flake8 + rev: 3.7.9 + hooks: + - id: flake8 + pass_filenames: true diff --git a/imio/load.py b/imio/load.py index 30602b4..12bd4e6 100644 --- a/imio/load.py +++ b/imio/load.py @@ -227,8 +227,8 @@ def load_from_folder( :param bool anti_aliasing: Whether to apply a Gaussian filter to smooth the image prior to down-scaling. It is crucial to filter when down-sampling the image to avoid aliasing artifacts. - :param str file_extension: will have to be present in the file names for them\ - to be considered part of the sample + :param str file_extension: will have to be present in the file names for + them to be considered part of the sample :param bool load_parallel: Use multiprocessing to speedup image loading :param int n_free_cpus: Number of cpu cores to leave free. :return: The loaded and scaled brain diff --git a/imio/save.py b/imio/save.py index c999f70..c45dddc 100644 --- a/imio/save.py +++ b/imio/save.py @@ -31,7 +31,8 @@ def to_nii(img, dest_path, scale=None, affine_transform=None): :param tuple scale: A tuple of floats to indicate the 'zooms' of the nifty image :param np.ndarray affine_transform: A 4x4 matrix indicating the transform - to save in the metadata of the image (required only if not nibabel input) + to save in the metadata of the image + (required only if not nibabel input) :return: """ dest_path = str(dest_path) diff --git a/imio/utils.py b/imio/utils.py index 226849d..740eb03 100644 --- a/imio/utils.py +++ b/imio/utils.py @@ -3,7 +3,6 @@ import glob import psutil -import numpy as np from scipy.ndimage import zoom from natsort import natsorted diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9bd6669 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[tool.black] +line-length = 79 +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist +)/ +''' \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 9527d6e..d2a1820 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,3 +10,9 @@ replace = version="{new_version}" [bumpversion:file:imio/__init__.py] search = __version__ = "{current_version}" replace = __version__ = "{new_version}" + +[flake8] +ignore = E203, E231, W503 +max-line-length = 79 +;max-complexity = 5 +exclude = __init__.py \ No newline at end of file diff --git a/setup.py b/setup.py index 95a746e..248e9ca 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,15 @@ description="Loading and saving of image data.", install_requires=requirements, extras_require={ - "dev": ["black", "pytest-cov", "pytest", "coverage", "bump2version"] + "dev": [ + "black", + "pytest-cov", + "pytest", + "coverage", + "bump2version", + "pre-commit", + "flake8", + ] }, python_requires=">=3.6", packages=find_packages(), diff --git a/tests/tests/test_imio.py b/tests/tests/test_imio.py index 35bdd4d..438f445 100644 --- a/tests/tests/test_imio.py +++ b/tests/tests/test_imio.py @@ -4,6 +4,7 @@ import numpy as np from tifffile import tifffile + from imio import load, save, utils From 6de2eed99ff70aea8e48fe7fb3457d26322e45ad Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 16 Jul 2020 18:35:01 +0100 Subject: [PATCH 08/87] update testing --- .travis.yml | 10 ++++++++++ travis/lint.sh | 12 ++++++++++++ travis/test.sh | 1 - 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 travis/lint.sh diff --git a/.travis.yml b/.travis.yml index 82ecd1e..01f14c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ after_success: stages: - test + - lint - name: deploy if: tag IS present AND repo = adamltyson/imio @@ -11,6 +12,15 @@ stages: jobs: include: + - stage: lint + name: "Lint" + language: python + os: linux + env: MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh + dist: bionic + python: 3.7 + before_install: source travis/install_unix.sh + script: bash travis/lint.sh - stage: test name: "Ubuntu Bionic python 3.6" language: python diff --git a/travis/lint.sh b/travis/lint.sh new file mode 100644 index 0000000..6bdbb3e --- /dev/null +++ b/travis/lint.sh @@ -0,0 +1,12 @@ +wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; +bash miniconda.sh -b -p $HOME/miniconda +export PATH="$HOME/miniconda/bin:$PATH" +hash -r +conda config --set always_yes yes --set changeps1 no +conda info -a +conda create -n test-environment python=$TRAVIS_PYTHON_VERSION +source activate test-environment +pip install -e .[dev] +conda info -a +black ./ -l 79 --target-version py37 --check +flake8 diff --git a/travis/test.sh b/travis/test.sh index 5691b63..9ee2c81 100644 --- a/travis/test.sh +++ b/travis/test.sh @@ -1,4 +1,3 @@ pip install -e .[dev] conda info -a -black ./ -l 79 --target-version py37 --check pytest --cov=imio \ No newline at end of file From 4a6d0388bf227321d102592bdaf92ff4f4a2449c Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 16 Jul 2020 18:40:09 +0100 Subject: [PATCH 09/87] reorder ci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 01f14c0..001bf47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ after_success: - coveralls stages: - - test - lint + - test - name: deploy if: tag IS present AND repo = adamltyson/imio From 8e6ae654fd859430cf7a9e679d3eefee79806935 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 5 Nov 2020 11:15:15 +0000 Subject: [PATCH 10/87] fix non-istropic loading error --- imio/load.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imio/load.py b/imio/load.py index 12bd4e6..4f862aa 100644 --- a/imio/load.py +++ b/imio/load.py @@ -441,7 +441,7 @@ def load_from_paths_sequence( ), dtype=img.dtype, ) - if x_scaling_factor != 1 and y_scaling_factor != 1: + if x_scaling_factor != 1 or y_scaling_factor != 1: with warnings.catch_warnings(): warnings.simplefilter("ignore") img = transform.rescale( From 9a77dcd432e76ea40a1848f036209b5c29587e31 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 5 Nov 2020 11:15:29 +0000 Subject: [PATCH 11/87] =?UTF-8?q?Bump=20version:=200.0.3=20=E2=86=92=200.0?= =?UTF-8?q?.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 5 ++--- setup.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index 85eb9a4..e5dc458 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Adam Tyson, Charly Rousseau" -__version__ = "0.0.3" +__version__ = "0.0.4" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index d2a1820..f31fec4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.0.3 +current_version = 0.0.4 commit = True tag = True @@ -14,5 +14,4 @@ replace = __version__ = "{new_version}" [flake8] ignore = E203, E231, W503 max-line-length = 79 -;max-complexity = 5 -exclude = __init__.py \ No newline at end of file +exclude = __init__.py diff --git a/setup.py b/setup.py index 248e9ca..c23e3ab 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.0.3", + version="0.0.4", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From 9722889d9105b9c2db9b596f7fa71f82b020d5fb Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 25 Nov 2020 19:22:19 +0000 Subject: [PATCH 12/87] Gh actions (#3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add gh actions * Update testing * update testing * add lint * coveralls * coveralls * deploy * Bump version: 0.0.4 → 0.0.5 * update readme --- .github/workflows/test_and_deploy.yml | 74 +++++++++++++++++++++++++++ README.md | 33 ++++++++++++ imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- tests/__init__.py | 0 6 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test_and_deploy.yml create mode 100644 tests/__init__.py diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml new file mode 100644 index 0000000..f408e58 --- /dev/null +++ b/.github/workflows/test_and_deploy.yml @@ -0,0 +1,74 @@ +name: tests + +on: push + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install .[dev] + - name: Lint + run: | + black ./ --check + flake8 + test: + needs: lint + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.7, 3.8] + exclude: + - os: macos-latest + python-version: 3.7 + - os: windows-latest + python-version: 3.7 + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install .[dev] + - name: Test + run: pytest + - name: Coveralls + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + pip install coveralls + coveralls + + deploy: + needs: test + runs-on: ubuntu-latest + if: contains(github.ref, 'tags') + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U setuptools setuptools_scm wheel twine + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} + run: | + git tag + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/README.md b/README.md index ece47b7..4e9d346 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,39 @@ +[![Python Version](https://img.shields.io/pypi/pyversions/imio.svg)](https://pypi.org/project/imio) +[![PyPI](https://img.shields.io/pypi/v/imio.svg)](https://pypi.org/project/imio) +[![Downloads](https://pepy.tech/badge/imio)](https://pepy.tech/project/imio) +[![Wheel](https://img.shields.io/pypi/wheel/imio.svg)](https://pypi.org/project/imio) +[![Development Status](https://img.shields.io/pypi/status/imio.svg)](https://github.com/adamltyson/imio) +[![Tests](https://img.shields.io/github/workflow/status/adamltyson/imio/tests)]( + https://github.com/adamltyson/imio/actions) +[![Coverage Status](https://coveralls.io/repos/github/adamltyson/imio/badge.svg?branch=master)](https://coveralls.io/github/adamltyson/imio?branch=master) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) +[![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/adamltyson/imio) + + # imio Loading and saving of image data. +### About +The aim of imio is to be a lightweight image loading library for the file types + supported by [cellfinder](https://github.com/brainglobe/cellfinder), and + [brainreg](https://github.com/brainglobe/brainreg). It is an update to + [brainio](https://github.com/adamltyson/brainio). + +#### Supports loading of: +* Tiff stack `+` +* Tiff series (from a directory, a text file or a list of file paths). `*+` +* nrrd +* nifti (`.nii` & `.nii.gz`) + +`*` Supports loading in parallel for speed + +`+` Suports scaling on loading. E.g. downsampling to load images bigger than the +available RAM + +#### Supports saving of: +* Tiff stack +* Tiff series +* nifti ### To install ```bash diff --git a/imio/__init__.py b/imio/__init__.py index e5dc458..dd0e3fe 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Adam Tyson, Charly Rousseau" -__version__ = "0.0.4" +__version__ = "0.0.5" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index f31fec4..e1935c0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.0.4 +current_version = 0.0.5 commit = True tag = True diff --git a/setup.py b/setup.py index c23e3ab..6997e09 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.0.4", + version="0.0.5", description="Loading and saving of image data.", install_requires=requirements, extras_require={ diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 From 284862277b58bd4848d89b4ab33cac7a4b9dcf8f Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 16 Dec 2020 16:36:29 +0000 Subject: [PATCH 13/87] transfer to brainglobe --- .travis.yml | 108 -------------------------------------- README.md | 10 ++-- setup.py | 4 +- travis/deploy_linux.sh | 3 -- travis/install_unix.sh | 8 --- travis/install_windows.sh | 31 ----------- travis/lint.sh | 12 ----- travis/test.sh | 3 -- 8 files changed, 7 insertions(+), 172 deletions(-) delete mode 100644 .travis.yml delete mode 100644 travis/deploy_linux.sh delete mode 100644 travis/install_unix.sh delete mode 100644 travis/install_windows.sh delete mode 100644 travis/lint.sh delete mode 100644 travis/test.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 001bf47..0000000 --- a/.travis.yml +++ /dev/null @@ -1,108 +0,0 @@ -after_success: - - pip install coveralls - - coveralls - -stages: - - lint - - test - - name: deploy - if: - tag IS present AND repo = adamltyson/imio - - -jobs: - include: - - stage: lint - name: "Lint" - language: python - os: linux - env: MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh - dist: bionic - python: 3.7 - before_install: source travis/install_unix.sh - script: bash travis/lint.sh - - stage: test - name: "Ubuntu Bionic python 3.6" - language: python - os: linux - env: MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh - dist: bionic - python: 3.6 - before_install: source travis/install_unix.sh - script: bash travis/test.sh - - stage: test - name: "Ubuntu Bionic python 3.7" - language: python - os: linux - env: MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh - dist: bionic - python: 3.7 - before_install: source travis/install_unix.sh - script: bash travis/test.sh - - stage: test - name: "Ubuntu Xenial python 3.6" - language: python - os: linux - env: MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh - dist: xenial - python: 3.6 - before_install: source travis/install_unix.sh - script: bash travis/test.sh - - stage: test - name: "Ubuntu Xenial python 3.7" - language: python - os: linux - env: MINICONDA_URL=http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh - dist: xenial - python: 3.7 - before_install: source travis/install_unix.sh - script: bash travis/test.sh - - stage: test - name: "Windows Python 3.6" - language: shell - env: TRAVIS_PYTHON_VERSION=3.6 - os: windows - before_install: source travis/install_windows.sh - script: bash travis/test.sh - - stage: test - name: "Windows Python 3.7" - language: shell - env: TRAVIS_PYTHON_VERSION=3.7 - os: windows - before_install: source travis/install_windows.sh - script: bash travis/test.sh - - stage: test - name: "macOS Python 3.6" - os: osx - language: shell - env: - - TRAVIS_PYTHON_VERSION=3.6 - - MINICONDA_URL=https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh - before_install: source travis/install_unix.sh - script: bash travis/test.sh - - stage: test - name: "macOS Python 3.7" - os: osx - language: shell - env: - - TRAVIS_PYTHON_VERSION=3.7 - - MINICONDA_URL=https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh - before_install: source travis/install_unix.sh - script: bash travis/test.sh - - stage: deploy - os: bionic - name: "Deploy Linux" - language: python - before_install: source travis/install_unix.sh - script: bash travis/deploy_linux.sh -notifications: - email: - recipients: - - adam.tyson@ucl.ac.uk - on_success: change - on_failure: always - -env: - global: - - TWINE_USERNAME=__token__ - # TWINE_PASSWORD is set to a PyPI API token in Travis settings \ No newline at end of file diff --git a/README.md b/README.md index 4e9d346..1b1a8f1 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ [![PyPI](https://img.shields.io/pypi/v/imio.svg)](https://pypi.org/project/imio) [![Downloads](https://pepy.tech/badge/imio)](https://pepy.tech/project/imio) [![Wheel](https://img.shields.io/pypi/wheel/imio.svg)](https://pypi.org/project/imio) -[![Development Status](https://img.shields.io/pypi/status/imio.svg)](https://github.com/adamltyson/imio) -[![Tests](https://img.shields.io/github/workflow/status/adamltyson/imio/tests)]( - https://github.com/adamltyson/imio/actions) -[![Coverage Status](https://coveralls.io/repos/github/adamltyson/imio/badge.svg?branch=master)](https://coveralls.io/github/adamltyson/imio?branch=master) +[![Development Status](https://img.shields.io/pypi/status/imio.svg)](https://github.com/brainglobe/imio) +[![Tests](https://img.shields.io/github/workflow/status/brainglobe/imio/tests)]( + https://github.com/brainglobe/imio/actions) +[![Coverage Status](https://coveralls.io/repos/github/brainglobe/imio/badge.svg?branch=master)](https://coveralls.io/github/brainglobe/imio?branch=master) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) -[![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/adamltyson/imio) +[![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/brainglobe/imio) # imio diff --git a/setup.py b/setup.py index 6997e09..1362b61 100644 --- a/setup.py +++ b/setup.py @@ -33,8 +33,8 @@ python_requires=">=3.6", packages=find_packages(), include_package_data=True, - url="https://github.com/adamltyson/imio", - author="Adam Tyson", + url="https://github.com/brainglobe/imio", + author="Adam Tyson, Charly Rousseau", author_email="adam.tyson@ucl.ac.uk", classifiers=[ "Development Status :: 3 - Alpha", diff --git a/travis/deploy_linux.sh b/travis/deploy_linux.sh deleted file mode 100644 index fddde26..0000000 --- a/travis/deploy_linux.sh +++ /dev/null @@ -1,3 +0,0 @@ -python setup.py bdist_wheel sdist -pip install twine -twine upload dist/* --skip-existing diff --git a/travis/install_unix.sh b/travis/install_unix.sh deleted file mode 100644 index b3f5dbd..0000000 --- a/travis/install_unix.sh +++ /dev/null @@ -1,8 +0,0 @@ -wget $MINICONDA_URL -O miniconda.sh; -bash miniconda.sh -b -p $HOME/miniconda -export PATH="$HOME/miniconda/bin:$PATH" -hash -r -conda config --set always_yes yes --set changeps1 no -conda info -a -conda create -n test-environment python=$TRAVIS_PYTHON_VERSION -source activate test-environment diff --git a/travis/install_windows.sh b/travis/install_windows.sh deleted file mode 100644 index b0ce091..0000000 --- a/travis/install_windows.sh +++ /dev/null @@ -1,31 +0,0 @@ -export MINICONDA_PATH=$HOME/miniconda; -export MINICONDA_PATH_WIN=`cygpath --windows $MINICONDA_PATH`; -export MINICONDA_SUB_PATH=$MINICONDA_PATH/Scripts; -export MINICONDA_LIB_BIN_PATH=$MINICONDA_PATH/Library/bin; - -choco install openssl.light; - -echo "folder $MINICONDA_SUB_PATH does not exist" -echo "installing miniconda for windows"; -choco install miniconda3 --params="'/JustMe /AddToPath:1 /D:$MINICONDA_PATH_WIN'"; - -export PATH="$MINICONDA_PATH:$MINICONDA_SUB_PATH:$MINICONDA_LIB_BIN_PATH:$PATH"; - -# begin checking miniconda existance -echo "checking if folder $MINICONDA_SUB_PATH exists" -if [[ -d $MINICONDA_SUB_PATH ]]; then - echo "folder $MINICONDA_SUB_PATH exists" -else - echo "folder $MINICONDA_SUB_PATH does not exist" -fi; -# end checking miniconda existance - -source $MINICONDA_PATH/etc/profile.d/conda.sh; -hash -r; -python --version -conda config --set always_yes yes --set changeps1 no; -conda update -q conda; -conda info -a - -conda create -n test-environment python=$TRAVIS_PYTHON_VERSION -source activate test-environment diff --git a/travis/lint.sh b/travis/lint.sh deleted file mode 100644 index 6bdbb3e..0000000 --- a/travis/lint.sh +++ /dev/null @@ -1,12 +0,0 @@ -wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; -bash miniconda.sh -b -p $HOME/miniconda -export PATH="$HOME/miniconda/bin:$PATH" -hash -r -conda config --set always_yes yes --set changeps1 no -conda info -a -conda create -n test-environment python=$TRAVIS_PYTHON_VERSION -source activate test-environment -pip install -e .[dev] -conda info -a -black ./ -l 79 --target-version py37 --check -flake8 diff --git a/travis/test.sh b/travis/test.sh deleted file mode 100644 index 9ee2c81..0000000 --- a/travis/test.sh +++ /dev/null @@ -1,3 +0,0 @@ -pip install -e .[dev] -conda info -a -pytest --cov=imio \ No newline at end of file From b820e007feaf859466c2344f35e1aea77ddbdc8f Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 21 Jun 2021 10:52:19 +0100 Subject: [PATCH 14/87] run tests on PR --- .github/workflows/test_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index f408e58..bccfb4f 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -1,6 +1,6 @@ name: tests -on: push +on: [push, pull_request] jobs: lint: From 091a5cc602a104348ce6b9bca0ac67ce808035bb Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 21 Jun 2021 11:07:33 +0100 Subject: [PATCH 15/87] update coverage --- .github/workflows/test_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index bccfb4f..f7ae46c 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -48,7 +48,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | pip install coveralls - coveralls + coveralls --service=github deploy: needs: test From 5c72f6f36d8b6983687b2cde954cb6919eda093d Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 21 Jun 2021 11:11:15 +0100 Subject: [PATCH 16/87] support python 3.9 --- .github/workflows/test_and_deploy.yml | 6 +++++- setup.py | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index f7ae46c..5bcbe69 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -25,12 +25,16 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.7, 3.8] + python-version: [3.7, 3.8, 3.9] exclude: - os: macos-latest python-version: 3.7 - os: windows-latest python-version: 3.7 + - os: macos-latest + python-version: 3.8 + - os: windows-latest + python-version: 3.9 steps: - uses: actions/checkout@v2 - name: Set up Python diff --git a/setup.py b/setup.py index 1362b61..2220024 100644 --- a/setup.py +++ b/setup.py @@ -30,20 +30,20 @@ "flake8", ] }, - python_requires=">=3.6", + python_requires=">=3.7", packages=find_packages(), include_package_data=True, url="https://github.com/brainglobe/imio", author="Adam Tyson, Charly Rousseau", - author_email="adam.tyson@ucl.ac.uk", + author_email="code@adamltyson.com", classifiers=[ "Development Status :: 3 - Alpha", "Operating System :: POSIX :: Linux", "Operating System :: Microsoft :: Windows :: Windows 10", "Programming Language :: Python", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Intended Audience :: Developers", "Intended Audience :: Science/Research", ], From a569cce7a59ffc9368fd3e56fa008c37d831c726 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 21 Jun 2021 11:15:06 +0100 Subject: [PATCH 17/87] =?UTF-8?q?Bump=20version:=200.0.5=20=E2=86=92=200.0?= =?UTF-8?q?.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index dd0e3fe..7ff0345 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Adam Tyson, Charly Rousseau" -__version__ = "0.0.5" +__version__ = "0.0.6" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index e1935c0..9f42d5d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.0.5 +current_version = 0.0.6 commit = True tag = True diff --git a/setup.py b/setup.py index 2220024..d82b6b3 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.0.5", + version="0.0.6", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From e3eb0ecdda05cd889079986e7db62b2d620b06b7 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 21 Jun 2021 11:17:36 +0100 Subject: [PATCH 18/87] update bump2version --- setup.cfg | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/setup.cfg b/setup.cfg index 9f42d5d..38510a1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,6 +2,20 @@ current_version = 0.0.6 commit = True tag = True +tag_name = {new_version} +parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? +serialize = + {major}.{minor}.{patch}-{release}{rc} + {major}.{minor}.{patch} + +[bumpversion:part:release] +optional_value = prod +first_value = rc +values = + rc + prod + +[bumpversion:part:rc] [bumpversion:file:setup.py] search = version="{current_version}" From 3a91bbeb716ebd064eb7bbb7a235952945403da3 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 21 Jun 2021 11:17:38 +0100 Subject: [PATCH 19/87] =?UTF-8?q?Bump=20version:=200.0.6=20=E2=86=92=200.1?= =?UTF-8?q?.0-rc0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 6 +++--- setup.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index 7ff0345..8509786 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Adam Tyson, Charly Rousseau" -__version__ = "0.0.6" +__version__ = "0.1.0-rc0" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index 38510a1..6261811 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,17 +1,17 @@ [bumpversion] -current_version = 0.0.6 +current_version = 0.1.0-rc0 commit = True tag = True tag_name = {new_version} parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? -serialize = +serialize = {major}.{minor}.{patch}-{release}{rc} {major}.{minor}.{patch} [bumpversion:part:release] optional_value = prod first_value = rc -values = +values = rc prod diff --git a/setup.py b/setup.py index d82b6b3..e6d831d 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.0.6", + version="0.1.0-rc0", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From 1fde21826264ef51259eb179bebf547ba452344b Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 21 Jun 2021 11:17:46 +0100 Subject: [PATCH 20/87] =?UTF-8?q?Bump=20version:=200.1.0-rc0=20=E2=86=92?= =?UTF-8?q?=200.1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index 8509786..78806c5 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Adam Tyson, Charly Rousseau" -__version__ = "0.1.0-rc0" +__version__ = "0.1.0" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index 6261811..8e8425e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.0-rc0 +current_version = 0.1.0 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index e6d831d..edba9ef 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.1.0-rc0", + version="0.1.0", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From 6db5636f9c5ab0b8ba1fb4fa0c99261841c32832 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 7 Oct 2021 17:58:59 +0100 Subject: [PATCH 21/87] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index edba9ef..1600bec 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ packages=find_packages(), include_package_data=True, url="https://github.com/brainglobe/imio", - author="Adam Tyson, Charly Rousseau", + author="Charly Rousseau, Adam Tyson", author_email="code@adamltyson.com", classifiers=[ "Development Status :: 3 - Alpha", From 9c8ee2836874375ec63307149b92caf30397181c Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 7 Oct 2021 17:59:32 +0100 Subject: [PATCH 22/87] add missing import --- imio/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imio/utils.py b/imio/utils.py index 740eb03..88c0f80 100644 --- a/imio/utils.py +++ b/imio/utils.py @@ -3,6 +3,8 @@ import glob import psutil +import numpy as np + from scipy.ndimage import zoom from natsort import natsorted From 8e615b247b0bece289c3ffb3b73958cfe1efda4e Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 7 Oct 2021 18:00:35 +0100 Subject: [PATCH 23/87] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b1a8f1..7be85cd 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,7 @@ Loading and saving of image data. ### About The aim of imio is to be a lightweight image loading library for the file types supported by [cellfinder](https://github.com/brainglobe/cellfinder), and - [brainreg](https://github.com/brainglobe/brainreg). It is an update to - [brainio](https://github.com/adamltyson/brainio). + [brainreg](https://github.com/brainglobe/brainreg). #### Supports loading of: * Tiff stack `+` From d5ff00f22107d3df1002ae3e8a828c4513393c72 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 7 Oct 2021 18:12:10 +0100 Subject: [PATCH 24/87] fix linting --- imio/load.py | 27 ++++++++++++++++++++++++++- imio/save.py | 12 ------------ imio/utils.py | 31 ------------------------------- 3 files changed, 26 insertions(+), 44 deletions(-) diff --git a/imio/load.py b/imio/load.py index 4f862aa..c374f8a 100644 --- a/imio/load.py +++ b/imio/load.py @@ -13,7 +13,7 @@ from imlib.general.system import get_sorted_file_paths, get_num_processes -from .utils import check_mem, scale_z +from .utils import scale_z, check_mem with warnings.catch_warnings(): warnings.simplefilter("ignore") @@ -480,3 +480,28 @@ def generate_paths_sequence_file( with open(output_file_path, "w") as out_file: out_file.writelines(paths) + + +def get_size_image_from_file_paths(file_path, file_extension="tif"): + """ + Returns the size of an image (which is a list of 2D files), without loading + the whole image + :param str file_path: File containing file_paths in a text file, + or as a list. + :param str file_extension: Optional file extension (if a directory + is passed) + :return: Dict of image sizes + """ + file_path = str(file_path) + + img_paths = get_sorted_file_paths(file_path, file_extension=file_extension) + z_shape = len(img_paths) + + logging.debug( + "Loading file: {} to check raw image size" "".format(img_paths[0]) + ) + image_0 = load_any(img_paths[0]) + y_shape, x_shape = image_0.shape + + image_shape = {"x": x_shape, "y": y_shape, "z": z_shape} + return image_shape diff --git a/imio/save.py b/imio/save.py index c45dddc..7b58a7c 100644 --- a/imio/save.py +++ b/imio/save.py @@ -1,19 +1,7 @@ -import os -import math -import nrrd -import logging import tifffile import warnings import numpy as np -from skimage import transform -from tqdm import tqdm -from natsort import natsorted -from concurrent.futures import ProcessPoolExecutor - -from imlib.general.system import get_sorted_file_paths, get_num_processes - -from .utils import check_mem, scale_z with warnings.catch_warnings(): warnings.simplefilter("ignore") diff --git a/imio/utils.py b/imio/utils.py index 88c0f80..95247ae 100644 --- a/imio/utils.py +++ b/imio/utils.py @@ -1,15 +1,9 @@ -import logging -import os -import glob import psutil import numpy as np from scipy.ndimage import zoom -from natsort import natsorted -from slurmio import slurmio - class ImioLoadException(Exception): pass @@ -48,28 +42,3 @@ def scale_z(volume, scaling_factor): volume = np.swapaxes(volume, 1, 2) volume = zoom(volume, (1, scaling_factor, 1), order=1) return np.swapaxes(volume, 1, 2) - - -def get_size_image_from_file_paths(file_path, file_extension="tif"): - """ - Returns the size of an image (which is a list of 2D files), without loading - the whole image - :param str file_path: File containing file_paths in a text file, - or as a list. - :param str file_extension: Optional file extension (if a directory - is passed) - :return: Dict of image sizes - """ - file_path = str(file_path) - - img_paths = get_sorted_file_paths(file_path, file_extension=file_extension) - z_shape = len(img_paths) - - logging.debug( - "Loading file: {} to check raw image size" "".format(img_paths[0]) - ) - image_0 = load_any(img_paths[0]) - y_shape, x_shape = image_0.shape - - image_shape = {"x": x_shape, "y": y_shape, "z": z_shape} - return image_shape From 951411e8a70c9928f5dce352fb5bfcb1411b690d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Rodr=C3=ADguez-Guerra?= Date: Fri, 4 Feb 2022 14:49:40 +0100 Subject: [PATCH 25/87] Exclude tests from packaged distributions (#6) --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1600bec..a567635 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ ] }, python_requires=">=3.7", - packages=find_packages(), + packages=find_packages(exclude=("tests", "tests.*")), include_package_data=True, url="https://github.com/brainglobe/imio", author="Charly Rousseau, Adam Tyson", From c00505302b077d7547d97f3b9983cca6211e8d21 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Fri, 4 Feb 2022 13:52:01 +0000 Subject: [PATCH 26/87] Update pre commit --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c975a0..edd36e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ repos: - repo: https://github.com/python/black - rev: 19.10b0 + rev: 22.1.0 hooks: - id: black pass_filenames: true - repo: https://gitlab.com/pycqa/flake8 - rev: 3.7.9 + rev: 4.0.1 hooks: - id: flake8 pass_filenames: true From 125c9b5498142700d992c6eec806b020520d5955 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Fri, 4 Feb 2022 13:52:58 +0000 Subject: [PATCH 27/87] reformat --- imio/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imio/save.py b/imio/save.py index 7b58a7c..cf95488 100644 --- a/imio/save.py +++ b/imio/save.py @@ -59,7 +59,7 @@ def to_tiffs(img_volume, path_prefix, path_suffix="", pad_width=4): :return: """ z_size = img_volume.shape[-1] - if z_size > 10 ** pad_width: + if z_size > 10**pad_width: raise ValueError( "Not enough padding digits {} for value" " {}".format(pad_width, z_size) From 70361c18afc41cad2c91ef010539a9909936e884 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Fri, 4 Feb 2022 13:58:45 +0000 Subject: [PATCH 28/87] Python 3.10 compatibility --- .github/workflows/test_and_deploy.yml | 6 +++++- setup.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 5bcbe69..b5157f9 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -25,7 +25,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, 3.10] exclude: - os: macos-latest python-version: 3.7 @@ -33,6 +33,10 @@ jobs: python-version: 3.7 - os: macos-latest python-version: 3.8 + - os: windows-latest + python-version: 3.8 + - os: macos-latest + python-version: 3.9 - os: windows-latest python-version: 3.9 steps: diff --git a/setup.py b/setup.py index a567635..5d4d1c9 100644 --- a/setup.py +++ b/setup.py @@ -38,12 +38,12 @@ author_email="code@adamltyson.com", classifiers=[ "Development Status :: 3 - Alpha", - "Operating System :: POSIX :: Linux", - "Operating System :: Microsoft :: Windows :: Windows 10", + "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Intended Audience :: Developers", "Intended Audience :: Science/Research", ], From 5f9f55112117856145ab6241c36c01a57680c2fe Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Fri, 4 Feb 2022 13:59:19 +0000 Subject: [PATCH 29/87] =?UTF-8?q?Bump=20version:=200.1.0=20=E2=86=92=200.2?= =?UTF-8?q?.0-rc0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index 78806c5..1dc14df 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Adam Tyson, Charly Rousseau" -__version__ = "0.1.0" +__version__ = "0.2.0-rc0" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index 8e8425e..45471ac 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.0 +current_version = 0.2.0-rc0 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index 5d4d1c9..296e873 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.1.0", + version="0.2.0-rc0", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From b19110550d8d33f5b1898e7182a493a1de666098 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Fri, 4 Feb 2022 14:00:55 +0000 Subject: [PATCH 30/87] update GH actions --- .github/workflows/test_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index b5157f9..8b113f1 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -25,7 +25,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.7, 3.8, 3.9, 3.10] + python-version: ["3.7", "3.8", "3.9", "3.10"] exclude: - os: macos-latest python-version: 3.7 From cd543915e5c9becad07cfe7621a2169181ac72c8 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Fri, 4 Feb 2022 14:05:37 +0000 Subject: [PATCH 31/87] =?UTF-8?q?Bump=20version:=200.2.0-rc0=20=E2=86=92?= =?UTF-8?q?=200.2.0-rc1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index 1dc14df..f0a54d0 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Adam Tyson, Charly Rousseau" -__version__ = "0.2.0-rc0" +__version__ = "0.2.0-rc1" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index 45471ac..5c00691 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.0-rc0 +current_version = 0.2.0-rc1 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index 296e873..2bfa59f 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.2.0-rc0", + version="0.2.0-rc1", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From 0b4e34e7d6755f321ec5d8e678c3efe3671e5884 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Fri, 4 Feb 2022 14:11:07 +0000 Subject: [PATCH 32/87] =?UTF-8?q?Bump=20version:=200.2.0-rc1=20=E2=86=92?= =?UTF-8?q?=200.2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index f0a54d0..c3a8037 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Adam Tyson, Charly Rousseau" -__version__ = "0.2.0-rc1" +__version__ = "0.2.0" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index 5c00691..8d44c98 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.0-rc1 +current_version = 0.2.0 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index 2bfa59f..723e7dd 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.2.0-rc1", + version="0.2.0", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From 9c295de1f6f80af64fc36193ee54deb3153cacde Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 14 Feb 2022 16:14:58 +0000 Subject: [PATCH 33/87] Revert older changes --- imio/__init__.py | 4 +- imio/load.py | 87 +++++++++------------------------------- imio/save.py | 35 +++++++++------- imio/utils.py | 35 +++++++++++++--- setup.cfg | 2 +- setup.py | 2 +- tests/tests/test_imio.py | 6 +-- 7 files changed, 77 insertions(+), 94 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index c3a8037..b05da57 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ -__author__ = "Adam Tyson, Charly Rousseau" -__version__ = "0.2.0" +__author__ = "Charly Rousseau, Adam Tyson" +__version__ = "0.2.1" from imio.load import * from imio.save import * diff --git a/imio/load.py b/imio/load.py index c374f8a..d15fb61 100644 --- a/imio/load.py +++ b/imio/load.py @@ -8,12 +8,12 @@ from skimage import transform from tqdm import tqdm -from natsort import natsorted from concurrent.futures import ProcessPoolExecutor +from natsort import natsorted from imlib.general.system import get_sorted_file_paths, get_num_processes -from .utils import scale_z, check_mem +from .utils import check_mem, scale_z with warnings.catch_warnings(): warnings.simplefilter("ignore") @@ -170,7 +170,7 @@ def load_img_stack( stack = np.array(downsampled_stack) if stack.ndim == 3: - stack = np.rollaxis(stack, 0, 3) + # stack = np.rollaxis(stack, 0, 3) if z_scaling_factor != 1: logging.debug("Downsampling stack in Z") stack = scale_z(stack, z_scaling_factor) @@ -191,7 +191,7 @@ def load_nii(src_path, as_array=False, as_numpy=False): src_path = str(src_path) nii_img = nib.load(src_path) if as_array: - image = nii_img.get_data() + image = nii_img.get_fdata() if as_numpy: image = np.array(image) @@ -202,9 +202,9 @@ def load_nii(src_path, as_array=False, as_numpy=False): def load_from_folder( src_folder, - x_scaling_factor, - y_scaling_factor, - z_scaling_factor, + x_scaling_factor=1, + y_scaling_factor=1, + z_scaling_factor=1, anti_aliasing=True, file_extension="", load_parallel=False, @@ -249,9 +249,9 @@ def load_from_folder( def load_img_sequence( img_sequence_file_path, - x_scaling_factor, - y_scaling_factor, - z_scaling_factor, + x_scaling_factor=1, + y_scaling_factor=1, + z_scaling_factor=1, anti_aliasing=True, load_parallel=False, sort=False, @@ -299,9 +299,9 @@ def load_img_sequence( def load_image_series( paths, - x_scaling_factor, - y_scaling_factor, - z_scaling_factor, + x_scaling_factor=1, + y_scaling_factor=1, + z_scaling_factor=1, anti_aliasing=True, load_parallel=False, n_free_cpus=2, @@ -341,6 +341,8 @@ def load_image_series( y_scaling_factor, anti_aliasing=anti_aliasing, ) + + img = np.moveaxis(img, 2, 0) # back to z first if z_scaling_factor != 1: img = scale_z(img, z_scaling_factor) @@ -385,8 +387,11 @@ def threaded_load_from_sequence( break else: end_idx = start_idx + n_paths_per_subsequence - end_idx = end_idx if end_idx < len(paths_sequence) else -1 - sub_paths = paths_sequence[start_idx:end_idx] + + if end_idx <= len(paths_sequence): + sub_paths = paths_sequence[start_idx:end_idx] + else: + sub_paths = paths_sequence[start_idx:] process = pool.submit( load_from_paths_sequence, @@ -453,55 +458,3 @@ def load_from_paths_sequence( ) volume[:, :, i] = img return volume - - -def generate_paths_sequence_file( - input_folder, - output_file_path, - sort=True, - prefix=None, - suffix=None, - match_string=None, -): - input_folder = str(input_folder) - paths = [] - for root, dirs, files in os.walk(input_folder): - for filename in files: - if prefix is not None and not filename.startswith(prefix): - continue - if suffix is not None and not filename.endswith(suffix): - continue - if match_string is not None and match_string not in filename: - continue - paths.append(os.path.join(root, filename)) - - if sort: - paths = natsorted(paths) - - with open(output_file_path, "w") as out_file: - out_file.writelines(paths) - - -def get_size_image_from_file_paths(file_path, file_extension="tif"): - """ - Returns the size of an image (which is a list of 2D files), without loading - the whole image - :param str file_path: File containing file_paths in a text file, - or as a list. - :param str file_extension: Optional file extension (if a directory - is passed) - :return: Dict of image sizes - """ - file_path = str(file_path) - - img_paths = get_sorted_file_paths(file_path, file_extension=file_extension) - z_shape = len(img_paths) - - logging.debug( - "Loading file: {} to check raw image size" "".format(img_paths[0]) - ) - image_0 = load_any(img_paths[0]) - y_shape, x_shape = image_0.shape - - image_shape = {"x": x_shape, "y": y_shape, "z": z_shape} - return image_shape diff --git a/imio/save.py b/imio/save.py index cf95488..e74458c 100644 --- a/imio/save.py +++ b/imio/save.py @@ -1,5 +1,7 @@ import tifffile import warnings +import nrrd + import numpy as np @@ -39,13 +41,12 @@ def to_tiff(img_volume, dest_path): :param np.ndarray img_volume: The image to be saved :param dest_path: Where to save the tiff stack - :return: """ dest_path = str(dest_path) tifffile.imsave(dest_path, img_volume) -def to_tiffs(img_volume, path_prefix, path_suffix="", pad_width=4): +def to_tiffs(img_volume, path_prefix, path_suffix="", extension=".tif"): """ Save the image volume (numpy array) as a sequence of tiff planes. Each plane will have a filepath of the following for: @@ -54,19 +55,23 @@ def to_tiffs(img_volume, path_prefix, path_suffix="", pad_width=4): :param np.ndarray img_volume: The image to be saved :param str path_prefix: The prefix for each plane :param str path_suffix: The suffix for each plane - :param int pad_width: The number of digits on which the index of the - image (z plane number) will be padded - :return: """ - z_size = img_volume.shape[-1] - if z_size > 10**pad_width: - raise ValueError( - "Not enough padding digits {} for value" - " {}".format(pad_width, z_size) - ) + z_size = img_volume.shape[0] + pad_width = int(round(z_size / 10)) + 1 for i in range(z_size): - img = img_volume[:, :, i] - dest_path = "{}_{}{}.tif".format( - path_prefix, str(i).zfill(pad_width), path_suffix + img = img_volume[i, :, :] + dest_path = ( + f"{path_prefix}_{str(i).zfill(pad_width)}{path_suffix}{extension}" ) - tifffile.imsave(dest_path, img) + tifffile.imwrite(dest_path, img) + + +def to_nrrd(img_volume, dest_path): + """ + Saves the image volume (numpy array) as nrrd + + :param np.ndarray img_volume: The image to be saved + :param dest_path: Where to save the nrrd image + """ + dest_path = str(dest_path) + nrrd.write(dest_path, img_volume) diff --git a/imio/utils.py b/imio/utils.py index 95247ae..5cfd369 100644 --- a/imio/utils.py +++ b/imio/utils.py @@ -1,8 +1,10 @@ +import logging import psutil -import numpy as np - from scipy.ndimage import zoom +from imlib.general.system import get_sorted_file_paths + +import imio class ImioLoadException(Exception): @@ -39,6 +41,29 @@ def scale_z(volume, scaling_factor): :return: """ - volume = np.swapaxes(volume, 1, 2) - volume = zoom(volume, (1, scaling_factor, 1), order=1) - return np.swapaxes(volume, 1, 2) + return zoom(volume, (scaling_factor, 1, 1), order=1) + + +def get_size_image_from_file_paths(file_path, file_extension="tif"): + """ + Returns the size of an image (which is a list of 2D files), without loading + the whole image + :param str file_path: File containing file_paths in a text file, + or as a list. + :param str file_extension: Optional file extension (if a directory + is passed) + :return: Dict of image sizes + """ + file_path = str(file_path) + + img_paths = get_sorted_file_paths(file_path, file_extension=file_extension) + z_shape = len(img_paths) + + logging.debug( + "Loading file: {} to check raw image size" "".format(img_paths[0]) + ) + image_0 = imio.load_any(img_paths[0]) + y_shape, x_shape = image_0.shape + + image_shape = {"x": x_shape, "y": y_shape, "z": z_shape} + return image_shape diff --git a/setup.cfg b/setup.cfg index 8d44c98..366ef10 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.0 +current_version = 0.2.1 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index 723e7dd..6dda8bf 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.2.0", + version="0.2.1", description="Loading and saving of image data.", install_requires=requirements, extras_require={ diff --git a/tests/tests/test_imio.py b/tests/tests/test_imio.py index 438f445..d12df56 100644 --- a/tests/tests/test_imio.py +++ b/tests/tests/test_imio.py @@ -54,11 +54,11 @@ def test_to_nii(tmpdir, start_array): # Also tests load_nii folder = str(tmpdir) nii_path = os.path.join(folder, "test_array.nii") save.to_nii(start_array, nii_path) - assert (load.load_nii(nii_path).get_data() == start_array).all() + assert (load.load_nii(nii_path).get_fdata() == start_array).all() def test_scale_z(start_array): assert ( - utils.scale_z(start_array, 0.5).shape[-1] == start_array.shape[-1] / 2 + utils.scale_z(start_array, 0.5).shape[0] == start_array.shape[-1] / 2 ) - assert utils.scale_z(start_array, 2).shape[-1] == start_array.shape[-1] * 2 + assert utils.scale_z(start_array, 2).shape[0] == start_array.shape[-1] * 2 From 1d8bfe10000d775649dc4e979f33527e9b53080b Mon Sep 17 00:00:00 2001 From: Jules Scholler Date: Fri, 29 Apr 2022 11:13:46 +0200 Subject: [PATCH 34/87] Fix deprecation of tifffile.imsave replaced by tifffile.imwrite. (#8) Co-authored-by: Jules Scholler --- imio/save.py | 2 +- tests/tests/test_imio.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/imio/save.py b/imio/save.py index e74458c..cd77802 100644 --- a/imio/save.py +++ b/imio/save.py @@ -43,7 +43,7 @@ def to_tiff(img_volume, dest_path): :param dest_path: Where to save the tiff stack """ dest_path = str(dest_path) - tifffile.imsave(dest_path, img_volume) + tifffile.imwrite(dest_path, img_volume) def to_tiffs(img_volume, path_prefix, path_suffix="", extension=".tif"): diff --git a/tests/tests/test_imio.py b/tests/tests/test_imio.py index d12df56..c1fb947 100644 --- a/tests/tests/test_imio.py +++ b/tests/tests/test_imio.py @@ -22,7 +22,7 @@ def start_array(layer): def test_tiff_io(tmpdir, layer): folder = str(tmpdir) dest_path = os.path.join(folder, "layer.tiff") - tifffile.imsave(dest_path, layer) + tifffile.imwrite(dest_path, layer) reloaded = tifffile.imread(dest_path) assert (reloaded == layer).all() From 4308b9b146725662b3eb6dc3581b6be928fb1bb3 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Fri, 29 Apr 2022 10:15:07 +0100 Subject: [PATCH 35/87] =?UTF-8?q?Bump=20version:=200.2.1=20=E2=86=92=200.2?= =?UTF-8?q?.2-rc0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index b05da57..ba0ded9 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Charly Rousseau, Adam Tyson" -__version__ = "0.2.1" +__version__ = "0.2.2-rc0" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index 366ef10..2e909ac 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.1 +current_version = 0.2.2-rc0 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index 6dda8bf..7de34a5 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.2.1", + version="0.2.2-rc0", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From 466049b4ecc115d650ddb92c4e869a200ccdf121 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Fri, 29 Apr 2022 10:17:47 +0100 Subject: [PATCH 36/87] =?UTF-8?q?Bump=20version:=200.2.2-rc0=20=E2=86=92?= =?UTF-8?q?=200.2.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index ba0ded9..7ba457e 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Charly Rousseau, Adam Tyson" -__version__ = "0.2.2-rc0" +__version__ = "0.2.2" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index 2e909ac..2ca8172 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.2-rc0 +current_version = 0.2.2 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index 7de34a5..72188ea 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.2.2-rc0", + version="0.2.2", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From d7cc8753c72f3d6f32784c0d1f478de72bf86da7 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 31 May 2022 13:49:19 +0100 Subject: [PATCH 37/87] Add link to contributing guide --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7be85cd..410d6e2 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,6 @@ available RAM ```bash pip install imio ``` + +## Contributing +Contributions to imio are more than welcome. Please see the [contributing guide](https://github.com/brainglobe/.github/blob/main/CONTRIBUTING.md). From a36b87bda6163ce019e0b398d310d9c7d2fe4d9e Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 6 Jun 2022 17:15:41 +0100 Subject: [PATCH 38/87] Add tox and use brainglobe/actions (#10) * Add tox and use brainglobe actions for testing * Update pre-commit * run pre-commit --- .github/workflows/test_and_deploy.yml | 57 +++++++-------------------- .pre-commit-config.yaml | 45 ++++++++++++++++----- README.md | 4 +- imio/load.py | 17 ++++---- imio/save.py | 5 +-- imio/utils.py | 4 +- pyproject.toml | 2 +- setup.py | 2 +- tests/tests/test_imio.py | 3 +- tox.ini | 14 +++++++ 10 files changed, 80 insertions(+), 73 deletions(-) create mode 100644 tox.ini diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 8b113f1..ed2bdcf 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -6,57 +6,28 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install .[dev] - - name: Lint - run: | - black ./ --check - flake8 + - uses: brainglobe/actions/lint@v1 + test: needs: lint + name: ${{ matrix.os }} py${{ matrix.python-version }} runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.7", "3.8", "3.9", "3.10"] - exclude: - - os: macos-latest - python-version: 3.7 - - os: windows-latest - python-version: 3.7 - - os: macos-latest - python-version: 3.8 - - os: windows-latest - python-version: 3.8 - - os: macos-latest - python-version: 3.9 - - os: windows-latest - python-version: 3.9 + # Run all supported Python versions on linux + python-version: ["3.7", "3.8", "3.9"] + os: [ubuntu-latest] + # Include one windows and macos run + include: + - os: macos-latest + python-version: "3.9" + - os: windows-latest + python-version: "3.9" + steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 + - uses: brainglobe/actions/test@v1 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install .[dev] - - name: Test - run: pytest - - name: Coveralls - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - pip install coveralls - coveralls --service=github deploy: needs: test diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index edd36e0..eb90a1c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,36 @@ repos: -- repo: https://github.com/python/black - rev: 22.1.0 - hooks: - - id: black - pass_filenames: true -- repo: https://gitlab.com/pycqa/flake8 - rev: 4.0.1 - hooks: - - id: flake8 - pass_filenames: true + - repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort + types: [text] + types_or: [python, cython] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-toml + - id: end-of-file-fixer + - id: mixed-line-ending + args: [--fix=lf] + - id: requirements-txt-fixer + - id: trailing-whitespace + # bump2version produces whitespace in setup.cfg, so exclude to + # not inferfere with versioning + exclude: setup.cfg + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + - repo: https://github.com/psf/black + rev: 22.3.0 + hooks: + - id: black + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.931 + hooks: + - id: mypy + additional_dependencies: + - types-setuptools diff --git a/README.md b/README.md index 410d6e2..804fb89 100644 --- a/README.md +++ b/README.md @@ -26,13 +26,13 @@ The aim of imio is to be a lightweight image loading library for the file types `*` Supports loading in parallel for speed -`+` Suports scaling on loading. E.g. downsampling to load images bigger than the +`+` Suports scaling on loading. E.g. downsampling to load images bigger than the available RAM #### Supports saving of: * Tiff stack * Tiff series -* nifti +* nifti ### To install ```bash diff --git a/imio/load.py b/imio/load.py index d15fb61..d54d796 100644 --- a/imio/load.py +++ b/imio/load.py @@ -1,17 +1,16 @@ -import os -import math -import nrrd import logging -import tifffile +import math +import os import warnings -import numpy as np +from concurrent.futures import ProcessPoolExecutor +import nrrd +import numpy as np +import tifffile +from imlib.general.system import get_num_processes, get_sorted_file_paths +from natsort import natsorted from skimage import transform from tqdm import tqdm -from concurrent.futures import ProcessPoolExecutor -from natsort import natsorted - -from imlib.general.system import get_sorted_file_paths, get_num_processes from .utils import check_mem, scale_z diff --git a/imio/save.py b/imio/save.py index cd77802..8991873 100644 --- a/imio/save.py +++ b/imio/save.py @@ -1,9 +1,8 @@ -import tifffile import warnings -import nrrd +import nrrd import numpy as np - +import tifffile with warnings.catch_warnings(): warnings.simplefilter("ignore") diff --git a/imio/utils.py b/imio/utils.py index 5cfd369..960b196 100644 --- a/imio/utils.py +++ b/imio/utils.py @@ -1,8 +1,8 @@ import logging -import psutil -from scipy.ndimage import zoom +import psutil from imlib.general.system import get_sorted_file_paths +from scipy.ndimage import zoom import imio diff --git a/pyproject.toml b/pyproject.toml index 9bd6669..dfab025 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,4 +13,4 @@ exclude = ''' | build | dist )/ -''' \ No newline at end of file +''' diff --git a/setup.py b/setup.py index 72188ea..72872b4 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup, find_packages +from setuptools import find_packages, setup requirements = [ "numpy", diff --git a/tests/tests/test_imio.py b/tests/tests/test_imio.py index c1fb947..dd60835 100644 --- a/tests/tests/test_imio.py +++ b/tests/tests/test_imio.py @@ -1,8 +1,7 @@ import os -import pytest import numpy as np - +import pytest from tifffile import tifffile from imio import load, save, utils diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..27e1903 --- /dev/null +++ b/tox.ini @@ -0,0 +1,14 @@ +[tox] +envlist = py{37,38,39} + +[gh-actions] +python = + 3.7: py37 + 3.8: py38 + 3.9: py39 + +[testenv] +extras = + dev +commands = + pytest -v --color=yes --cov=brainreg --cov-report=xml From 3dac57ee27c8b7f9d0eef2e546319c36597c1e7e Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 9 Jun 2022 09:23:34 +0100 Subject: [PATCH 39/87] Update tox.ini --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 27e1903..464ae73 100644 --- a/tox.ini +++ b/tox.ini @@ -11,4 +11,4 @@ python = extras = dev commands = - pytest -v --color=yes --cov=brainreg --cov-report=xml + pytest -v --color=yes --cov=imio --cov-report=xml From 22c85b786fdbdcea7d9fad82d51034f134be682a Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 26 Jul 2022 11:52:12 +0100 Subject: [PATCH 40/87] =?UTF-8?q?Bump=20version:=200.2.2=20=E2=86=92=200.2?= =?UTF-8?q?.3-rc0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index 7ba457e..7f00b37 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Charly Rousseau, Adam Tyson" -__version__ = "0.2.2" +__version__ = "0.2.3-rc0" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index 2ca8172..f695562 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.2 +current_version = 0.2.3-rc0 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index 72872b4..1712369 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.2.2", + version="0.2.3-rc0", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From 5a8c607741b103d17b29f87e4913d18b5f391a87 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 26 Jul 2022 12:40:18 +0100 Subject: [PATCH 41/87] =?UTF-8?q?Bump=20version:=200.2.3-rc0=20=E2=86=92?= =?UTF-8?q?=200.2.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index 7f00b37..838300b 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Charly Rousseau, Adam Tyson" -__version__ = "0.2.3-rc0" +__version__ = "0.2.3" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index f695562..336a055 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.3-rc0 +current_version = 0.2.3 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index 1712369..f7e66f2 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="imio", - version="0.2.3-rc0", + version="0.2.3", description="Loading and saving of image data.", install_requires=requirements, extras_require={ From 6b685cf9dcfa81f5d8bbf947a6c76a362a51f26c Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 26 Jul 2022 05:32:16 -0700 Subject: [PATCH 42/87] Long description (#11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add long description for PyPI * Bump version: 0.2.3 → 0.2.4-rc0 --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index 838300b..1911b81 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Charly Rousseau, Adam Tyson" -__version__ = "0.2.3" +__version__ = "0.2.4-rc0" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index 336a055..7755833 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.3 +current_version = 0.2.4-rc0 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index f7e66f2..cb47c21 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,11 @@ +from os import path + from setuptools import find_packages, setup +this_directory = path.abspath(path.dirname(__file__)) +with open(path.join(this_directory, "README.md"), encoding="utf-8") as f: + long_description = f.read() + requirements = [ "numpy", "scikit-image", @@ -16,8 +22,10 @@ setup( name="imio", - version="0.2.3", + version="0.2.4-rc0", description="Loading and saving of image data.", + long_description=long_description, + long_description_content_type="text/markdown", install_requires=requirements, extras_require={ "dev": [ From 2292cb1ccb7b7ef5d090373443b4748bce940105 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 26 Jul 2022 13:32:44 +0100 Subject: [PATCH 43/87] =?UTF-8?q?Bump=20version:=200.2.4-rc0=20=E2=86=92?= =?UTF-8?q?=200.2.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- imio/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imio/__init__.py b/imio/__init__.py index 1911b81..46900e5 100644 --- a/imio/__init__.py +++ b/imio/__init__.py @@ -1,5 +1,5 @@ __author__ = "Charly Rousseau, Adam Tyson" -__version__ = "0.2.4-rc0" +__version__ = "0.2.4" from imio.load import * from imio.save import * diff --git a/setup.cfg b/setup.cfg index 7755833..422e059 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.4-rc0 +current_version = 0.2.4 commit = True tag = True tag_name = {new_version} diff --git a/setup.py b/setup.py index cb47c21..f78fa2a 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( name="imio", - version="0.2.4-rc0", + version="0.2.4", description="Loading and saving of image data.", long_description=long_description, long_description_content_type="text/markdown", From 5cbc6a398f7027f405a077c67f07a7c31629399f Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 27 Jul 2022 11:30:32 +0100 Subject: [PATCH 44/87] Change coverage badge to codecov. --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 804fb89..afcda40 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,7 @@ [![Development Status](https://img.shields.io/pypi/status/imio.svg)](https://github.com/brainglobe/imio) [![Tests](https://img.shields.io/github/workflow/status/brainglobe/imio/tests)]( https://github.com/brainglobe/imio/actions) -[![Coverage Status](https://coveralls.io/repos/github/brainglobe/imio/badge.svg?branch=master)](https://coveralls.io/github/brainglobe/imio?branch=master) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) +[![codecov](https://codecov.io/gh/brainglobe/imio/branch/master/graph/badge.svg?token=M1BXRDJ9V4)](https://codecov.io/gh/brainglobe/imio)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) [![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/brainglobe/imio) From b2dc8ddbff1c6a4fcc8a6252d076212b27573c68 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 31 Jan 2023 09:33:41 +0000 Subject: [PATCH 45/87] Test on recent python versions (#13) * Test on recent python versions * Bump pre-commit versions * Fix dtype issue * Remove straggling mention of 3.7 --- .github/workflows/test_and_deploy.yml | 11 ++++++----- .pre-commit-config.yaml | 12 ++++++------ setup.py | 4 ++-- tests/tests/test_imio.py | 2 +- tox.ini | 5 +++-- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index ed2bdcf..6ee7183 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -14,15 +14,16 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - # Run all supported Python versions on linux - python-version: ["3.7", "3.8", "3.9"] - os: [ubuntu-latest] - # Include one windows and macos run + # Run across a mixture of Python versions and operating systems include: + - os: ubuntu-latest + python-version: "3.11" - os: macos-latest - python-version: "3.9" + python-version: "3.10" - os: windows-latest python-version: "3.9" + - os: ubuntu-latest + python-version: "3.8" steps: - uses: brainglobe/actions/test@v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb90a1c..d3cc34c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort types: [text] types_or: [python, cython] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.4.0 hooks: - id: check-docstring-first - id: check-executables-have-shebangs @@ -20,16 +20,16 @@ repos: # bump2version produces whitespace in setup.cfg, so exclude to # not inferfere with versioning exclude: setup.cfg - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.2 + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 hooks: - id: flake8 - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.12.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.931 + rev: v0.991 hooks: - id: mypy additional_dependencies: diff --git a/setup.py b/setup.py index f78fa2a..aa8e5ba 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ "flake8", ] }, - python_requires=">=3.7", + python_requires=">=3.8", packages=find_packages(exclude=("tests", "tests.*")), include_package_data=True, url="https://github.com/brainglobe/imio", @@ -48,10 +48,10 @@ "Development Status :: 3 - Alpha", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Intended Audience :: Developers", "Intended Audience :: Science/Research", ], diff --git a/tests/tests/test_imio.py b/tests/tests/test_imio.py index dd60835..4609706 100644 --- a/tests/tests/test_imio.py +++ b/tests/tests/test_imio.py @@ -9,7 +9,7 @@ @pytest.fixture() def layer(): - return np.tile(np.array([1, 2, 3, 4]), (4, 1)) + return np.tile(np.array([1, 2, 3, 4], dtype=np.int32), (4, 1)) @pytest.fixture() diff --git a/tox.ini b/tox.ini index 464ae73..978bb51 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,12 @@ [tox] -envlist = py{37,38,39} +envlist = py{38,39,310,311} [gh-actions] python = - 3.7: py37 3.8: py38 3.9: py39 + 3.10: py310 + 3.11: py311 [testenv] extras = From e93fc18d4df9eab17f0e46767177d394f1b3ded9 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 3 Feb 2023 17:30:50 +0000 Subject: [PATCH 46/87] Replace brainglobe > NI actions (#14) --- .github/workflows/test_and_deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 6ee7183..fc3eb4b 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -6,7 +6,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: brainglobe/actions/lint@v1 + - uses: neuroinformatics-unit/actions/lint@v1 test: needs: lint @@ -26,7 +26,7 @@ jobs: python-version: "3.8" steps: - - uses: brainglobe/actions/test@v1 + - uses: neuroinformatics-unit/actions/test@v1 with: python-version: ${{ matrix.python-version }} From 8f5dc7e1652deee6d9a11962b5985ad7b7b7fd36 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 13 Feb 2023 10:05:33 +0000 Subject: [PATCH 47/87] Use standard pre-commit config (#15) * Add standard pre-commit config * pre-commit fixes --- .pre-commit-config.yaml | 18 +++++------------- pyproject.toml | 22 ++++++++-------------- setup.cfg | 4 ++-- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d3cc34c..0dfba3b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,4 @@ repos: - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - types: [text] - types_or: [python, cython] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: @@ -17,15 +11,12 @@ repos: args: [--fix=lf] - id: requirements-txt-fixer - id: trailing-whitespace - # bump2version produces whitespace in setup.cfg, so exclude to - # not inferfere with versioning - exclude: setup.cfg - - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.240 hooks: - - id: flake8 + - id: ruff - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy @@ -34,3 +25,4 @@ repos: - id: mypy additional_dependencies: - types-setuptools + - types-requests diff --git a/pyproject.toml b/pyproject.toml index dfab025..4e758eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,16 +1,10 @@ [tool.black] +target-version = ['py38', 'py39', 'py310'] +skip-string-normalization = false line-length = 79 -include = '\.pyi?$' -exclude = ''' -/( - \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | _build - | buck-out - | build - | dist -)/ -''' + +[tool.ruff] +line-length = 79 +exclude = ["__init__.py","build",".eggs"] +select = ["I", "E", "F"] +fix = true diff --git a/setup.cfg b/setup.cfg index 422e059..f5c1833 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,14 +4,14 @@ commit = True tag = True tag_name = {new_version} parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? -serialize = +serialize = {major}.{minor}.{patch}-{release}{rc} {major}.{minor}.{patch} [bumpversion:part:release] optional_value = prod first_value = rc -values = +values = rc prod From 4f0ffe70370044af3ec325613b4314f20ee11bb5 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 24 Feb 2023 13:12:10 +0000 Subject: [PATCH 48/87] Use pyproject.toml (#16) --- pyproject.toml | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 31 -------------------------- setup.py | 59 ------------------------------------------------- 3 files changed, 60 insertions(+), 90 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml index 4e758eb..e525ee6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,63 @@ +[project] +name = "imio" +description = "Loading and saving of image data." +readme = "README.md" +authors = [ + {name = "Charly Rousseau, Adam Tyson", email = "code@adamltyson.com"}, +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +requires-python = ">=3.8" +dependencies = [ + "imlib", + "natsort", + "nibabel", + "nibabel >= 2.1.0", + "numpy", + "psutil", + "pynrrd", + "scikit-image", + "slurmio >= 0.0.5", + "tifffile", + "tqdm", +] +dynamic = ['version'] + +[project.urls] +Homepage = "https://github.com/brainglobe/imio" + +[project.optional-dependencies] +dev = [ + "black", + "pre-commit", + "pytest", + "pytest-cov", +] + +[build-system] +requires = [ + "setuptools>=45", + "wheel", + "setuptools_scm[toml]>=6.2", +] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +include = ["imio*"] + +[tool.setuptools_scm] [tool.black] target-version = ['py38', 'py39', 'py310'] skip-string-normalization = false diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index f5c1833..0000000 --- a/setup.cfg +++ /dev/null @@ -1,31 +0,0 @@ -[bumpversion] -current_version = 0.2.4 -commit = True -tag = True -tag_name = {new_version} -parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? -serialize = - {major}.{minor}.{patch}-{release}{rc} - {major}.{minor}.{patch} - -[bumpversion:part:release] -optional_value = prod -first_value = rc -values = - rc - prod - -[bumpversion:part:rc] - -[bumpversion:file:setup.py] -search = version="{current_version}" -replace = version="{new_version}" - -[bumpversion:file:imio/__init__.py] -search = __version__ = "{current_version}" -replace = __version__ = "{new_version}" - -[flake8] -ignore = E203, E231, W503 -max-line-length = 79 -exclude = __init__.py diff --git a/setup.py b/setup.py deleted file mode 100644 index aa8e5ba..0000000 --- a/setup.py +++ /dev/null @@ -1,59 +0,0 @@ -from os import path - -from setuptools import find_packages, setup - -this_directory = path.abspath(path.dirname(__file__)) -with open(path.join(this_directory, "README.md"), encoding="utf-8") as f: - long_description = f.read() - -requirements = [ - "numpy", - "scikit-image", - "tifffile", - "pynrrd", - "nibabel", - "tqdm", - "natsort", - "psutil", - "slurmio >= 0.0.5", - "imlib", - "nibabel >= 2.1.0", -] - -setup( - name="imio", - version="0.2.4", - description="Loading and saving of image data.", - long_description=long_description, - long_description_content_type="text/markdown", - install_requires=requirements, - extras_require={ - "dev": [ - "black", - "pytest-cov", - "pytest", - "coverage", - "bump2version", - "pre-commit", - "flake8", - ] - }, - python_requires=">=3.8", - packages=find_packages(exclude=("tests", "tests.*")), - include_package_data=True, - url="https://github.com/brainglobe/imio", - author="Charly Rousseau, Adam Tyson", - author_email="code@adamltyson.com", - classifiers=[ - "Development Status :: 3 - Alpha", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - ], - zip_safe=False, -) From 4091d87adb692b1b1f391511d64d1781a43f6240 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 28 Feb 2023 16:28:16 +0000 Subject: [PATCH 49/87] Filter warnings in pytest (#17) * Filter warnings in pytest * Filter nptyping warnings --- pyproject.toml | 18 ++++++++++++++++++ pytest.ini | 2 -- 2 files changed, 18 insertions(+), 2 deletions(-) delete mode 100644 pytest.ini diff --git a/pyproject.toml b/pyproject.toml index e525ee6..deffb70 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,24 @@ include-package-data = true include = ["imio*"] [tool.setuptools_scm] + +[tool.pytest.ini_options] +addopts = "--cov=imio" +filterwarnings = [ + "error", + # Emitted by scikit-image on import, see https://github.com/scikit-image/scikit-image/issues/6663 + # This filter should be removed when scikit-image 0.20 is released + "ignore:`np.bool8` is a deprecated alias for `np.bool_`", + # Emitted by nptyping, see https://github.com/ramonhagenaars/nptyping/issues/102 + # for upstream issue + "ignore:`np.object0` is a deprecated alias for ``np.object0`", + "ignore:`np.int0` is a deprecated alias for `np.intp`", + "ignore:`np.uint0` is a deprecated alias for `np.uintp`", + "ignore:`np.void0` is a deprecated alias for `np.void`", + "ignore:`np.bytes0` is a deprecated alias for `np.bytes_`", + "ignore:`np.str0` is a deprecated alias for `np.str_`" +] + [tool.black] target-version = ['py38', 'py39', 'py310'] skip-string-normalization = false diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 0bfb381..0000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -addopts = --cov=imio From 61fb3b83d192f2e2470f2d8e6ff05223efcf980e Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 30 Mar 2023 17:12:35 +0100 Subject: [PATCH 50/87] Add all-contributors --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index afcda40..1c09d89 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ https://github.com/brainglobe/imio/actions) [![codecov](https://codecov.io/gh/brainglobe/imio/branch/master/graph/badge.svg?token=M1BXRDJ9V4)](https://codecov.io/gh/brainglobe/imio)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) [![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/brainglobe/imio) - +[![All Contributors](https://img.shields. +io/github/all-contributors/brainglobe/imio?color=ee8449&style=flat-square)](#contributors) # imio Loading and saving of image data. @@ -40,3 +41,14 @@ pip install imio ## Contributing Contributions to imio are more than welcome. Please see the [contributing guide](https://github.com/brainglobe/.github/blob/main/CONTRIBUTING.md). + +## Contributors + + + + + + + + + From 9f499daa3e4099de6d52c1e3c26a59c721db2c9e Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 30 Mar 2023 17:27:23 +0100 Subject: [PATCH 51/87] Update README.md Co-authored-by: David Stansby --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c09d89..f11f471 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ https://github.com/brainglobe/imio/actions) [![codecov](https://codecov.io/gh/brainglobe/imio/branch/master/graph/badge.svg?token=M1BXRDJ9V4)](https://codecov.io/gh/brainglobe/imio)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) [![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/brainglobe/imio) -[![All Contributors](https://img.shields. -io/github/all-contributors/brainglobe/imio?color=ee8449&style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/github/all-contributors/brainglobe/imio?color=ee8449&style=flat-square)](#contributors) # imio Loading and saving of image data. From 63c09bc9c36fd3d44ae40ba5518fb78f7a2d3761 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 30 Mar 2023 17:57:52 +0100 Subject: [PATCH 52/87] docs: add crousseau as a contributor for code, ideas, and test (#25) * docs: update README.md [skip ci] * docs: create .all-contributorsrc [skip ci] * Remove badge --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: Adam Tyson --- .all-contributorsrc | 27 +++++++++++++++++++++++++++ README.md | 15 ++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .all-contributorsrc diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 0000000..58d2f80 --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,27 @@ +{ + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": false, + "commitConvention": "angular", + "contributors": [ + { + "login": "crousseau", + "name": "Charly Rousseau", + "avatar_url": "https://avatars.githubusercontent.com/u/13150960?v=4", + "profile": "https://github.com/crousseau", + "contributions": [ + "code", + "ideas", + "test" + ] + } + ], + "contributorsPerLine": 7, + "skipCi": true, + "repoType": "github", + "repoHost": "https://github.com", + "projectName": "imio", + "projectOwner": "brainglobe" +} diff --git a/README.md b/README.md index f11f471..842aedb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ https://github.com/brainglobe/imio/actions) [![codecov](https://codecov.io/gh/brainglobe/imio/branch/master/graph/badge.svg?token=M1BXRDJ9V4)](https://codecov.io/gh/brainglobe/imio)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) [![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/brainglobe/imio) -[![All Contributors](https://img.shields.io/github/all-contributors/brainglobe/imio?color=ee8449&style=flat-square)](#contributors) # imio Loading and saving of image data. @@ -46,6 +45,20 @@ Contributions to imio are more than welcome. Please see the [contributing guide] + + + + + + +
Charly Rousseau
Charly Rousseau

💻 🤔 ⚠️
+ + + + + + + From 6661f2d3393355a516463dd2b826d03808131ac5 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 30 Mar 2023 18:00:14 +0100 Subject: [PATCH 53/87] Don't skip CI for all-contrbutors-bot --- .all-contributorsrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 58d2f80..223d0c8 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -19,7 +19,7 @@ } ], "contributorsPerLine": 7, - "skipCi": true, + "skipCi": false, "repoType": "github", "repoHost": "https://github.com", "projectName": "imio", From 9f9fb0146231a3685824c51cbb4d2d2598bfc682 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 30 Mar 2023 18:01:14 +0100 Subject: [PATCH 54/87] Update .all-contributorsrc --- .all-contributorsrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 223d0c8..af360b7 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -18,6 +18,8 @@ ] } ], + "commit": false, + "contributorsSortAlphabetically": true, "contributorsPerLine": 7, "skipCi": false, "repoType": "github", From b6b1b6720dbe8b06d604aca68a42ef1e8823a944 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 30 Mar 2023 18:05:01 +0100 Subject: [PATCH 55/87] docs: add jaimergp as a contributor for code (#23) * docs: update README.md [skip ci] * docs: create .all-contributorsrc [skip ci] * Update README.md --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: Adam Tyson --- .all-contributorsrc | 9 +++++++++ README.md | 1 + 2 files changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index af360b7..478c104 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7,6 +7,15 @@ "commitConvention": "angular", "contributors": [ { + "login": "jaimergp", + "name": "jaimergp", + "avatar_url": "https://avatars.githubusercontent.com/u/2559438?v=4", + "profile": "https://github.com/jaimergp", + "contributions": [ + "code" + ] + } + ], "login": "crousseau", "name": "Charly Rousseau", "avatar_url": "https://avatars.githubusercontent.com/u/13150960?v=4", diff --git a/README.md b/README.md index 842aedb..f0c19fa 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Contributions to imio are more than welcome. Please see the [contributing guide] + From 937ac894f33ec5b91f49a9edecd2bf4ccc770165 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 30 Mar 2023 18:10:31 +0100 Subject: [PATCH 56/87] docs: add JulesScholler as a contributor for code (#22) * docs: update README.md [skip ci] * docs: create .all-contributorsrc [skip ci] * Update README.md * Update .all-contributorsrc * Update .all-contributorsrc --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: Adam Tyson --- .all-contributorsrc | 13 +++++++++++-- README.md | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 478c104..0a97a52 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7,6 +7,15 @@ "commitConvention": "angular", "contributors": [ { + "login": "JulesScholler", + "name": "Jules Scholler", + "avatar_url": "https://avatars.githubusercontent.com/u/23705332?v=4", + "profile": "https://www.jscholler.com/", + "contributions": [ + "code" + ] + }, + { "login": "jaimergp", "name": "jaimergp", "avatar_url": "https://avatars.githubusercontent.com/u/2559438?v=4", @@ -14,8 +23,8 @@ "contributions": [ "code" ] - } - ], + }, + { "login": "crousseau", "name": "Charly Rousseau", "avatar_url": "https://avatars.githubusercontent.com/u/13150960?v=4", diff --git a/README.md b/README.md index f0c19fa..a0b84ac 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Contributions to imio are more than welcome. Please see the [contributing guide]
jaimergp
jaimergp

💻
Charly Rousseau
Charly Rousseau

💻 🤔 ⚠️
+ From 31823bbbceee9fde7b604489891b4357553565a9 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 30 Mar 2023 18:13:16 +0100 Subject: [PATCH 57/87] docs: add dstansby as a contributor for test, code, and 3 more (#21) * docs: update README.md [skip ci] * docs: create .all-contributorsrc [skip ci] * Update README.md --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: Adam Tyson --- .all-contributorsrc | 12 ++++++++++++ README.md | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 0a97a52..dc7b4eb 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7,6 +7,18 @@ "commitConvention": "angular", "contributors": [ { + "login": "dstansby", + "name": "David Stansby", + "avatar_url": "https://avatars.githubusercontent.com/u/6197628?v=4", + "profile": "https://www.davidstansby.com", + "contributions": [ + "test", + "code", + "maintenance", + "review", + "infra" + ] + } "login": "JulesScholler", "name": "Jules Scholler", "avatar_url": "https://avatars.githubusercontent.com/u/23705332?v=4", diff --git a/README.md b/README.md index a0b84ac..b1bd9e9 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ [![Downloads](https://pepy.tech/badge/imio)](https://pepy.tech/project/imio) [![Wheel](https://img.shields.io/pypi/wheel/imio.svg)](https://pypi.org/project/imio) [![Development Status](https://img.shields.io/pypi/status/imio.svg)](https://github.com/brainglobe/imio) -[![Tests](https://img.shields.io/github/workflow/status/brainglobe/imio/tests)]( - https://github.com/brainglobe/imio/actions) +[![Tests](https://img.shields.io/github/workflow/status/brainglobe/imio/tests)](https://github.com/brainglobe/imio/actions) [![codecov](https://codecov.io/gh/brainglobe/imio/branch/master/graph/badge.svg?token=M1BXRDJ9V4)](https://codecov.io/gh/brainglobe/imio)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) [![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/brainglobe/imio) @@ -48,6 +47,7 @@ Contributions to imio are more than welcome. Please see the [contributing guide]
Jules Scholler
Jules Scholler

💻
jaimergp
jaimergp

💻
Charly Rousseau
Charly Rousseau

💻 🤔 ⚠️
+ From b50438686487f2a667e1111c83dcdecf8cf55d80 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 30 Mar 2023 18:16:32 +0100 Subject: [PATCH 58/87] docs: add adamltyson as a contributor for code, infra, and 2 more (#24) * docs: update README.md [skip ci] * docs: create .all-contributorsrc [skip ci] * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] * Update README.md --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: Adam Tyson --- .all-contributorsrc | 12 ++++++++++++ README.md | 1 + 2 files changed, 13 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index dc7b4eb..569aa61 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -7,6 +7,17 @@ "commitConvention": "angular", "contributors": [ { + "login": "adamltyson", + "name": "Adam Tyson", + "avatar_url": "https://avatars.githubusercontent.com/u/13147259?v=4", + "profile": "http://adamltyson.com", + "contributions": [ + "code", + "infra", + "maintenance", + "test", + ] + } "login": "dstansby", "name": "David Stansby", "avatar_url": "https://avatars.githubusercontent.com/u/6197628?v=4", @@ -48,6 +59,7 @@ ] } ], + "commit": false, "contributorsSortAlphabetically": true, "contributorsPerLine": 7, diff --git a/README.md b/README.md index b1bd9e9..37e2d75 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Contributions to imio are more than welcome. Please see the [contributing guide]
David Stansby
David Stansby

⚠️ 💻 🚧 👀 🚇
Jules Scholler
Jules Scholler

💻
jaimergp
jaimergp

💻
Charly Rousseau
Charly Rousseau

💻 🤔 ⚠️
+ From ef57ad3b3eaf3327e11012cb192c9be49a1c0c4e Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 19 Jun 2023 14:41:47 +0100 Subject: [PATCH 59/87] Update doc links (#27) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37e2d75..5462594 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ pip install imio ``` ## Contributing -Contributions to imio are more than welcome. Please see the [contributing guide](https://github.com/brainglobe/.github/blob/main/CONTRIBUTING.md). +Contributions to imio are more than welcome. Please see the [developers guide](https://brainglobe.info/developers/index.html). ## Contributors From a14934a70926b3aa90045fd4d916f9c79b258711 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 20 Jun 2023 08:15:07 +0100 Subject: [PATCH 60/87] [pre-commit.ci] pre-commit autoupdate (#28) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.240 → v0.0.272](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.240...v0.0.272) - [github.com/psf/black: 23.1.0 → 23.3.0](https://github.com/psf/black/compare/23.1.0...23.3.0) - [github.com/pre-commit/mirrors-mypy: v0.991 → v1.3.0](https://github.com/pre-commit/mirrors-mypy/compare/v0.991...v1.3.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0dfba3b..0430e1a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,15 +12,15 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.240 + rev: v0.0.272 hooks: - id: ruff - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.3.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.991 + rev: v1.3.0 hooks: - id: mypy additional_dependencies: From 7c7f8d183639ee9b70c201134a3fcb6836563fb1 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 26 Jun 2023 13:52:06 +0100 Subject: [PATCH 61/87] Update dependency (imlib -> brainglobe-utils) (#29) --- imio/load.py | 5 ++++- imio/utils.py | 2 +- pyproject.toml | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/imio/load.py b/imio/load.py index d54d796..c5edf68 100644 --- a/imio/load.py +++ b/imio/load.py @@ -7,7 +7,10 @@ import nrrd import numpy as np import tifffile -from imlib.general.system import get_num_processes, get_sorted_file_paths +from brainglobe_utils.general.system import ( + get_num_processes, + get_sorted_file_paths, +) from natsort import natsorted from skimage import transform from tqdm import tqdm diff --git a/imio/utils.py b/imio/utils.py index 960b196..e6d87d2 100644 --- a/imio/utils.py +++ b/imio/utils.py @@ -1,7 +1,7 @@ import logging import psutil -from imlib.general.system import get_sorted_file_paths +from brainglobe_utils.general.system import get_sorted_file_paths from scipy.ndimage import zoom import imio diff --git a/pyproject.toml b/pyproject.toml index deffb70..c400c3e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ classifiers = [ ] requires-python = ">=3.8" dependencies = [ - "imlib", + "brainglobe-utils[slurmio]", "natsort", "nibabel", "nibabel >= 2.1.0", @@ -26,7 +26,6 @@ dependencies = [ "psutil", "pynrrd", "scikit-image", - "slurmio >= 0.0.5", "tifffile", "tqdm", ] From 18ce4e2c45968db9282da03f100a0e5e2b5a8bbe Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 27 Jun 2023 08:45:06 +0100 Subject: [PATCH 62/87] [pre-commit.ci] pre-commit autoupdate (#31) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.272 → v0.0.275](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.272...v0.0.275) - [github.com/pre-commit/mirrors-mypy: v1.3.0 → v1.4.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.3.0...v1.4.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0430e1a..cf65f26 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.272 + rev: v0.0.275 hooks: - id: ruff - repo: https://github.com/psf/black @@ -20,7 +20,7 @@ repos: hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.3.0 + rev: v1.4.1 hooks: - id: mypy additional_dependencies: From bdebb78dc0291967dd3b3e80b652ff448a720194 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 28 Jun 2023 11:24:56 +0100 Subject: [PATCH 63/87] remove all contributors (#32) --- .all-contributorsrc | 71 --------------------------------------------- README.md | 29 ------------------ 2 files changed, 100 deletions(-) delete mode 100644 .all-contributorsrc diff --git a/.all-contributorsrc b/.all-contributorsrc deleted file mode 100644 index 569aa61..0000000 --- a/.all-contributorsrc +++ /dev/null @@ -1,71 +0,0 @@ -{ - "files": [ - "README.md" - ], - "imageSize": 100, - "commit": false, - "commitConvention": "angular", - "contributors": [ - { - "login": "adamltyson", - "name": "Adam Tyson", - "avatar_url": "https://avatars.githubusercontent.com/u/13147259?v=4", - "profile": "http://adamltyson.com", - "contributions": [ - "code", - "infra", - "maintenance", - "test", - ] - } - "login": "dstansby", - "name": "David Stansby", - "avatar_url": "https://avatars.githubusercontent.com/u/6197628?v=4", - "profile": "https://www.davidstansby.com", - "contributions": [ - "test", - "code", - "maintenance", - "review", - "infra" - ] - } - "login": "JulesScholler", - "name": "Jules Scholler", - "avatar_url": "https://avatars.githubusercontent.com/u/23705332?v=4", - "profile": "https://www.jscholler.com/", - "contributions": [ - "code" - ] - }, - { - "login": "jaimergp", - "name": "jaimergp", - "avatar_url": "https://avatars.githubusercontent.com/u/2559438?v=4", - "profile": "https://github.com/jaimergp", - "contributions": [ - "code" - ] - }, - { - "login": "crousseau", - "name": "Charly Rousseau", - "avatar_url": "https://avatars.githubusercontent.com/u/13150960?v=4", - "profile": "https://github.com/crousseau", - "contributions": [ - "code", - "ideas", - "test" - ] - } - ], - - "commit": false, - "contributorsSortAlphabetically": true, - "contributorsPerLine": 7, - "skipCi": false, - "repoType": "github", - "repoHost": "https://github.com", - "projectName": "imio", - "projectOwner": "brainglobe" -} diff --git a/README.md b/README.md index 5462594..102e22e 100644 --- a/README.md +++ b/README.md @@ -38,32 +38,3 @@ pip install imio ## Contributing Contributions to imio are more than welcome. Please see the [developers guide](https://brainglobe.info/developers/index.html). - -## Contributors - - - - -
Adam Tyson
Adam Tyson

💻 🚇 🚧 ⚠️
David Stansby
David Stansby

⚠️ 💻 🚧 👀 🚇
Jules Scholler
Jules Scholler

💻
jaimergp
jaimergp

💻
- - - - - - - - - -
Adam Tyson
Adam Tyson

💻 🚇 🚧 ⚠️
David Stansby
David Stansby

⚠️ 💻 🚧 👀 🚇
Jules Scholler
Jules Scholler

💻
jaimergp
jaimergp

💻
Charly Rousseau
Charly Rousseau

💻 🤔 ⚠️
- - - - - - - - - - - - From 7d9b38e556f6b070f89c23f07fc283d0779ac7ca Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 08:10:03 +0100 Subject: [PATCH 64/87] [pre-commit.ci] pre-commit autoupdate (#33) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - https://github.com/charliermarsh/ruff-pre-commit → https://github.com/astral-sh/ruff-pre-commit - [github.com/astral-sh/ruff-pre-commit: v0.0.275 → v0.0.276](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.275...v0.0.276) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf65f26..3494562 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,8 +11,8 @@ repos: args: [--fix=lf] - id: requirements-txt-fixer - id: trailing-whitespace - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.275 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.276 hooks: - id: ruff - repo: https://github.com/psf/black From b7b3198a3f1115463c6de1a8d5abab95d66f06cd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Jul 2023 07:21:21 +0100 Subject: [PATCH 65/87] [pre-commit.ci] pre-commit autoupdate (#34) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.276 → v0.0.277](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.276...v0.0.277) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3494562..2881864 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.276 + rev: v0.0.277 hooks: - id: ruff - repo: https://github.com/psf/black From e0e5f3463c19f014a75c46ca01425198f75fe3d2 Mon Sep 17 00:00:00 2001 From: Will Graham <32364977+willGraham01@users.noreply.github.com> Date: Tue, 18 Jul 2023 11:35:03 +0100 Subject: [PATCH 66/87] Update CI workflow to use NIU actions (#35) --- .github/workflows/test_and_deploy.yml | 43 +++++++++++++-------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index fc3eb4b..ccc7bed 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -6,7 +6,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: neuroinformatics-unit/actions/lint@v1 + - uses: neuroinformatics-unit/actions/lint@v2 test: needs: lint @@ -26,29 +26,28 @@ jobs: python-version: "3.8" steps: - - uses: neuroinformatics-unit/actions/test@v1 + - uses: neuroinformatics-unit/actions/test@v2 with: python-version: ${{ matrix.python-version }} - deploy: - needs: test + build_sdist_wheels: + name: Build source distribution + needs: [test] + if: github.event_name == 'push' && github.ref_type == 'tag' runs-on: ubuntu-latest - if: contains(github.ref, 'tags') steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: "3.x" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -U setuptools setuptools_scm wheel twine - - name: Build and publish - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} - run: | - git tag - python setup.py sdist bdist_wheel - twine upload dist/* + - uses: neuroinformatics-unit/actions/build_sdist_wheels@v2 + + upload_all: + name: Publish build distributions + needs: [build_sdist_wheels] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + - uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.TWINE_API_KEY }} From 0f8699866a8918812a90825003e06dd8e8281637 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 13:23:03 +0100 Subject: [PATCH 67/87] [pre-commit.ci] pre-commit autoupdate (#36) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.277 → v0.0.278](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.277...v0.0.278) - [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2881864..9e4386e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,11 +12,11 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.277 + rev: v0.0.278 hooks: - id: ruff - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy From a629b28670eae19a3d21a026f28fd5f19c6bd362 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Jul 2023 07:45:50 -0700 Subject: [PATCH 68/87] [pre-commit.ci] pre-commit autoupdate (#37) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.278 → v0.0.280](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.278...v0.0.280) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e4386e..c8796b8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.278 + rev: v0.0.280 hooks: - id: ruff - repo: https://github.com/psf/black From 6c28c9c1c25274bcc9176ebe686f255cd7047fbf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 10:27:56 +0100 Subject: [PATCH 69/87] [pre-commit.ci] pre-commit autoupdate (#38) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.280 → v0.0.281](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.280...v0.0.281) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c8796b8..5c97909 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.280 + rev: v0.0.281 hooks: - id: ruff - repo: https://github.com/psf/black From cebc28e02e5f7d35dc78dc5d7cf1242e783af096 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 09:40:55 +0100 Subject: [PATCH 70/87] [pre-commit.ci] pre-commit autoupdate (#39) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.281 → v0.0.282](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.281...v0.0.282) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c97909..a71484a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.281 + rev: v0.0.282 hooks: - id: ruff - repo: https://github.com/psf/black From 15d9aeb963dda1b26a7db4b6cfcca4126761f1f9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Aug 2023 15:14:46 +0100 Subject: [PATCH 71/87] [pre-commit.ci] pre-commit autoupdate (#40) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.282 → v0.0.284](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.282...v0.0.284) - [github.com/pre-commit/mirrors-mypy: v1.4.1 → v1.5.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.4.1...v1.5.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a71484a..b1c6953 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.282 + rev: v0.0.284 hooks: - id: ruff - repo: https://github.com/psf/black @@ -20,7 +20,7 @@ repos: hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.4.1 + rev: v1.5.0 hooks: - id: mypy additional_dependencies: From b8489909aac171bf57c8a1f81a044bd46a7d9bfa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 14:03:55 +0100 Subject: [PATCH 72/87] [pre-commit.ci] pre-commit autoupdate (#41) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.284 → v0.0.285](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.284...v0.0.285) - [github.com/pre-commit/mirrors-mypy: v1.5.0 → v1.5.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.5.0...v1.5.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b1c6953..1914893 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.284 + rev: v0.0.285 hooks: - id: ruff - repo: https://github.com/psf/black @@ -20,7 +20,7 @@ repos: hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.5.0 + rev: v1.5.1 hooks: - id: mypy additional_dependencies: From c94cad26ee8db2f18b6b6ce574419d396393b72d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 10:12:29 +0100 Subject: [PATCH 73/87] [pre-commit.ci] pre-commit autoupdate (#42) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.285 → v0.0.286](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.285...v0.0.286) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1914893..9845047 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.285 + rev: v0.0.286 hooks: - id: ruff - repo: https://github.com/psf/black From 43a71ca65b3e1105290dea3bee6a7a19e0a74fdb Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 29 Aug 2023 10:47:59 +0100 Subject: [PATCH 74/87] Set pre-commit autoupdate frequency to monthly (#43) --- .pre-commit-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9845047..f60812b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,7 @@ +# Configuring https://pre-commit.ci/ +ci: + autoupdate_schedule: monthly + repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 From bed58d428e87f75a623e5ce7e15940250935909d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 12:13:27 +0100 Subject: [PATCH 75/87] [pre-commit.ci] pre-commit autoupdate (#44) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.286 → v0.0.287](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.286...v0.0.287) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f60812b..be39ad7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.286 + rev: v0.0.287 hooks: - id: ruff - repo: https://github.com/psf/black From 7a763f0e7497be0a7ed14f4edb0f168e497265a5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 09:36:55 +0100 Subject: [PATCH 76/87] [pre-commit.ci] pre-commit autoupdate (#45) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.287 → v0.0.292](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.287...v0.0.292) - [github.com/psf/black: 23.7.0 → 23.9.1](https://github.com/psf/black/compare/23.7.0...23.9.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index be39ad7..944d01c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,11 +16,11 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.287 + rev: v0.0.292 hooks: - id: ruff - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy From 877d979a6f1699d6b28b7efda9dfd3343685d2d0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:31:37 +0000 Subject: [PATCH 77/87] [pre-commit.ci] pre-commit autoupdate (#48) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) - [github.com/astral-sh/ruff-pre-commit: v0.0.292 → v0.1.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.292...v0.1.4) - [github.com/psf/black: 23.9.1 → 23.10.1](https://github.com/psf/black/compare/23.9.1...23.10.1) - [github.com/pre-commit/mirrors-mypy: v1.5.1 → v1.6.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.5.1...v1.6.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 944d01c..5e015b5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-docstring-first - id: check-executables-have-shebangs @@ -16,15 +16,15 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.292 + rev: v0.1.4 hooks: - id: ruff - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.10.1 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.5.1 + rev: v1.6.1 hooks: - id: mypy additional_dependencies: From d87e52a38455cf91bfe4101530a37a49e49c335f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 08:25:51 +0000 Subject: [PATCH 78/87] [pre-commit.ci] pre-commit autoupdate (#49) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.4 → v0.1.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.4...v0.1.6) - [github.com/psf/black: 23.10.1 → 23.11.0](https://github.com/psf/black/compare/23.10.1...23.11.0) - [github.com/pre-commit/mirrors-mypy: v1.6.1 → v1.7.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.6.1...v1.7.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5e015b5..5970391 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,15 +16,15 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.4 + rev: v0.1.6 hooks: - id: ruff - repo: https://github.com/psf/black - rev: 23.10.1 + rev: 23.11.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.6.1 + rev: v1.7.1 hooks: - id: mypy additional_dependencies: From bfe2a0dd9c72ad8bcd34f21b7c31f494d7947e18 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Jan 2024 07:50:16 +0000 Subject: [PATCH 79/87] [pre-commit.ci] pre-commit autoupdate (#50) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.6 → v0.1.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.6...v0.1.9) - [github.com/psf/black: 23.11.0 → 23.12.1](https://github.com/psf/black/compare/23.11.0...23.12.1) - [github.com/pre-commit/mirrors-mypy: v1.7.1 → v1.8.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.7.1...v1.8.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5970391..53d2857 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,15 +16,15 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.6 + rev: v0.1.9 hooks: - id: ruff - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.1 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.7.1 + rev: v1.8.0 hooks: - id: mypy additional_dependencies: From 176e87151dca2f0c40416cc10869fadd01d38bf4 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 10 Jan 2024 09:46:37 +0000 Subject: [PATCH 80/87] Update GH actions badge (#51) --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 102e22e..1db84f5 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,9 @@ [![Downloads](https://pepy.tech/badge/imio)](https://pepy.tech/project/imio) [![Wheel](https://img.shields.io/pypi/wheel/imio.svg)](https://pypi.org/project/imio) [![Development Status](https://img.shields.io/pypi/status/imio.svg)](https://github.com/brainglobe/imio) -[![Tests](https://img.shields.io/github/workflow/status/brainglobe/imio/tests)](https://github.com/brainglobe/imio/actions) -[![codecov](https://codecov.io/gh/brainglobe/imio/branch/master/graph/badge.svg?token=M1BXRDJ9V4)](https://codecov.io/gh/brainglobe/imio)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) +[![Tests](https://img.shields.io/github/actions/workflow/status/brainglobe/imio/test_and_deploy.yml?branch=main)](https://github.com/brainglobe/imio/actions) +[![codecov](https://codecov.io/gh/brainglobe/imio/branch/master/graph/badge.svg?token=M1BXRDJ9V4)](https://codecov.io/gh/brainglobe/imio) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) [![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://github.com/brainglobe/imio) # imio From d1c806b20a47d6aec7c1ee43c3baa650a2b6b95d Mon Sep 17 00:00:00 2001 From: Alessandro Felder Date: Mon, 5 Feb 2024 13:31:37 +0000 Subject: [PATCH 81/87] Update test_and_deploy.yml (#52) See https://github.com/neuroinformatics-unit/movement/pull/108 Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com> --- .github/workflows/test_and_deploy.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index ccc7bed..368e839 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -43,11 +43,6 @@ jobs: needs: [build_sdist_wheels] runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v3 + - uses: neuroinformatics-unit/actions/upload_pypi@v2 with: - name: artifact - path: dist - - uses: pypa/gh-action-pypi-publish@v1.5.0 - with: - user: __token__ - password: ${{ secrets.TWINE_API_KEY }} + secret-pypi-key: ${{ secrets.TWINE_API_KEY }} From 712fc00b4f93ce6b17a8e95958a724fb192e7697 Mon Sep 17 00:00:00 2001 From: Will Graham <32364977+willGraham01@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:09:33 +0000 Subject: [PATCH 82/87] Add manifest (#54) * Update CI workflows with manifest * Allow workflow to be dispatchable * Add pyarrow dependency to prevent future pandas failures --- .github/workflows/test_and_deploy.yml | 20 ++++++++++++-- MANIFEST.in | 8 ++++++ pyproject.toml | 40 +++++++++++++++++---------- tox.ini | 15 ---------- 4 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 MANIFEST.in delete mode 100644 tox.ini diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 368e839..0649eb1 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -1,15 +1,29 @@ name: tests -on: [push, pull_request] +on: + push: + branches: + - "main" + tags: + - "v**" + pull_request: + workflow_dispatch: jobs: - lint: + linting: + name: Check Linting runs-on: ubuntu-latest steps: - uses: neuroinformatics-unit/actions/lint@v2 + manifest: + name: Check Manifest + runs-on: ubuntu-latest + steps: + - uses: neuroinformatics-unit/actions/check_manifest@v2 + test: - needs: lint + needs: [linting, manifest] name: ${{ matrix.os }} py${{ matrix.python-version }} runs-on: ${{ matrix.os }} strategy: diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..18039b7 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,8 @@ +exclude .pre-commit-config.yaml + +include LICENSE +include README.md + +graft imio *.py + +prune tests diff --git a/pyproject.toml b/pyproject.toml index c400c3e..0826dc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "imio" description = "Loading and saving of image data." readme = "README.md" authors = [ - {name = "Charly Rousseau, Adam Tyson", email = "code@adamltyson.com"}, + { name = "Charly Rousseau, Adam Tyson", email = "code@adamltyson.com" }, ] classifiers = [ "Development Status :: 3 - Alpha", @@ -24,6 +24,7 @@ dependencies = [ "nibabel >= 2.1.0", "numpy", "psutil", + "pyarrow", "pynrrd", "scikit-image", "tifffile", @@ -35,19 +36,10 @@ dynamic = ['version'] Homepage = "https://github.com/brainglobe/imio" [project.optional-dependencies] -dev = [ - "black", - "pre-commit", - "pytest", - "pytest-cov", -] +dev = ["black", "pre-commit", "pytest", "pytest-cov"] [build-system] -requires = [ - "setuptools>=45", - "wheel", - "setuptools_scm[toml]>=6.2", -] +requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" [tool.setuptools] @@ -72,7 +64,7 @@ filterwarnings = [ "ignore:`np.uint0` is a deprecated alias for `np.uintp`", "ignore:`np.void0` is a deprecated alias for `np.void`", "ignore:`np.bytes0` is a deprecated alias for `np.bytes_`", - "ignore:`np.str0` is a deprecated alias for `np.str_`" + "ignore:`np.str0` is a deprecated alias for `np.str_`", ] [tool.black] @@ -82,6 +74,26 @@ line-length = 79 [tool.ruff] line-length = 79 -exclude = ["__init__.py","build",".eggs"] +exclude = ["__init__.py", "build", ".eggs"] select = ["I", "E", "F"] fix = true + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = py{38,39,310,311} + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 + +[testenv] +extras = + dev +commands = + pytest -v --color=yes --cov=imio --cov-report=xml + +""" diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 978bb51..0000000 --- a/tox.ini +++ /dev/null @@ -1,15 +0,0 @@ -[tox] -envlist = py{38,39,310,311} - -[gh-actions] -python = - 3.8: py38 - 3.9: py39 - 3.10: py310 - 3.11: py311 - -[testenv] -extras = - dev -commands = - pytest -v --color=yes --cov=imio --cov-report=xml From b9615ba301f544dd37e3d446514892016e980707 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:14:11 +0000 Subject: [PATCH 83/87] [pre-commit.ci] pre-commit autoupdate (#53) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.9 → v0.2.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.9...v0.2.0) - [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 53d2857..74f2506 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,11 +16,11 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.9 + rev: v0.2.0 hooks: - id: ruff - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy From f699d8aa56e923fa24c4e6134123a15f92cbd7df Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Fri, 9 Feb 2024 10:32:26 +0000 Subject: [PATCH 84/87] refactor image_io as submodule --- brainglobe_utils/brainreg/transform.py | 13 +++++++------ brainglobe_utils/image/heatmap.py | 4 ++-- brainglobe_utils/image_io/__init__.py | 6 ++++++ {imio => brainglobe_utils/image_io}/load.py | 7 ++++--- {imio => brainglobe_utils/image_io}/save.py | 0 {imio => brainglobe_utils/image_io}/utils.py | 10 +++++----- imio/__init__.py | 6 ------ pyproject.toml | 5 ++++- tests/tests/{test_imio.py => test_image_io.py} | 2 +- 9 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 brainglobe_utils/image_io/__init__.py rename {imio => brainglobe_utils/image_io}/load.py (99%) rename {imio => brainglobe_utils/image_io}/save.py (100%) rename {imio => brainglobe_utils/image_io}/utils.py (92%) delete mode 100644 imio/__init__.py rename tests/tests/{test_imio.py => test_image_io.py} (96%) diff --git a/brainglobe_utils/brainreg/transform.py b/brainglobe_utils/brainreg/transform.py index 7fe9400..703514f 100644 --- a/brainglobe_utils/brainreg/transform.py +++ b/brainglobe_utils/brainreg/transform.py @@ -2,13 +2,14 @@ import os from typing import List, Optional, Tuple -import bg_space as bgs -import imio +import brainglobe_space as bgs import numpy as np import pandas as pd import tifffile from bg_atlasapi import BrainGlobeAtlas +from brainglobe_utils.image_io import get_size_image_from_file_paths + def transform_points_from_downsampled_to_atlas_space( downsampled_points: np.ndarray, @@ -91,7 +92,7 @@ def get_anatomical_space_from_image_planes( image_plane : np.ndarray A numpy-like array representing a single image plane from a 3D image. orientation : str - The orientation of the image following the bg-space + The orientation of the image following the brainglobe-space three-letter convention (e.g., 'asr', 'psl'). voxel_sizes : List[float] A list of floats representing the voxel sizes (e.g., [5, 2, 2]). @@ -103,7 +104,7 @@ def get_anatomical_space_from_image_planes( """ - shape = tuple(imio.get_size_image_from_file_paths(image_plane).values()) + shape = tuple(get_size_image_from_file_paths(image_plane).values()) space = bgs.AnatomicalSpace( orientation, @@ -132,7 +133,7 @@ def transform_points_from_raw_to_downsampled_space( source_image_plane : np.ndarray A numpy-like array representing a single image. orientation : str - The orientation of the image following the bg-space + The orientation of the image following the brainglobe-space three letter convention (e.g. 'asr', 'psl') voxel_sizes : List[float] A list of floats representing the voxel sizes (e.g. [5, 2, 2]) @@ -182,7 +183,7 @@ def transform_points_to_atlas_space( source_image_plane : np.ndarray A numpy-like array representing a single image. orientation : str - The orientation of the image following the bg-space + The orientation of the image following the brainglobe-space three letter convention (e.g. 'asr', 'psl') voxel_sizes : List[float] A list of floats representing the voxel sizes (e.g. [5, 2, 2]) diff --git a/brainglobe_utils/image/heatmap.py b/brainglobe_utils/image/heatmap.py index 9c306b5..51e7b37 100644 --- a/brainglobe_utils/image/heatmap.py +++ b/brainglobe_utils/image/heatmap.py @@ -1,7 +1,6 @@ from pathlib import Path from typing import Tuple, Union -import imio import numpy as np from scipy.ndimage import zoom from skimage.filters import gaussian @@ -10,6 +9,7 @@ from brainglobe_utils.image.binning import get_bins from brainglobe_utils.image.masking import mask_image_threshold from brainglobe_utils.image.scale import scale_and_convert_to_16_bits +from brainglobe_utils.image_io import to_tiff def rescale_array(source_array, target_array, order=1): @@ -104,6 +104,6 @@ def heatmap_from_points( if output_filename is not None: ensure_directory_exists(Path(output_filename).parent) - imio.to_tiff(heatmap_array, output_filename) + to_tiff(heatmap_array, output_filename) return heatmap_array diff --git a/brainglobe_utils/image_io/__init__.py b/brainglobe_utils/image_io/__init__.py new file mode 100644 index 0000000..6d3bc46 --- /dev/null +++ b/brainglobe_utils/image_io/__init__.py @@ -0,0 +1,6 @@ +__author__ = "Charly Rousseau, Adam Tyson" +__version__ = "0.2.4" + +from brainglobe_utils.image_io.load import * +from brainglobe_utils.image_io.save import * +from brainglobe_utils.image_io.utils import * diff --git a/imio/load.py b/brainglobe_utils/image_io/load.py similarity index 99% rename from imio/load.py rename to brainglobe_utils/image_io/load.py index c5edf68..c6192d8 100644 --- a/imio/load.py +++ b/brainglobe_utils/image_io/load.py @@ -7,13 +7,14 @@ import nrrd import numpy as np import tifffile +from natsort import natsorted +from skimage import transform +from tqdm import tqdm + from brainglobe_utils.general.system import ( get_num_processes, get_sorted_file_paths, ) -from natsort import natsorted -from skimage import transform -from tqdm import tqdm from .utils import check_mem, scale_z diff --git a/imio/save.py b/brainglobe_utils/image_io/save.py similarity index 100% rename from imio/save.py rename to brainglobe_utils/image_io/save.py diff --git a/imio/utils.py b/brainglobe_utils/image_io/utils.py similarity index 92% rename from imio/utils.py rename to brainglobe_utils/image_io/utils.py index e6d87d2..546fdc6 100644 --- a/imio/utils.py +++ b/brainglobe_utils/image_io/utils.py @@ -1,13 +1,13 @@ import logging import psutil -from brainglobe_utils.general.system import get_sorted_file_paths from scipy.ndimage import zoom -import imio +from brainglobe_utils.general.system import get_sorted_file_paths +from brainglobe_utils.image_io import load_any -class ImioLoadException(Exception): +class ImageIOLoadException(Exception): pass @@ -26,7 +26,7 @@ def check_mem(img_byte_size, n_imgs): total_size = img_byte_size * n_imgs free_mem = psutil.virtual_memory().available if total_size >= free_mem: - raise ImioLoadException( + raise ImageIOLoadException( "Not enough memory on the system to complete loading operation" "Needed {}, only {} available.".format(total_size, free_mem) ) @@ -62,7 +62,7 @@ def get_size_image_from_file_paths(file_path, file_extension="tif"): logging.debug( "Loading file: {} to check raw image size" "".format(img_paths[0]) ) - image_0 = imio.load_any(img_paths[0]) + image_0 = load_any(img_paths[0]) y_shape, x_shape = image_0.shape image_shape = {"x": x_shape, "y": y_shape, "z": z_shape} diff --git a/imio/__init__.py b/imio/__init__.py deleted file mode 100644 index 46900e5..0000000 --- a/imio/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -__author__ = "Charly Rousseau, Adam Tyson" -__version__ = "0.2.4" - -from imio.load import * -from imio.save import * -from imio.utils import * diff --git a/pyproject.toml b/pyproject.toml index b84924e..746e0f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ classifiers = [ ] dependencies = [ "bg-atlasapi", + "brainglobe-space", "configobj", "natsort", "nibabel >= 2.1.0", @@ -101,9 +102,11 @@ line-length = 79 [tool.ruff] line-length = 79 exclude = ["__init__.py", "build", ".eggs"] -select = ["I", "E", "F"] fix = true +[tool.ruff.lint] +select = ["I", "E", "F"] + [tool.mypy] ignore_errors = true diff --git a/tests/tests/test_imio.py b/tests/tests/test_image_io.py similarity index 96% rename from tests/tests/test_imio.py rename to tests/tests/test_image_io.py index 4609706..17f8438 100644 --- a/tests/tests/test_imio.py +++ b/tests/tests/test_image_io.py @@ -4,7 +4,7 @@ import pytest from tifffile import tifffile -from imio import load, save, utils +from brainglobe_utils.image_io import load, save, utils @pytest.fixture() From a4586a415d677e351cb55e2845545779a1537727 Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Fri, 9 Feb 2024 11:06:34 +0000 Subject: [PATCH 85/87] Deprecated alias warning is still present --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 746e0f9..d3a45a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ filterwarnings = [ "error", # Emitted by scikit-image on import, see https://github.com/scikit-image/scikit-image/issues/6663 # This filter should be removed when scikit-image 0.20 is released - # "ignore:`np.bool8` is a deprecated alias for `np.bool_`", + "ignore:`np.bool8` is a deprecated alias for `np.bool_`", # Emitted by nptyping, see https://github.com/ramonhagenaars/nptyping/issues/102 # for upstream issue "ignore:`np.object0` is a deprecated alias for ``np.object0`", From ada6b011186543516776225fb8dfd6043ed47a22 Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Fri, 9 Feb 2024 11:23:12 +0000 Subject: [PATCH 86/87] Fix an actual circular import because of wildcard import --- brainglobe_utils/image_io/load.py | 25 +++++++++++++++++++++++++ brainglobe_utils/image_io/utils.py | 30 ------------------------------ 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/brainglobe_utils/image_io/load.py b/brainglobe_utils/image_io/load.py index c6192d8..52ab4a2 100644 --- a/brainglobe_utils/image_io/load.py +++ b/brainglobe_utils/image_io/load.py @@ -461,3 +461,28 @@ def load_from_paths_sequence( ) volume[:, :, i] = img return volume + + +def get_size_image_from_file_paths(file_path, file_extension="tif"): + """ + Returns the size of an image (which is a list of 2D files), without loading + the whole image + :param str file_path: File containing file_paths in a text file, + or as a list. + :param str file_extension: Optional file extension (if a directory + is passed) + :return: Dict of image sizes + """ + file_path = str(file_path) + + img_paths = get_sorted_file_paths(file_path, file_extension=file_extension) + z_shape = len(img_paths) + + logging.debug( + "Loading file: {} to check raw image size" "".format(img_paths[0]) + ) + image_0 = load_any(img_paths[0]) + y_shape, x_shape = image_0.shape + + image_shape = {"x": x_shape, "y": y_shape, "z": z_shape} + return image_shape diff --git a/brainglobe_utils/image_io/utils.py b/brainglobe_utils/image_io/utils.py index 546fdc6..afc5269 100644 --- a/brainglobe_utils/image_io/utils.py +++ b/brainglobe_utils/image_io/utils.py @@ -1,11 +1,6 @@ -import logging - import psutil from scipy.ndimage import zoom -from brainglobe_utils.general.system import get_sorted_file_paths -from brainglobe_utils.image_io import load_any - class ImageIOLoadException(Exception): pass @@ -42,28 +37,3 @@ def scale_z(volume, scaling_factor): """ return zoom(volume, (scaling_factor, 1, 1), order=1) - - -def get_size_image_from_file_paths(file_path, file_extension="tif"): - """ - Returns the size of an image (which is a list of 2D files), without loading - the whole image - :param str file_path: File containing file_paths in a text file, - or as a list. - :param str file_extension: Optional file extension (if a directory - is passed) - :return: Dict of image sizes - """ - file_path = str(file_path) - - img_paths = get_sorted_file_paths(file_path, file_extension=file_extension) - z_shape = len(img_paths) - - logging.debug( - "Loading file: {} to check raw image size" "".format(img_paths[0]) - ) - image_0 = load_any(img_paths[0]) - y_shape, x_shape = image_0.shape - - image_shape = {"x": x_shape, "y": y_shape, "z": z_shape} - return image_shape From 2328e0b79330d8655890d098b8715560e3edce82 Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Fri, 9 Feb 2024 11:43:59 +0000 Subject: [PATCH 87/87] Fix buggy html logo - wrong escape backslash --- brainglobe_utils/qtpy/logo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainglobe_utils/qtpy/logo.py b/brainglobe_utils/qtpy/logo.py index 003b669..78d9d75 100644 --- a/brainglobe_utils/qtpy/logo.py +++ b/brainglobe_utils/qtpy/logo.py @@ -29,7 +29,7 @@ def _logo_widget(package_name: str, parent: QWidget = None):

{package_name}

- <\h1> +

""" # noqa W605 return QLabel(_logo_html, parent=None)