@@ -33,14 +33,19 @@ def linear_iterator(size: int | None = None, **kwargs) -> Iterator[int]:
33
33
34
34
Parameters
35
35
----------
36
- size : :obj:`int`
37
- Number of volumes in the dataset
38
- (for instance, the number of orientations in a DWI)
39
-
40
- Returns
41
- -------
42
- :obj:`~typing.Iterator`
43
- The sorted index order.
36
+ size : :obj:`int` or ``None``, optional
37
+ Number of volumes in the dataset.
38
+ If ``None``, ``size`` will be inferred from the ``bvalues``
39
+ keyword argument.
40
+ bvalues : :obj:`list`, optional (keyword argument)
41
+ List of b-values corresponding to all orientations of a DWI dataset.
42
+ If ``size`` is provided, this argument will be ignored.
43
+ Otherwise, ``size`` will be inferred from the length of ``bvalues``.
44
+
45
+ Yields
46
+ ------
47
+ :obj:`int`
48
+ The next index.
44
49
45
50
Examples
46
51
--------
@@ -53,28 +58,38 @@ def linear_iterator(size: int | None = None, **kwargs) -> Iterator[int]:
53
58
if size is None :
54
59
raise TypeError ("Cannot build iterator without size" )
55
60
56
- return iter ( range (size ))
61
+ return ( s for s in range (size ))
57
62
58
63
59
64
def random_iterator (size : int | None = None , ** kwargs ) -> Iterator [int ]:
60
65
"""
61
66
Traverse the dataset volumes randomly.
62
67
68
+ If the ``seed`` key is present in the keyword arguments, initializes the seed
69
+ of Python's ``random`` pseudo-random number generator library with the given
70
+ value. Specifically, if ``False``, ``None`` is used as the seed; if ``True``, a
71
+ default seed value is used.
72
+
63
73
Parameters
64
74
----------
65
- size : :obj:`int`
66
- Number of volumes in the dataset
67
- (for instance, the number of orientations in a DWI)
68
- seed : :obj:`int` or :obj:`bool` or :obj:`bool` or ``None``
75
+ size : :obj:`int` or ``None``, optional
76
+ Number of volumes in the dataset.
77
+ If ``None``, ``size`` will be inferred from the ``bvalues``
78
+ keyword argument.
79
+ bvalues : :obj:`list`, optional (keyword argument)
80
+ List of b-values corresponding to all orientations of a DWI dataset.
81
+ If ``size`` is provided, this argument will be ignored.
82
+ Otherwise, ``size`` will be inferred from the length of ``bvalues``.
83
+ seed : :obj:`int`, :obj:`bool`, :obj:`str`, or ``None``, optional (keyword argument)
69
84
If :obj:`int` or :obj:`str` or ``None``, initializes the seed of Python's random generator
70
85
with the given value.
71
86
If ``False``, the random generator is passed ``None``.
72
87
If ``True``, a default seed value is set.
73
88
74
- Returns
75
- -------
76
- :obj:`~typing.Iterator `
77
- The sorted index order .
89
+ Yields
90
+ ------
91
+ :obj:`int `
92
+ The next index.
78
93
79
94
Examples
80
95
--------
@@ -105,19 +120,21 @@ def random_iterator(size: int | None = None, **kwargs) -> Iterator[int]:
105
120
return (x for x in index_order )
106
121
107
122
108
- def bvalue_iterator (size : int | None = None , ** kwargs ) -> Iterator [int ]:
123
+ def bvalue_iterator (* _ , ** kwargs ) -> Iterator [int ]:
109
124
"""
110
125
Traverse the volumes in a DWI dataset by growing b-value.
111
126
112
127
Parameters
113
128
----------
114
129
bvalues : :obj:`list`
115
130
List of b-values corresponding to all orientations of the dataset.
131
+ Please note that ``bvalues`` is a keyword argument and MUST be provided
132
+ to generate the volume sequence.
116
133
117
- Returns
118
- -------
119
- :obj:`~typing.Iterator `
120
- The sorted index order .
134
+ Yields
135
+ ------
136
+ :obj:`int `
137
+ The next index.
121
138
122
139
Examples
123
140
--------
@@ -138,14 +155,19 @@ def centralsym_iterator(size: int | None = None, **kwargs) -> Iterator[int]:
138
155
139
156
Parameters
140
157
----------
141
- size : :obj:`int`
142
- Number of volumes in the dataset
143
- (for instance, the number of orientations in a DWI)
144
-
145
- Returns
146
- -------
147
- :obj:`~typing.Iterator`
148
- The sorted index order.
158
+ size : :obj:`int` or ``None``, optional
159
+ Number of volumes in the dataset.
160
+ If ``None``, ``size`` will be inferred from the ``bvalues``
161
+ keyword argument.
162
+ bvalues : :obj:`list`, optional (keyword argument)
163
+ List of b-values corresponding to all orientations of the dataset.
164
+ If ``size`` is provided, this argument will be ignored.
165
+ Otherwise, ``size`` will be inferred from the length of ``bvalues``.
166
+
167
+ Yields
168
+ ------
169
+ :obj:`~int`
170
+ The next index.
149
171
150
172
Examples
151
173
--------
0 commit comments