Skip to content

Commit d231004

Browse files
committed
DOC: edits to docstrings
1 parent d910a5e commit d231004

File tree

1 file changed

+38
-39
lines changed

1 file changed

+38
-39
lines changed

nibabel/streamlines/tractogram.py

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class PerArrayDict(SliceableDataDict):
8080
8181
In addition, it makes sure the amount of data contained in those ndarrays
8282
matches the number of streamlines given at the instantiation of this
83-
dictionary.
83+
instance.
8484
"""
8585
def __init__(self, nb_elements, *args, **kwargs):
8686
self.nb_elements = nb_elements
@@ -114,7 +114,7 @@ class PerArraySequenceDict(SliceableDataDict):
114114
115115
In addition, it makes sure the amount of data contained in those array
116116
sequences matches the number of elements given at the instantiation
117-
of this dictionary.
117+
of the instance.
118118
"""
119119
def __init__(self, nb_elements, *args, **kwargs):
120120
self.nb_elements = nb_elements
@@ -136,9 +136,9 @@ def __setitem__(self, key, value):
136136
class LazyDict(collections.MutableMapping):
137137
""" Dictionary of generator functions.
138138
139-
This container behaves like an dictionary but it makes sure its elements
140-
are callable objects and assumed to be generator function yielding values.
141-
When getting the element associated to a given key, the element (i.e. a
139+
This container behaves like a dictionary but it makes sure its elements are
140+
callable objects that it assumes are generator functions yielding values.
141+
When getting the element associated with a given key, the element (i.e. a
142142
generator function) is first called before being returned.
143143
"""
144144
def __init__(self, *args, **kwargs):
@@ -178,7 +178,7 @@ def __len__(self):
178178
class TractogramItem(object):
179179
""" Class containing information about one streamline.
180180
181-
:class:`TractogramItem` objects have three main properties: `streamline`,
181+
:class:`TractogramItem` objects have three public attributes: `streamline`,
182182
`data_for_streamline`, and `data_for_points`.
183183
184184
Parameters
@@ -187,14 +187,14 @@ class TractogramItem(object):
187187
Points of this streamline represented as an ndarray of shape (N, 3)
188188
where N is the number of points.
189189
data_for_streamline : dict
190-
Dictionary containing some data associated to this particular
191-
streamline. Each key `k` is mapped to a ndarray of shape (Pt,), where
192-
`Pt` is the dimension of the data associated with key `k`.
190+
Dictionary containing some data associated with this particular
191+
streamline. Each key ``k`` is mapped to a ndarray of shape (Pt,), where
192+
``Pt`` is the dimension of the data associated with key ``k``.
193193
data_for_points : dict
194194
Dictionary containing some data associated to each point of this
195-
particular streamline. Each key `k` is mapped to a ndarray of
196-
shape (Nt, Mk), where `Nt` is the number of points of this streamline
197-
and `Mk` is the dimension of the data associated with key `k`.
195+
particular streamline. Each key ``k`` is mapped to a ndarray of shape
196+
(Nt, Mk), where ``Nt`` is the number of points of this streamline and
197+
``Mk`` is the dimension of the data associated with key ``k``.
198198
"""
199199
def __init__(self, streamline, data_for_streamline, data_for_points):
200200
self.streamline = np.asarray(streamline)
@@ -215,7 +215,7 @@ class Tractogram(object):
215215
choice as long as you provide the correct `affine_to_rasmm` matrix, at
216216
construction time, that brings the streamlines back to *RAS+*, *mm* space,
217217
where the coordinates (0,0,0) corresponds to the center of the voxel
218-
(opposed to a corner).
218+
(as opposed to the corner of the voxel).
219219
220220
Attributes
221221
----------
@@ -224,18 +224,18 @@ class Tractogram(object):
224224
shape ($N_t$, 3) where $N_t$ is the number of points of
225225
streamline $t$.
226226
data_per_streamline : :class:`PerArrayDict` object
227-
Dictionary where the items are (str, 2D array).
228-
Each key represents an information $i$ to be kept alongside every
229-
streamline, and its associated value is a 2D array of shape
230-
($T$, $P_i$) where $T$ is the number of streamlines and $P_i$ is
231-
the number of values to store for that particular information $i$.
227+
Dictionary where the items are (str, 2D array). Each key represents a
228+
piece of information $i$ to be kept alongside every streamline, and its
229+
associated value is a 2D array of shape ($T$, $P_i$) where $T$ is the
230+
number of streamlines and $P_i$ is the number of values to store for
231+
that particular piece of information $i$.
232232
data_per_point : :class:`PerArraySequenceDict` object
233-
Dictionary where the items are (str, :class:`ArraySequence`).
234-
Each key represents an information $i$ to be kept alongside every
235-
point of every streamline, and its associated value is an iterable
236-
of ndarrays of shape ($N_t$, $M_i$) where $N_t$ is the number of
237-
points for a particular streamline $t$ and $M_i$ is the number
238-
values to store for that particular information $i$.
233+
Dictionary where the items are (str, :class:`ArraySequence`). Each key
234+
represents a piece of information $i$ to be kept alongside every point
235+
of every streamline, and its associated value is an iterable of
236+
ndarrays of shape ($N_t$, $M_i$) where $N_t$ is the number of points
237+
for a particular streamline $t$ and $M_i$ is the number values to store
238+
for that particular piece of information $i$.
239239
"""
240240
def __init__(self, streamlines=None,
241241
data_per_streamline=None,
@@ -424,29 +424,29 @@ class LazyTractogram(Tractogram):
424424
choice as long as you provide the correct `affine_to_rasmm` matrix, at
425425
construction time, that brings the streamlines back to *RAS+*, *mm* space,
426426
where the coordinates (0,0,0) corresponds to the center of the voxel
427-
(opposed to a corner).
427+
(as opposed to the corner of the voxel).
428428
429429
Attributes
430430
----------
431431
streamlines : generator function
432432
Generator function yielding streamlines. Each streamline is an
433433
ndarray of shape ($N_t$, 3) where $N_t$ is the number of points of
434434
streamline $t$.
435-
data_per_streamline : :class:`LazyDict` object
435+
data_per_streamline : instance of :class:`LazyDict`
436436
Dictionary where the items are (str, instantiated generator).
437-
Each key represents an information $i$ to be kept alongside every
438-
streamline, and its associated value is a generator function
439-
yielding that information via ndarrays of shape ($P_i$,) where
440-
$P_i$ is the number of values to store for that particular
441-
information $i$.
437+
Each key represents a piece of information $i$ to be kept alongside
438+
every streamline, and its associated value is a generator function
439+
yielding that information via ndarrays of shape ($P_i$,) where $P_i$ is
440+
the number of values to store for that particular piece of information
441+
$i$.
442442
data_per_point : :class:`LazyDict` object
443-
Dictionary where the items are (str, instantiated generator).
444-
Each key represents an information $i$ to be kept alongside every
445-
point of every streamline, and its associated value is a generator
446-
function yielding that information via ndarrays of shape
447-
($N_t$, $M_i$) where $N_t$ is the number of points for a particular
448-
streamline $t$ and $M_i$ is the number of values to store for
449-
that particular information $i$.
443+
Dictionary where the items are (str, instantiated generator). Each key
444+
represents a piece of information $i$ to be kept alongside every point
445+
of every streamline, and its associated value is a generator function
446+
yielding that information via ndarrays of shape ($N_t$, $M_i$) where
447+
$N_t$ is the number of points for a particular streamline $t$ and $M_i$
448+
is the number of values to store for that particular piece of
449+
information $i$.
450450
451451
Notes
452452
-----
@@ -599,7 +599,6 @@ def _apply_affine():
599599
def _set_streamlines(self, value):
600600
if value is not None and not callable(value):
601601
raise TypeError("`streamlines` must be a generator function.")
602-
603602
self._streamlines = value
604603

605604
@property

0 commit comments

Comments
 (0)