From b3abb6cbf6ae7d58b1325bf813905c4871a875b9 Mon Sep 17 00:00:00 2001 From: NiPreps Bot Date: Mon, 8 Apr 2024 20:23:04 +0000 Subject: [PATCH] docs(main): Update docs of development line --- main/.buildinfo | 2 +- main/_modules/eddymotion/data/dmri.html | 11 +- main/_modules/eddymotion/data/pet.html | 11 +- main/_modules/eddymotion/data/splitting.html | 11 +- main/_modules/eddymotion/data/utils.html | 11 +- main/_modules/eddymotion/estimator.html | 11 +- main/_modules/eddymotion/model/base.html | 11 +- main/_modules/eddymotion/utils.html | 443 +++++++++++++++++++ main/_modules/eddymotion/viz.html | 11 +- main/_modules/index.html | 12 +- main/_sources/api/eddymotion.utils.rst.txt | 7 + main/_sources/developers.rst.txt | 1 + main/_static/documentation_options.js | 2 +- main/api/eddymotion.data.dmri.html | 11 +- main/api/eddymotion.data.html | 11 +- main/api/eddymotion.data.pet.html | 11 +- main/api/eddymotion.data.splitting.html | 11 +- main/api/eddymotion.data.utils.html | 11 +- main/api/eddymotion.estimator.html | 11 +- main/api/eddymotion.model.base.html | 17 +- main/api/eddymotion.model.html | 11 +- main/api/eddymotion.utils.html | 410 +++++++++++++++++ main/api/eddymotion.viz.html | 17 +- main/changes.html | 11 +- main/developers.html | 18 +- main/genindex.html | 44 +- main/index.html | 12 +- main/installation.html | 11 +- main/links.html | 11 +- main/objects.inv | Bin 1047 -> 1104 bytes main/py-modindex.html | 17 +- main/search.html | 11 +- main/searchindex.js | 2 +- 33 files changed, 1065 insertions(+), 137 deletions(-) create mode 100644 main/_modules/eddymotion/utils.html create mode 100644 main/_sources/api/eddymotion.utils.rst.txt create mode 100644 main/api/eddymotion.utils.html diff --git a/main/.buildinfo b/main/.buildinfo index c73db5de..de2b4410 100644 --- a/main/.buildinfo +++ b/main/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: b2cea85f3596e30dbcd5b1f0a4c099db +config: 44f68a0e2ab09edafa0073714e68cfe3 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/main/_modules/eddymotion/data/dmri.html b/main/_modules/eddymotion/data/dmri.html index ed58c9a0..bf7017ac 100644 --- a/main/_modules/eddymotion/data/dmri.html +++ b/main/_modules/eddymotion/data/dmri.html @@ -5,7 +5,7 @@ - eddymotion.data.dmri - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.data.dmri - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -123,7 +123,7 @@
-
eddymotion 24.0.0.dev218+gecd7ce8 documentation
+
eddymotion 24.0.0.dev219+g6128b37 documentation
@@ -145,14 +145,14 @@ diff --git a/main/_modules/eddymotion/data/pet.html b/main/_modules/eddymotion/data/pet.html index 6e2e1a04..429aab24 100644 --- a/main/_modules/eddymotion/data/pet.html +++ b/main/_modules/eddymotion/data/pet.html @@ -5,7 +5,7 @@ - eddymotion.data.pet - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.data.pet - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -123,7 +123,7 @@
@@ -145,14 +145,14 @@ diff --git a/main/_modules/eddymotion/data/splitting.html b/main/_modules/eddymotion/data/splitting.html index d1cc2325..9365d554 100644 --- a/main/_modules/eddymotion/data/splitting.html +++ b/main/_modules/eddymotion/data/splitting.html @@ -5,7 +5,7 @@ - eddymotion.data.splitting - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.data.splitting - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -123,7 +123,7 @@
@@ -145,14 +145,14 @@ diff --git a/main/_modules/eddymotion/data/utils.html b/main/_modules/eddymotion/data/utils.html index cf6841f5..c16e7691 100644 --- a/main/_modules/eddymotion/data/utils.html +++ b/main/_modules/eddymotion/data/utils.html @@ -5,7 +5,7 @@ - eddymotion.data.utils - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.data.utils - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -123,7 +123,7 @@
@@ -145,14 +145,14 @@ diff --git a/main/_modules/eddymotion/estimator.html b/main/_modules/eddymotion/estimator.html index 7722d9de..d4dec776 100644 --- a/main/_modules/eddymotion/estimator.html +++ b/main/_modules/eddymotion/estimator.html @@ -5,7 +5,7 @@ - eddymotion.estimator - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.estimator - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -123,7 +123,7 @@
@@ -145,14 +145,14 @@ diff --git a/main/_modules/eddymotion/model/base.html b/main/_modules/eddymotion/model/base.html index a8c606d0..912a21e5 100644 --- a/main/_modules/eddymotion/model/base.html +++ b/main/_modules/eddymotion/model/base.html @@ -5,7 +5,7 @@ - eddymotion.model.base - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.model.base - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -123,7 +123,7 @@
@@ -145,14 +145,14 @@ diff --git a/main/_modules/eddymotion/utils.html b/main/_modules/eddymotion/utils.html new file mode 100644 index 00000000..b59b24d2 --- /dev/null +++ b/main/_modules/eddymotion/utils.html @@ -0,0 +1,443 @@ + + + + + + + + eddymotion.utils - eddymotion 24.0.0.dev219+g6128b37 documentation + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+
+ +
+ +
+
+

Source code for eddymotion.utils

+# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
+# vi: set ft=python sts=4 ts=4 sw=4 et:
+#
+# Copyright 2024 The NiPreps Developers <nipreps@gmail.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# We support and encourage derived works from this project, please read
+# about our expectations at
+#
+#     https://www.nipreps.org/community/licensing/
+#
+"""Iterators to traverse the volumes in a 4D image."""
+
+import random
+from itertools import chain, zip_longest
+from typing import Iterator
+
+
+
+[docs] +def linear_iterator(size: int = None, **kwargs) -> Iterator[int]: + """ + Traverse the dataset volumes in ascending order. + + Parameters + ---------- + size : :obj:`int` + Number of volumes in the dataset + (for instance, the number of orientations in a DWI) + + Returns + ------- + :obj:`~typing.Iterator` + The sorted index order. + + Examples + -------- + >>> list(linear_iterator(10)) + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + + """ + if size is None and "bvals" in kwargs: + size = len(kwargs["bvals"]) + if size is None: + raise TypeError("Cannot build iterator without size") + + return range(size)
+ + + +
+[docs] +def random_iterator(size: int = None, **kwargs) -> Iterator[int]: + """ + Traverse the dataset volumes randomly. + + Parameters + ---------- + size : :obj:`int` + Number of volumes in the dataset + (for instance, the number of orientations in a DWI) + seed : :obj:`int` or :obj:`bool` or :obj:`bool` or ``None`` + If :obj:`int` or :obj:`str` or ``None``, initializes the seed of Python's random generator + with the given value. + If ``False``, the random generator is passed ``None``. + If ``True``, a default seed value is set. + + Returns + ------- + :obj:`~typing.Iterator` + The sorted index order. + + Examples + -------- + >>> list(random_iterator(15, seed=0)) # seed is 0 + [1, 10, 9, 5, 11, 2, 3, 7, 8, 4, 0, 14, 12, 6, 13] + >>> # seed is True -> the default value 20210324 is set + >>> list(random_iterator(15, seed=True)) + [1, 12, 14, 5, 0, 11, 10, 9, 7, 8, 3, 13, 2, 6, 4] + >>> list(random_iterator(15, seed=20210324)) + [1, 12, 14, 5, 0, 11, 10, 9, 7, 8, 3, 13, 2, 6, 4] + >>> list(random_iterator(15, seed=42)) # seed is 42 + [8, 13, 7, 6, 14, 12, 5, 2, 9, 3, 4, 11, 0, 1, 10] + + """ + + if size is None and "bvals" in kwargs: + size = len(kwargs["bvals"]) + if size is None: + raise TypeError("Cannot build iterator without size") + + _seed = kwargs.get("seed", None) + _seed = 20210324 if _seed is True else _seed + + random.seed(None if _seed is False else _seed) + + index_order = list(range(size)) + random.shuffle(index_order) + return (x for x in index_order)
+ + + +
+[docs] +def bvalue_iterator(size: int = None, **kwargs) -> Iterator[int]: + """ + Traverse the volumes in a DWI dataset by growing b-value. + + Parameters + ---------- + bvalues : :obj:`list` + List of b-values corresponding to all orientations of the dataset. + + Returns + ------- + :obj:`~typing.Iterator` + The sorted index order. + + Examples + -------- + >>> list(bvalue_iterator(bvals=[0.0, 0.0, 1000.0, 1000.0, 700.0, 700.0, 2000.0, 2000.0, 0.0])) + [0, 1, 8, 4, 5, 2, 3, 6, 7] + + """ + bvals = kwargs.get("bvals", None) + if bvals is None: + raise TypeError("Keyword argument bvals is required") + indexed_bvals = sorted([(round(b, 2), i) for i, b in enumerate(bvals)]) + return (index[1] for index in indexed_bvals)
+ + + +
+[docs] +def centralsym_iterator(size: int = None, **kwargs) -> Iterator[int]: + """ + Traverse the dataset starting from the center and alternatingly progressing to the sides. + + Parameters + ---------- + size : :obj:`int` + Number of volumes in the dataset + (for instance, the number of orientations in a DWI) + + Returns + ------- + :obj:`~typing.Iterator` + The sorted index order. + + Examples + -------- + >>> list(centralsym_iterator(10)) + [5, 4, 6, 3, 7, 2, 8, 1, 9, 0] + >>> list(centralsym_iterator(11)) + [5, 4, 6, 3, 7, 2, 8, 1, 9, 0, 10] + + """ + if size is None and "bvals" in kwargs: + size = len(kwargs["bvals"]) + if size is None: + raise TypeError("Cannot build iterator without size") + linear = list(range(size)) + return ( + x + for x in chain.from_iterable( + zip_longest( + linear[size // 2 :], + reversed(linear[: size // 2]), + ) + ) + if x is not None + )
+ +
+
+
+
+ + +
+
+ + Made with Sphinx and @pradyunsg's + + Furo + +
+
+ +
+
+ +
+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/main/_modules/eddymotion/viz.html b/main/_modules/eddymotion/viz.html index e8180364..0922bf82 100644 --- a/main/_modules/eddymotion/viz.html +++ b/main/_modules/eddymotion/viz.html @@ -5,7 +5,7 @@ - eddymotion.viz - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.viz - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -123,7 +123,7 @@
@@ -145,14 +145,14 @@ diff --git a/main/_modules/index.html b/main/_modules/index.html index 8f5e0be5..cb523b97 100644 --- a/main/_modules/index.html +++ b/main/_modules/index.html @@ -5,7 +5,7 @@ - Overview: module code - eddymotion 24.0.0.dev218+gecd7ce8 documentation + Overview: module code - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -123,7 +123,7 @@
@@ -145,14 +145,14 @@ +
diff --git a/main/_sources/api/eddymotion.utils.rst.txt b/main/_sources/api/eddymotion.utils.rst.txt new file mode 100644 index 00000000..558e90ec --- /dev/null +++ b/main/_sources/api/eddymotion.utils.rst.txt @@ -0,0 +1,7 @@ +eddymotion.utils module +======================= + +.. automodule:: eddymotion.utils + :members: + :undoc-members: + :show-inheritance: diff --git a/main/_sources/developers.rst.txt b/main/_sources/developers.rst.txt index 0d44320b..8cd62d50 100644 --- a/main/_sources/developers.rst.txt +++ b/main/_sources/developers.rst.txt @@ -32,4 +32,5 @@ Information on specific functions, classes, and methods. api/eddymotion.data.dmri api/eddymotion.estimator api/eddymotion.model + api/eddymotion.utils api/eddymotion.viz diff --git a/main/_static/documentation_options.js b/main/_static/documentation_options.js index ca25d89f..7cfb8afd 100644 --- a/main/_static/documentation_options.js +++ b/main/_static/documentation_options.js @@ -1,5 +1,5 @@ const DOCUMENTATION_OPTIONS = { - VERSION: '24.0.0.dev218+gecd7ce8', + VERSION: '24.0.0.dev219+g6128b37', LANGUAGE: 'en', COLLAPSE_INDEX: false, BUILDER: 'html', diff --git a/main/api/eddymotion.data.dmri.html b/main/api/eddymotion.data.dmri.html index b8bccc5b..a3d51150 100644 --- a/main/api/eddymotion.data.dmri.html +++ b/main/api/eddymotion.data.dmri.html @@ -6,7 +6,7 @@ - eddymotion.data.dmri module - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.data.dmri module - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -124,7 +124,7 @@
@@ -146,14 +146,14 @@ +
diff --git a/main/api/eddymotion.data.html b/main/api/eddymotion.data.html index 7f8097ec..df04d234 100644 --- a/main/api/eddymotion.data.html +++ b/main/api/eddymotion.data.html @@ -6,7 +6,7 @@ - eddymotion.data package - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.data package - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -124,7 +124,7 @@
@@ -146,14 +146,14 @@
@@ -146,14 +146,14 @@ +
diff --git a/main/api/eddymotion.data.splitting.html b/main/api/eddymotion.data.splitting.html index 7a47099a..922ce6c9 100644 --- a/main/api/eddymotion.data.splitting.html +++ b/main/api/eddymotion.data.splitting.html @@ -6,7 +6,7 @@ - eddymotion.data.splitting module - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.data.splitting module - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -124,7 +124,7 @@
@@ -146,14 +146,14 @@ +
diff --git a/main/api/eddymotion.data.utils.html b/main/api/eddymotion.data.utils.html index 545e36a9..45cf0673 100644 --- a/main/api/eddymotion.data.utils.html +++ b/main/api/eddymotion.data.utils.html @@ -6,7 +6,7 @@ - eddymotion.data.utils module - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.data.utils module - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -124,7 +124,7 @@
@@ -146,14 +146,14 @@ +
diff --git a/main/api/eddymotion.estimator.html b/main/api/eddymotion.estimator.html index 071cf182..b747cf11 100644 --- a/main/api/eddymotion.estimator.html +++ b/main/api/eddymotion.estimator.html @@ -6,7 +6,7 @@ - eddymotion.estimator module - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.estimator module - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -124,7 +124,7 @@
@@ -146,14 +146,14 @@ +
diff --git a/main/api/eddymotion.model.base.html b/main/api/eddymotion.model.base.html index 2909ffc9..00e93136 100644 --- a/main/api/eddymotion.model.base.html +++ b/main/api/eddymotion.model.base.html @@ -3,10 +3,10 @@ - + - eddymotion.model.base module - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.model.base module - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -124,7 +124,7 @@
@@ -146,14 +146,14 @@ diff --git a/main/api/eddymotion.model.html b/main/api/eddymotion.model.html index 5bc355f2..5b8e2d70 100644 --- a/main/api/eddymotion.model.html +++ b/main/api/eddymotion.model.html @@ -6,7 +6,7 @@ - eddymotion.model package - eddymotion 24.0.0.dev218+gecd7ce8 documentation + eddymotion.model package - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -124,7 +124,7 @@
@@ -146,14 +146,14 @@
@@ -146,14 +146,14 @@ -
+
diff --git a/main/changes.html b/main/changes.html index 578bfb4f..792cc3f3 100644 --- a/main/changes.html +++ b/main/changes.html @@ -6,7 +6,7 @@ - What’s new? - eddymotion 24.0.0.dev218+gecd7ce8 documentation + What’s new? - eddymotion 24.0.0.dev219+g6128b37 documentation @@ -124,7 +124,7 @@
@@ -146,14 +146,14 @@
@@ -146,14 +146,14 @@
@@ -144,14 +144,14 @@