Skip to content

Commit 62e5e43

Browse files
authored
Merge pull request #343 from jhlegarreta/doc/improve-dmri-data-doc
DOC: Improve the dMRI module documentation
2 parents be22ecc + e5e393e commit 62e5e43

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

src/nifreeze/data/dmri/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
3030
**Gradient Table Representation**.
3131
The :class:`~nifreeze.data.dmri.base.DWI` class represents diffusion MRI data must
32-
be provided a gradient table, which is a :class:`numpy.ndarray` of shape (N, 4), where N
33-
is the number of diffusion-weighted volumes.
32+
be provided a gradient table, which is a :class:`numpy.ndarray` of shape ``(N, 4)``, where
33+
``N`` is the number of diffusion-weighted volumes.
3434
The first three columns represent the gradient directions (b-vectors), and the fourth column
3535
represents the b-values in s/mm².
3636
*NiFreeze* expects that the gradient directions are normalized to unit length for non-zero
37-
b-values, and that the b=0 volumes have a gradient direction of (0, 0, 0).
37+
b-values, and that the :math:`b=0` volumes have a gradient direction of :math:`(0, 0, 0)`.
3838
When non-unit b-vectors are detected, the corresponding b-value is automatically adjusted to
3939
reflect the actual diffusion weighting.
4040
If the input gradient table does not conform to these expectations, it will be automatically
@@ -47,14 +47,15 @@
4747
The :class:`~nifreeze.data.dmri.base.DWI` class requires a ``dataobj`` that can be an array-like
4848
object.
4949
The final step of the initialization process examines the data object and the gradient table,
50-
and removes b=0 volumes from the data **AND** the gradient table.
50+
and removes :math:`b=0` volumes from the data **AND** the gradient table.
5151
If no ``bzero`` parameter is provided, a reference low-b volume is computed as the median of all
52-
the low-b volumes (b < 50 s/mm²) and inserted in the ``DWI.bzero`` attribute.
52+
the low-b volumes (``b <`` :data:`~nifreeze.data.dmri.utils.DEFAULT_LOWB_THRESHOLD` s/mm²) and
53+
inserted in the :attr:`~nifreeze.data.dmri.base.DWI.bzero` attribute.
5354
Therefore, ***NiFreeze* WILL NOT be able to reconstruct the original data organization**.
5455
This design choice simplifies the internal representation and processing of diffusion MRI data.
55-
If you want to calculate a b=0 reference map in a more sophisticated way (e.g., after realignment
56-
of all the low-b volumes), you should handle this separately and feed your own reference through
57-
the ``bzero`` parameter.
56+
If you want to calculate a :math:`b=0` reference map in a more sophisticated way (e.g., after
57+
realignment of all the low-b volumes), you should handle this separately and feed your own
58+
reference through the ``bzero`` parameter.
5859
5960
"""
6061

src/nifreeze/data/dmri/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def validate_gradients(
6161
6262
Parameters
6363
----------
64-
inst : :obj:`~nifreeze.data.dmri.DWI`
64+
inst : :obj:`~nifreeze.data.dmri.base.DWI`
6565
The instance being validated (unused; present for validator signature).
6666
attr : :obj:`~attrs.Attribute`
6767
The attribute being validated; attr.name is used in the error message.
@@ -190,7 +190,7 @@ def from_filename(cls, filename: Path | str) -> Self:
190190
191191
Returns
192192
-------
193-
:obj:`~nifreeze.data.dmri.DWI`
193+
:obj:`~nifreeze.data.dmri.base.DWI`
194194
The constructed dataset with data loaded from the file.
195195
196196
"""

src/nifreeze/data/dmri/io.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def from_nii(
6666
stored in the returned dataset.
6767
gradients_file : :obj:`os.pathlike`, optional
6868
A text file containing the gradients table, shape (N, C) where the last column
69-
stores the b-values. If provided following the column-major convention(C, N),
69+
stores the b-values. If provided following the column-major convention (C, N),
7070
it will be transposed automatically. If provided, it supersedes any .bvec / .bval
7171
combination.
7272
bvec_file : :obj:`os.pathlike`, optional
@@ -79,7 +79,7 @@ def from_nii(
7979
8080
Returns
8181
-------
82-
dwi : :obj:`~nifreeze.data.dmri.DWI`
82+
dwi : :obj:`~nifreeze.data.dmri.base.DWI`
8383
A DWI object containing the loaded data, gradient table, and optional
8484
b-zero volume, and brainmask.
8585
@@ -147,6 +147,9 @@ def to_nifti(
147147
148148
Parameters
149149
----------
150+
dwi : :obj:`~nifreeze.data.dmri.base.DWI`
151+
A DWI object containing the diffusion data to be written, including the
152+
gradient table, and optional b-zero volume.
150153
filename : :obj:`os.pathlike`, optional
151154
The output NIfTI file path.
152155
write_hmxfms : :obj:`bool`, optional
@@ -163,6 +166,10 @@ def to_nifti(
163166
bvecs_dec_places : :obj:`int`, optional
164167
Decimal places to use when serializing b-vectors.
165168
169+
Returns
170+
-------
171+
nii : :obj:`~nibabel.Nifti1Image`
172+
The main DWI data object.
166173
"""
167174

168175
no_bzero = dwi.bzero is None or not insert_b0

src/nifreeze/model/dmri.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self, dataset: DWI, max_b: float | int | None = None, **kwargs):
6969
7070
Parameters
7171
----------
72-
dataset : :obj:`~nifreeze.data.dmri.DWI`
72+
dataset : :obj:`~nifreeze.data.dmri.base.DWI`
7373
Reference to a DWI object.
7474
7575
"""
@@ -249,7 +249,7 @@ def __init__(
249249
250250
Parameters
251251
----------
252-
dataset : :obj:`~nifreeze.data.dmri.DWI`
252+
dataset : :obj:`~nifreeze.data.dmri.base.DWI`
253253
Reference to a DWI object.
254254
stat : :obj:`str`, optional
255255
Whether the summary statistic to apply is ``"mean"`` or ``"median"``.

0 commit comments

Comments
 (0)