From 379ded01bb419d1a72fb4543078fb802a9abb6dd Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Wed, 30 Aug 2023 10:36:43 +0100 Subject: [PATCH] MNT: Remove some obsolete warning suppression. Suppress nibabel warning when converting to NIFTI2 --- fsl/scripts/atlasq.py | 17 +++-------------- fsl/scripts/fsl_ents.py | 8 ++------ fsl/scripts/imcp.py | 15 ++++++++------- fsl/scripts/immv.py | 15 ++++++++------- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/fsl/scripts/atlasq.py b/fsl/scripts/atlasq.py index b0ef32a94..9e887e688 100644 --- a/fsl/scripts/atlasq.py +++ b/fsl/scripts/atlasq.py @@ -19,20 +19,9 @@ import warnings import logging import numpy as np -# if h5py <= 2.7.1 is installed, -# it will be imported via nibabel, -# and will cause a numpy warning -# to be emitted. -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=FutureWarning) - import fsl.data.image as fslimage - -# If wx is not present, then fsl.utils.platform -# will complain that it is not present. -logging.getLogger('fsl.utils.platform').setLevel(logging.ERROR) - -import fsl.data.atlases as fslatlases # noqa -import fsl.version as fslversion # noqa +import fsl.data.image as fslimage +import fsl.data.atlases as fslatlases +import fsl.version as fslversion log = logging.getLogger(__name__) diff --git a/fsl/scripts/fsl_ents.py b/fsl/scripts/fsl_ents.py index 1590c9b44..2f9a4a0b1 100644 --- a/fsl/scripts/fsl_ents.py +++ b/fsl/scripts/fsl_ents.py @@ -16,12 +16,8 @@ import warnings import numpy as np -# See atlasq.py for explanation -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=FutureWarning) - - import fsl.data.fixlabels as fixlabels - import fsl.data.melodicanalysis as melanalysis +import fsl.data.fixlabels as fixlabels +import fsl.data.melodicanalysis as melanalysis DTYPE = np.float64 diff --git a/fsl/scripts/imcp.py b/fsl/scripts/imcp.py index d2fcc1eda..6ae4d26da 100755 --- a/fsl/scripts/imcp.py +++ b/fsl/scripts/imcp.py @@ -14,15 +14,11 @@ The :func:`main` function is essentially a wrapper around the import os.path as op import sys -import warnings +import logging import fsl.utils.path as fslpath - -# See atlasq.py for explanation -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=FutureWarning) - import fsl.utils.imcp as imcp - import fsl.data.image as fslimage +import fsl.utils.imcp as imcp +import fsl.data.image as fslimage usage = """Usage: @@ -57,6 +53,11 @@ def main(argv=None): print(usage) return 1 + # When converting to NIFTI2, nibabel + # emits an annoying message via log.warning: + # sizeof_hdr should be 540; set sizeof_hdr to 540 + logging.getLogger('nibabel').setLevel(logging.ERROR) + try: srcs = [fslimage.fixExt(s) for s in srcs] srcs = fslpath.removeDuplicates( diff --git a/fsl/scripts/immv.py b/fsl/scripts/immv.py index febe42274..0ebfb575d 100755 --- a/fsl/scripts/immv.py +++ b/fsl/scripts/immv.py @@ -15,15 +15,11 @@ The :func:`main` function is essentially a wrapper around the import os.path as op import sys -import warnings +import logging import fsl.utils.path as fslpath - -# See atlasq.py for explanation -with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=FutureWarning) - import fsl.utils.imcp as imcp - import fsl.data.image as fslimage +import fsl.utils.imcp as imcp +import fsl.data.image as fslimage usage = """Usage: @@ -58,6 +54,11 @@ def main(argv=None): print(usage) return 1 + # When converting to NIFTI2, nibabel + # emits an annoying message via log.warning: + # sizeof_hdr should be 540; set sizeof_hdr to 540 + logging.getLogger('nibabel').setLevel(logging.ERROR) + try: srcs = [fslimage.fixExt(s) for s in srcs] srcs = fslpath.removeDuplicates( -- GitLab