Skip to content

Commit

Permalink
fix svg
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmje committed Apr 22, 2021
1 parent f5afc0f commit 2307c7f
Show file tree
Hide file tree
Showing 6 changed files with 7,204 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ sphinx:
# Execution settings
execute:
timeout: 3000
exclude_patterns:
- 0*ipynb
execute_notebooks: auto

# HTML-specific settings
Expand Down
1,773 changes: 1,773 additions & 0 deletions docs/assets/images/registration_15_0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,798 changes: 1,798 additions & 0 deletions docs/assets/images/registration_19_0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,809 changes: 1,809 additions & 0 deletions docs/assets/images/registration_21_0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,788 changes: 1,788 additions & 0 deletions docs/assets/images/registration_7_0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 34 additions & 1 deletion docs/tutorial/registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ kernelspec:
:tags: [remove-cell]
import warnings
from IPython.display import HTML
import requests
from tempfile import mkstemp
from pathlib import Path
Expand Down Expand Up @@ -175,6 +176,8 @@ We can now visualize our reference (the prediction) and the actual DW map.
Please notice the subtle *nodding* of the head, perhaps more apparent when looking at the corpus callosum in the sagittal views:

```{code-cell} python
:tags: [remove-output]
from niworkflows.viz.notebook import display
display(
Expand All @@ -185,6 +188,12 @@ display(
);
```

```{code-cell} python
:tags: [remove-input]
HTML("""<object alt="../images/registration_7_0.svg" type="image/svg+xml" data="../images/registration_7_0.svg"></object>""")
```

Let's configure ANTs via NiPype:

```{code-cell} python
Expand Down Expand Up @@ -221,6 +230,8 @@ If everything worked out, we can now retrieve the aligned file with the output `
We can now visualize how close (or far) the two images are:

```{code-cell} python
:tags: [remove-output]
display(
fixed_path,
result.outputs.warped_image,
Expand All @@ -229,6 +240,12 @@ display(
);
```

```{code-cell} python
:tags: [remove-input]
HTML("""<object alt="../images/registration_15_0.svg" type="image/svg+xml" data="../images/registration_15_0.svg"></object>""")
```

## Resampling an image

Once we have estimated what is the *transform* that brings two images into alignment, we can *bring* the data in the *moving* image and *move this image* into the *reference*'s grid through *resampling*.
Expand All @@ -253,10 +270,13 @@ matrix
Resampling an image requires two pieces of information: the *reference* image (which provides the new grid where we want to have the data) and the *moving* image which contains the actual data we are interested in:

```{code-cell} python
:tags: [remove-output]
xfm = nt.linear.Affine(matrix)
xfm.reference = fixed_path
resampled = xfm.apply(moving_path)
resampled.to_filename(tempdir / "resampled-nitransforms.nii.gz")
display(
fixed_path,
tempdir / "resampled-nitransforms.nii.gz",
Expand All @@ -265,14 +285,21 @@ display(
);
```

```{code-cell} python
:tags: [remove-input]
HTML("""<object alt="../images/registration_19_0.svg" type="image/svg+xml" data="../images/registration_19_0.svg"></object>""")
```


**Exercise**

Use the `display()` function to visualize the image aligned as generated by ANTs vs. that generated by *NiTransforms* -- they should be aligned!.

**Solution**

```{code-cell} python
:tags: [hide-cell]
:tags: [hide-cell, remove-output]
display(
result.outputs.warped_image,
Expand All @@ -281,3 +308,9 @@ display(
moving_label="Aligned (nitransforms)",
);
```

```{code-cell} python
:tags: [hide-cell, remove-input]
HTML("""<object alt="../images/registration_21_0.svg" type="image/svg+xml" data="../images/registration_21_0.svg"></object>""")
```

0 comments on commit 2307c7f

Please sign in to comment.