Skip to content
Snippets Groups Projects
Commit 51522048 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

MNT: Removed all the deprecated things

parent 0904c833
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,6 @@ import re ...@@ -32,7 +32,6 @@ import re
import glob import glob
import json import json
import logging import logging
import deprecation
import nibabel as nib import nibabel as nib
...@@ -80,38 +79,6 @@ class DicomImage(fslimage.Image): ...@@ -80,38 +79,6 @@ class DicomImage(fslimage.Image):
return self.__dicomDir return self.__dicomDir
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use metaKeys instead')
def keys(self):
"""Deprecated - use :meth:`.Image.metaKeys`. """
return self.metaKeys()
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use metaValues instead')
def values(self):
"""Deprecated - use :meth:`.Image.metaValues`. """
return self.metaValues()
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use metaItems instead')
def items(self):
"""Deprecated - use :meth:`.Image.metaItems`. """
return self.metaItems()
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use getMeta instead')
def get(self, *args, **kwargs):
"""Deprecated - use :meth:`.Image.getMeta`. """
return self.getMeta(*args, **kwargs)
@memoize.memoize @memoize.memoize
def enabled(): def enabled():
"""Returns ``True`` if ``dcm2niix`` is present, and recent enough, """Returns ``True`` if ``dcm2niix`` is present, and recent enough,
......
...@@ -25,7 +25,6 @@ are available: ...@@ -25,7 +25,6 @@ are available:
import glob import glob
import os.path as op import os.path as op
import deprecation
import numpy as np import numpy as np
import nibabel as nib import nibabel as nib
...@@ -306,48 +305,3 @@ def relatedFiles(fname, ftypes=None): ...@@ -306,48 +305,3 @@ def relatedFiles(fname, ftypes=None):
glob.glob(op.join(dirname, '{}*{}'.format(prefix, ftype)))) glob.glob(op.join(dirname, '{}*{}'.format(prefix, ftype))))
return [r for r in related if r != path] return [r for r in related if r != path]
class GiftiSurface(fslmesh.TriangleMesh):
"""Deprecated - use GiftiMesh instead. """
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use GiftiMesh instead')
def __init__(self, infile, fixWinding=False):
"""Deprecated - use GiftiMesh instead. """
surfimg, vertices, indices = loadGiftiSurface(infile)
fslmesh.TriangleMesh.__init__(self, vertices, indices, fixWinding)
name = fslpath.removeExt(op.basename(infile), ALLOWED_EXTENSIONS)
infile = op.abspath(infile)
self._Mesh__name = name
self._Mesh__dataSource = infile
self.surfImg = surfimg
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use GiftiMesh instead')
def loadVertexData(self, dataSource, vertexData=None):
"""Deprecated - use GiftiMesh instead. """
if vertexData is None:
if dataSource.endswith('.gii'):
vertexData = loadGiftiVertexData(dataSource)[1]
else:
vertexData = None
return fslmesh.TriangleMesh.loadVertexData(
self, dataSource, vertexData)
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use loadGiftiMesh instead')
def loadGiftiSurface(filename):
"""Deprecated - use loadGiftiMesh instead."""
return loadGiftiMesh(filename)
...@@ -41,7 +41,6 @@ import logging ...@@ -41,7 +41,6 @@ import logging
import tempfile import tempfile
import six import six
import deprecation
import numpy as np import numpy as np
import scipy.ndimage as ndimage import scipy.ndimage as ndimage
...@@ -502,23 +501,6 @@ class Nifti(notifier.Notifier, meta.Meta): ...@@ -502,23 +501,6 @@ class Nifti(notifier.Notifier, meta.Meta):
return len(self.__shape) return len(self.__shape)
@property
@deprecation.deprecated(deprecated_in='1.9.0',
removed_in='2.0.0',
details='Use ndim instead')
def ndims(self):
"""Deprecated - use :mod::meth:``ndim`` instead. """
return self.ndim
@deprecation.deprecated(deprecated_in='1.1.0',
removed_in='2.0.0',
details='Use ndims instead')
def is4DImage(self):
"""Returns ``True`` if this image is 4D, ``False`` otherwise. """
return len(self.__shape) > 3 and self.__shape[3] > 1
def getXFormCode(self, code=None): def getXFormCode(self, code=None):
"""This method returns the code contained in the NIFTI header, """This method returns the code contained in the NIFTI header,
indicating the space to which the (transformed) image is oriented. indicating the space to which the (transformed) image is oriented.
...@@ -605,15 +587,6 @@ class Nifti(notifier.Notifier, meta.Meta): ...@@ -605,15 +587,6 @@ class Nifti(notifier.Notifier, meta.Meta):
return npla.det(self.__voxToWorldMat) > 0 return npla.det(self.__voxToWorldMat) > 0
@memoize.Instanceify(memoize.memoize)
@deprecation.deprecated(deprecated_in='1.2.0',
removed_in='2.0.0',
details='Use voxToScaledVoxMat instead')
def voxelsToScaledVoxels(self):
"""See :meth:`voxToScaledVoxMat`."""
return self.voxToScaledVoxMat
@property @property
def voxToScaledVoxMat(self): def voxToScaledVoxMat(self):
"""Returns a transformation matrix which transforms from voxel """Returns a transformation matrix which transforms from voxel
...@@ -1519,78 +1492,3 @@ def loadIndexedImageFile(filename): ...@@ -1519,78 +1492,3 @@ def loadIndexedImageFile(filename):
image = ftype.from_file_map(fmap) image = ftype.from_file_map(fmap)
return image, fobj return image, fobj
@deprecation.deprecated(deprecated_in='1.3.0',
removed_in='2.0.0',
details='Upgrade to nibabel 2.2.0')
def read_segments(fileobj, segments, n_bytes):
"""This function is used in place of the
``nibabel.fileslice.read_segments`` function to ensure thread-safe read
access to image data via the ``nibabel.arrayproxy.ArrayProxy`` (the
``dataobj`` attribute of a ``nibabel`` image).
The ``nibabel`` implementation uses multiple calls to ``seek`` and
``read`` to read segments of data from the file. When accessed by multiple
threads, these seeks and reads can become intertwined, which causes a read
from one thread to read data from the seek location requested by the other
thread.
This implementation protects the seek/read pairs with a
``threading.Lock``, which is added to ``IndexedGzipFile`` instances that
are created in the :func:`loadIndexedImageFile` function.
.. note:: This patch is not required in nibabel 2.2.0 and newer. It will
be removed from ``fslpy`` in version 2.0.0.
"""
from mmap import mmap
try:
# fileobj is a nibabel.openers.ImageOpener - the
# actual file is available via the fobj attribute
lock = getattr(fileobj.fobj, '_arrayproxy_lock')
except AttributeError:
return fileslice.orig_read_segments(fileobj, segments, n_bytes)
if len(segments) == 0:
if n_bytes != 0:
raise ValueError("No segments, but non-zero n_bytes")
return b''
if len(segments) == 1:
offset, length = segments[0]
lock.acquire()
try:
fileobj.seek(offset)
bytes = fileobj.read(length)
finally:
lock.release()
if len(bytes) != n_bytes:
raise ValueError("Whoops, not enough data in file")
return bytes
# More than one segment
bytes = mmap(-1, n_bytes)
for offset, length in segments:
lock.acquire()
try:
fileobj.seek(offset)
bytes.write(fileobj.read(length))
finally:
lock.release()
if bytes.tell() != n_bytes:
raise ValueError("Oh dear, n_bytes does not look right")
return bytes
# Monkey-patch the above implementation into
# nibabel. FSLeyes requires at least 2.1.0 -
# newer versions do not need to be patched.
if nib.__version__ == '2.1.0':
fileslice.orig_read_segments = fileslice.read_segments
fileslice.read_segments = read_segments
...@@ -41,8 +41,6 @@ import logging ...@@ -41,8 +41,6 @@ import logging
import collections import collections
import itertools as it import itertools as it
import deprecation
import numpy as np import numpy as np
import nibabel as nib import nibabel as nib
...@@ -717,16 +715,6 @@ class ImageWrapper(notifier.Notifier): ...@@ -717,16 +715,6 @@ class ImageWrapper(notifier.Notifier):
self.__updateDataRangeOnWrite(slices, values) self.__updateDataRangeOnWrite(slices, values)
@deprecation.deprecated(deprecated_in='1.7.0',
removed_in='2.0.0',
details='Moved to fsl.utils.naninfrange')
def naninfrange(data):
"""Deprecated - moved to :mod:`fsl.utils.naninfrange`. """
from fsl.utils.naninfrange import naninfrange
return naninfrange(data)
def isValidFancySliceObj(sliceobj, shape): def isValidFancySliceObj(sliceobj, shape):
"""Returns ``True`` if the given ``sliceobj`` is a valid and fancy slice """Returns ``True`` if the given ``sliceobj`` is a valid and fancy slice
object. object.
...@@ -768,15 +756,6 @@ def canonicalSliceObj(sliceobj, shape): ...@@ -768,15 +756,6 @@ def canonicalSliceObj(sliceobj, shape):
return nib.fileslice.canonical_slicers(sliceobj, shape) return nib.fileslice.canonical_slicers(sliceobj, shape)
@deprecation.deprecated(deprecated_in='1.7.0',
removed_in='2.0.0',
details='moved to the fsl.data.image module')
def canonicalShape(shape):
"""Deprecated - moved to the :mod:`fsl.data.image` module. """
from fsl.data.image import canonicalShape
return canonicalShape(shape)
def expectedShape(sliceobj, shape): def expectedShape(sliceobj, shape):
"""Given a slice object, and the shape of an array to which """Given a slice object, and the shape of an array to which
that slice object is going to be applied, returns the expected that slice object is going to be applied, returns the expected
......
...@@ -30,9 +30,6 @@ various things with meshes: ...@@ -30,9 +30,6 @@ various things with meshes:
import logging import logging
import collections import collections
import six
import deprecation
import os.path as op import os.path as op
import numpy as np import numpy as np
...@@ -763,109 +760,3 @@ def needsFixing(vertices, indices, fnormals, loBounds, hiBounds): ...@@ -763,109 +760,3 @@ def needsFixing(vertices, indices, fnormals, loBounds, hiBounds):
# If it isn't, we need to flip the # If it isn't, we need to flip the
# triangle winding order. # triangle winding order.
return np.dot(n, transform.normalise(camera - vert)) < 0 return np.dot(n, transform.normalise(camera - vert)) < 0
class TriangleMesh(Mesh):
"""Deprecated - use :class:`fsl.data.mesh.Mesh`, or one of its sub-classes
instead.
"""
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use fsl.data.mesh.Mesh, or one '
'of its sub-classes instead')
def __init__(self, data, indices=None, fixWinding=False):
import fsl.data.vtk as fslvtk
if isinstance(data, six.string_types):
name = op.basename(data)
dataSource = data
mesh = fslvtk.VTKMesh(data, fixWinding=False)
vertices = mesh.vertices
indices = mesh.indices
else:
name = 'TriangleMesh'
dataSource = None
vertices = data
Mesh.__init__(self, indices, name=name, dataSource=dataSource)
self.addVertices(vertices, 'default', fixWinding=fixWinding)
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use the Mesh class instead')
def loadVertexData(self, dataSource, vertexData=None):
nvertices = self.vertices.shape[0]
# Currently only white-space delimited
# text files are supported
if vertexData is None:
vertexData = np.loadtxt(dataSource)
vertexData.reshape(nvertices, -1)
if vertexData.shape[0] != nvertices:
raise ValueError('Incompatible size: {}'.format(dataSource))
self.addVertexData(dataSource, vertexData)
return vertexData
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use bounds instead')
def getBounds(self):
"""Deprecated - use :meth:`bounds` instead. """
return self.bounds
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use the Mesh class instead')
def getVertexData(self, dataSource):
try:
return Mesh.getVertexData(self, dataSource)
except KeyError:
return self.loadVertexData(dataSource)
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use fsl.data.vtk.loadVTKPolydataFile instead')
def loadVTKPolydataFile(*args, **kwargs):
"""Deprecated - use :func:`fsl.data.vtk.loadVTKPolydataFile` instead. """
import fsl.data.vtk as fslvtk
return fslvtk.loadVTKPolydataFile(*args, **kwargs)
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use fsl.data.vtk.getFIRSTPrefix instead')
def getFIRSTPrefix(*args, **kwargs):
"""Deprecated - use :func:`fsl.data.vtk.getFIRSTPrefix` instead. """
import fsl.data.vtk as fslvtk
return fslvtk.getFIRSTPrefix(*args, **kwargs)
@deprecation.deprecated(deprecated_in='1.6.0',
removed_in='2.0.0',
details='Use fsl.data.vtk.findReferenceImage instead')
def findReferenceImage(*args, **kwargs):
"""Deprecated - use :func:`fsl.data.vtk.findReferenceImage` instead. """
import fsl.data.vtk as fslvtk
return fslvtk.findReferenceImage(*args, **kwargs)
ALLOWED_EXTENSIONS = ['.vtk']
"""Deprecated, will be removed in fslpy 2.0.0. Use
:attr:`fsl.data.vtk.ALLOWED_EXTENSIONS` instead."""
EXTENSION_DESCRIPTIONS = ['VTK polygon model file']
"""Deprecated, will be removed in fslpy 2.0.0. Use
:attr:`fsl.data.vtk.EXTENSION_DESCRIPTIONS` instead."""
#!/usr/bin/env python
#
# async.py - Deprecaed - use the idle module instead.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
"""This module is deprecated - use the :mod:`.idle` module instead. """
import logging
import warnings
from .idle import (run, # noqa
idleReset,
getIdleTimeout,
setIdleTimeout,
inIdle,
cancelIdle,
idle,
idleWhen,
wait,
TaskThreadVeto,
TaskThread,
mutex)
log = logging.getLogger(__name__)
warnings.warn('fsl.utils.async is deprecated and will be removed '
'in fslpy 2.0.0 - use fsl.utils.idle instead',
DeprecationWarning)
log.warning('fsl.utils.async is deprecated and will be removed '
'in fslpy 2.0.0 - use fsl.utils.idle instead')
#!/usr/bin/env python
#
# callfsl.py - The callFSL function.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
"""Deprecated - use :mod:`fsl.utils.run` instead.
This module provides the :func:`callFSL` function, which can be
used to call a FSL command, and retrieve the result.
"""
import logging
import subprocess as sp
import os.path as op
import deprecation
from fsl.utils.platform import platform as fslplatform
log = logging.getLogger(__name__)
@deprecation.deprecated(deprecated_in='1.8.0',
removed_in='2.0.0',
details='Use fsl.utils.run.runfsl instead')
def callFSL(*args):
"""Call a FSL command and return the result.
You can pass the command and arguments as a single string, or as a
list/tuple.
"""
if fslplatform.fsldir is None:
raise RuntimeError('FSL cannot be found!')
# If we've been given a single argument,
# assume it is a string containing the
# command and its arguments. Otherwise,
# assume it is a sequence containing
# separate command and arguments.
if len(args) == 1:
args = args[0].split()
args = list(args)
args[0] = op.join(fslplatform.fsldir, 'bin', args[0])
log.debug('callfsl: {}'.format(' '.join(args)))
result = sp.check_output(args).decode('utf-8')
log.debug('result: {}'.format(result))
return result
...@@ -17,7 +17,6 @@ import os ...@@ -17,7 +17,6 @@ import os
import os.path as op import os.path as op
import sys import sys
import importlib import importlib
import deprecation
import fsl.utils.notifier as notifier import fsl.utils.notifier as notifier
...@@ -73,34 +72,6 @@ are running the Linux/GTK wx build. ...@@ -73,34 +72,6 @@ are running the Linux/GTK wx build.
""" """
@deprecation.deprecated(deprecated_in='1.2.2',
removed_in='2.0.0',
details='Use fsleyes_widgets.isalive instead')
def isWidgetAlive(widget):
"""Returns ``True`` if the given ``wx.Window`` object is "alive" (i.e.
has not been destroyed), ``False`` otherwise. Works in both wxPython
and wxPython/Phoenix.
.. warning:: Don't try to test whether a ``wx.MenuItem`` has been
destroyed, as it will probably result in segmentation
faults. Check the parent ``wx.Menu`` instead.
"""
import wx
if platform.wxFlavour == platform.WX_PHOENIX:
excType = RuntimeError
elif platform.wxFlavour == platform.WX_PYTHON:
excType = wx.PyDeadObjectError
try:
widget.GetParent()
return True
except excType:
return False
class Platform(notifier.Notifier): class Platform(notifier.Notifier):
"""The ``Platform`` class contains a handful of properties which contain """The ``Platform`` class contains a handful of properties which contain
information about the platform we are running on. information about the platform we are running on.
...@@ -138,7 +109,6 @@ class Platform(notifier.Notifier): ...@@ -138,7 +109,6 @@ class Platform(notifier.Notifier):
self.WX_MAC_COCOA = WX_MAC_COCOA self.WX_MAC_COCOA = WX_MAC_COCOA
self.WX_MAC_CARBON = WX_MAC_CARBON self.WX_MAC_CARBON = WX_MAC_CARBON
self.WX_GTK = WX_GTK self.WX_GTK = WX_GTK
self.isWidgetAlive = isWidgetAlive
self.__inSSHSession = False self.__inSSHSession = False
self.__inVNCSession = False self.__inVNCSession = False
......
...@@ -144,10 +144,6 @@ def run(*args, **kwargs): ...@@ -144,10 +144,6 @@ def run(*args, **kwargs):
exception is not raised. Ignored if ``submit`` is exception is not raised. Ignored if ``submit`` is
specified. specified.
:arg err: Deprecated - use ``stderr`` instead.
:arg ret: Deprecated - use ``exitcode`` instead.
:arg submit: Must be passed as a keyword argument. Defaults to ``None``. :arg submit: Must be passed as a keyword argument. Defaults to ``None``.
If ``True``, the command is submitted as a cluster job via If ``True``, the command is submitted as a cluster job via
the :func:`.fslsub.submit` function. May also be a the :func:`.fslsub.submit` function. May also be a
...@@ -175,17 +171,6 @@ def run(*args, **kwargs): ...@@ -175,17 +171,6 @@ def run(*args, **kwargs):
``stderr``, and ``exitcode`` arguments. ``stderr``, and ``exitcode`` arguments.
""" """
if 'err' in kwargs:
warnings.warn('err is deprecated and will be removed '
'in fslpy 2.0.0 - use stderr instead',
DeprecationWarning)
kwargs['stderr'] = kwargs.get('stderr', kwargs['err'])
if 'ret' in kwargs:
warnings.warn('ret is deprecated and will be removed '
'in fslpy 2.0.0 - use exitcode instead',
DeprecationWarning)
kwargs['exitcode'] = kwargs.get('exitcode', kwargs['ret'])
returnStdout = kwargs.get('stdout', True) returnStdout = kwargs.get('stdout', True)
returnStderr = kwargs.get('stderr', False) returnStderr = kwargs.get('stderr', False)
returnExitcode = kwargs.get('exitcode', False) returnExitcode = kwargs.get('exitcode', False)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment