This file is indexed.

/usr/share/pyshared/dipy/reconst/modelarray.py is in python-dipy 0.5.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/python
""" Class to present model parameters as voxel-shaped array """
# 5/17/2010

#import modules
from numpy import asarray, ones
from copy import copy

class ModelArray(object):
    """A class that has a shape and can be indexed like an ndarray

    When using a model to describe many voxels, ModelArray allows the
    parameters of a model to be stored as an ndarray where the last dimension
    of the array represents the parameters, and the first n-1 dimensions
    represent the shape or arrangement of the voxels. Model array is meant to
    be sub-classed to make more specific model classes.

    """
    ### Shape Property ###
    def _getshape(self):
        """
        Gives the shape of the ModelArray

        """

        return self.model_params.shape[:-1]

    def _setshape(self, shape):
        """
        Sets the shape of the ModelArray

        """
        if type(shape) is not tuple:
            shape = (shape,)
        self.model_params.shape = shape + self.model_params.shape[-1:]

    shape = property(_getshape, _setshape, doc = "Shape of model array")

    ### Ndim Property ###
    @property
    def ndim(self):
        """Gives the number of dimensions of the ModelArray
        """
        return self.model_params.ndim - 1

    @property
    def mask(self):
        """If the model_params array has a mask, returns the mask
        """
        if hasattr(self.model_params, 'mask'):
            return self.model_params.mask
        else:
            return ones(self.shape, 'bool')

    ### Getitem Property ###
    def __getitem__(self, index):
        """
        Returns part of the model array

        """
        if type(index) is not tuple:
            index = (index,)
        if len(index) > self.ndim:
            raise IndexError('invalid index')
        for ii, slc in enumerate(index):
            if slc is Ellipsis:
                n_ellipsis = len(self.shape) - len(index) + 1
                index = index[:ii] + n_ellipsis*(slice(None),) + index[ii+1:]
                break

        new_model = copy(self)
        new_model.model_params = self.model_params[index]
        return new_model

    def _get_model_params(self):
        """Parameters of the model

        All the parameters needed for a model should be flattened into the last
        dimension of model_params. The shape of the ModelArray is determined by
        the model_params.shape[:-1].
        """
        return self._model_params

    def _set_model_params(self, params):
        """Sets model_params
        """
        self._model_params = params

    model_params = property(_get_model_params, _set_model_params)