Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/images/project_structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/nipreps/dmriprep.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ Proposed dMRI pre-processing workflow
Current list of contributors to dMRIPrep
```

### References

[^veraart2019]: Image Processing: Possible Guidelines for Standardization & Clinical Applications. https://www.ismrm.org/19/program_files/MIS15.htm
6 changes: 0 additions & 6 deletions docs/nipreps/nipreps.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ They can be organized into 3 layers:

```{figure} ../images/nipreps-chart.png
:name: nipreps_chart

```

## NiPreps driving principles
Expand All @@ -96,7 +95,6 @@ This modularity in the code allows each step to be thoroughly tested. Some examp
Checks whether a function or class method behaves as expected.

![unittest](../images/unittest.png)

```

```{tabbed} doctest
Expand All @@ -105,22 +103,19 @@ Also checks whether code behaves as expected and serves as an example for how to
![doctest1](../images/doctest1.png)

![doctest2](../images/doctest2.png)

```

```{tabbed} integration test
Checks the behaviour of a system (multiple pieces of code).
Can also be used to determine whether the system is behaving suboptimally.

![integration_test](../images/integration_test.png)

```

```{tabbed} build test
Checks that code or software environment can be compiled and deployed.

![build_test](../images/build_test.png)

```

### 2. Easy to use
Expand All @@ -137,7 +132,6 @@ Thanks to limiting the input dataset to BIDS, manual parameter input is reduced

```{figure} ../images/dwi_reportlet.gif
:name: reportlet

```

*NiPreps* are also community-driven.
Expand Down
13 changes: 11 additions & 2 deletions docs/opensource/community_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
```

All *NiPreps* are open to community feedback and contributions.
Contributing to seemingly big projects can feel scary at first. This lesson will help orient you to how an example *NiPreps* project is organized and how to begin making a contribution.
Contributing to seemingly big projects can feel scary at first.
This lesson will help orient you to how an example *NiPreps* project is organized and how to begin making a contribution.

## Getting started with GitHub

Expand Down Expand Up @@ -79,9 +80,17 @@ Once you get the 👍 from the project maintainers, you are ready to begin your

## Plan ahead

It's important to start off by defining the problem.
Have a clear aim for what you want your contribution to achieve.
While you are making changes, you might discover certain ideas that hadn't come to mind before.
However, it's important to stay on target and keep your contribution easily digestible.

## Making a change

https://nipreps.org/community/CONTRIBUTING/#making-a-change
From here, continue following the [Making a change secion](https://nipreps.org/community/CONTRIBUTING/#making-a-change) of the contributing guidelines.
This section goes into more detail on how to create a local copy of a GitHub project and use version control to keep track of your changes.

You can find a brief summary below:

Make sure your git credentials are configured.

Expand Down
2 changes: 1 addition & 1 deletion docs/preparation/step0.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ If you have a working Docker installation and would like to use the workshop's D

```bash

docker run --rm -p 9999:8888 -e JUPYTER_ENABLE_LAB=yes josephmje/nipreps-book:latest
docker run --rm -p 9999:8888 -e JUPYTER_ENABLE_LAB=yes nipreps/nipreps-book:latest

```

Expand Down
35 changes: 9 additions & 26 deletions docs/tutorial/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ kernelspec:
import warnings

warnings.filterwarnings("ignore")

```

Diffusion imaging probes the random, microscopic movement of water molecules by using MRI sequences that are sensitive to the geometry and environmental organization surrounding these protons.
Expand Down Expand Up @@ -55,7 +54,6 @@ In the example code below, we've created a class with the name `DWI`.
To simplify class creation, we've also used the magic of a Python library called [`attrs`](https://www.attrs.org/en/stable/).

```{code-cell} python

"""Representing data in hard-disk and memory."""
import attr

Expand Down Expand Up @@ -86,7 +84,6 @@ class DWI:
def __len__(self):
"""Obtain the number of high-*b* orientations."""
return self.gradients.shape[-1]

```

This code implements several *attributes* as well as a *behavior* - the `__len__` *method*.
Expand All @@ -95,7 +92,6 @@ The `__len__` method is special in Python, as it will be executed when we call t
Let's test out the `DWI` data structure with some *simulated* data:

```{code-cell} python

# NumPy is a fundamental Python library for working with arrays
import numpy as np

Expand All @@ -104,7 +100,6 @@ dmri_dataset = DWI(gradients=np.random.normal(size=(4, 64)))

# call Python's built-in len() function
print(len(dmri_dataset))

```

The output of this `print()` statement is telling us that this (simulated) dataset has 64 diffusion-weighted samples.
Expand All @@ -118,14 +113,12 @@ Please note that the file has been minimized by zeroing all but two diffusion-we
Let's get some insights from it:

```{code-cell} python

# import the class from the library
from eddymotion.dmri import DWI

# load the sample file
dmri_dataset = DWI.from_filename("../../data/dwi.h5")
print(len(dmri_dataset))

```

In this case, the dataset is reporting to have 102 diffusion-weighted samples.
Expand All @@ -134,9 +127,7 @@ Python will automatically generate a summary of this object if we just type the
This pretty-printing of the object informs us about the data and metadata that, together, compose this particular DWI dataset:

```{code-cell} python

dmri_dataset

```

We'll go over some of the components of `dmri_dataset` through this lesson.
Expand All @@ -147,9 +138,7 @@ Let's start out by seeing what the data looks like.
The fully-fledged `DWI` object has a convenience function to plot the dataset:

```{code-cell} python

dmri_dataset.plot_mosaic()

dmri_dataset.plot_mosaic();
```

When calling `plot_mosaic()` without any arguments, the *b=0* reference is plotted.
Expand All @@ -167,17 +156,13 @@ Try calling `plot_mosaic` with an index of 10 or 100.
```{code-cell} python
:tags: [hide-cell]

dmri_dataset.plot_mosaic(index=10, vmax=5000)

dmri_dataset.plot_mosaic(index=10, vmax=5000);
```

or:

```{code-cell} python
:tags: [hide-cell]

dmri_dataset.plot_mosaic(index=100, vmax=5000)

dmri_dataset.plot_mosaic(index=100, vmax=5000);
```

Diffusion that exhibits directionality in the same direction as the gradient results in a loss of signal.
Expand All @@ -192,7 +177,7 @@ Stronger gradients yield diffusion maps with substantially lower SNR (signal-to-
Our `DWI` object stores the gradient information in the `gradients` attribute.

```{admonition} Exercise
Let's see the shape of the gradient information
Let's see the shape of the gradient information.
```

**Solution**
Expand All @@ -201,7 +186,6 @@ Let's see the shape of the gradient information
:tags: [hide-cell]

dmri_dataset.gradients.shape

```

We get a $4\times102$ -- three spatial coordinates ($b_x$, $b_y$, $b_z$) of the unit-norm "*b-vector*", plus the gradient sensitization magnitude (the "*b-value*"), with a total of 102 different orientations for the case at hand.
Expand All @@ -217,7 +201,6 @@ Remember to transpose (`.T`) the array.
:tags: [hide-cell]

print(dmri_dataset.gradients.T)

```

Later, we'll refer to this array as the gradient table.
Expand Down Expand Up @@ -249,7 +232,6 @@ In this case, the splitting strategy is a simple leave-one-out.
Because one "*datapoint*" in our DWI dataset corresponds to one gradient, we will refer to this partitioning of the dataset as *leave-one-gradient-out (LOGO)*:

```{code-cell} python

def logo_split(self, index, with_b0=False):
"""
Produce one fold of LOGO (leave-one-gradient-out).
Expand Down Expand Up @@ -297,18 +279,15 @@ def logo_split(self, index, with_b0=False):
(train_data, train_gradients),
(dwframe, bframe),
)

```

This function is contained in the `DWI` class shown earlier and will allow us to easily partition the dataset as follows:

```{code-cell} python

from eddymotion.viz import plot_dwi

data_train, data_test = dmri_dataset.logo_split(10)
plot_dwi(data_test[0], dmri_dataset.affine, gradient=data_test[1])

plot_dwi(data_test[0], dmri_dataset.affine, gradient=data_test[1]);
```

`data_train` is a tuple containing all diffusion-weighted volumes and the corresponding gradient table, excluding the left-out, which is stored in `data_test` (the 11<sup>th</sup> gradient indexed by `10`, in this example).
Expand All @@ -318,6 +297,8 @@ plot_dwi(data_test[0], dmri_dataset.affine, gradient=data_test[1])
Try printing the shapes of elements in the `data_train` tuple.
```

**Solution**

```{code-cell} python
:tags: [hide-cell]

Expand All @@ -329,6 +310,8 @@ print(f"data_train[1] is a gradient table and has {data_train[1].shape} dimensio
Likewise for the left-out gradient, try printing the shapes of elements in the `data_test` tuple.
```

**Solution**

```{code-cell} python
:tags: [hide-cell]

Expand Down
6 changes: 3 additions & 3 deletions docs/tutorial/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ While we can address the misalignment, it is really problematic to overcome the
## Objective: Implement a head-motion estimation code

This tutorial focuses on the misalignment problem.
We will build from existing software (Dipy for diffusion modeling and ANTs for image registration), as well as commonplace Python libraries (NumPy), a software framework for head-motion estimation in diffusion MRI data.
We will build from existing software (DIPY for diffusion modeling and ANTs for image registration), as well as commonplace Python libraries (NumPy), a software framework for head-motion estimation in diffusion MRI data.

The algorithmic and theoretical foundations of the method are based on an idea first proposed by [Ben-Amitay et al.](https://pubmed.ncbi.nlm.nih.gov/22183784/) and later implemented in *QSIPREP* (see this [OHBM 2019 poster](https://github.com/mattcieslak/ohbm_shoreline/blob/master/cieslakOHBM2019.pdf)).
The idea works as follows:
Expand Down Expand Up @@ -68,8 +68,8 @@ pointed at by the variable `data`, and assuming we have a list of rigid-body tra
a potential API would have a `.fit()` and `.predict()` members which run the algorithm (the former) and generate an EM-corrected
DWI (the latter):

```Python
from emc import EddyMotionEstimator
```python
from eddymotion import EddyMotionEstimator

estimator = EddyMotionEstimator()
estimator.fit(data, model="DTI")
Expand Down
Loading