This repository has been archived by the owner on May 26, 2023. It is now read-only.
forked from nipraxis/textbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh: finishing the transforms module
Adds a bunch of notebooks about coordinates, affines and nonlinear transforms to the jupyter book.
- Loading branch information
Showing
15 changed files
with
231 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
""" Rotation matrices for rotations around x, y, z axes | ||
See: https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations | ||
""" | ||
|
||
import numpy as np | ||
|
||
|
||
def x_rotmat(theta): | ||
""" Rotation matrix for rotation of `theta` radians around x axis | ||
Parameters | ||
---------- | ||
theta : scalar | ||
Rotation angle in radians | ||
Returns | ||
------- | ||
M : shape (3, 3) array | ||
Rotation matrix | ||
""" | ||
cos_t = np.cos(theta) | ||
sin_t = np.sin(theta) | ||
return np.array([[1, 0, 0], | ||
[0, cos_t, -sin_t], | ||
[0, sin_t, cos_t]]) | ||
|
||
|
||
def y_rotmat(theta): | ||
""" Rotation matrix for rotation of `theta` radians around y axis | ||
Parameters | ||
---------- | ||
theta : scalar | ||
Rotation angle in radians | ||
Returns | ||
------- | ||
M : shape (3, 3) array | ||
Rotation matrix | ||
""" | ||
cos_t = np.cos(theta) | ||
sin_t = np.sin(theta) | ||
return np.array([[cos_t, 0, sin_t], | ||
[0, 1, 0], | ||
[-sin_t, 0, cos_t]]) | ||
|
||
|
||
def z_rotmat(theta): | ||
""" Rotation matrix for rotation of `theta` radians around z axis | ||
Parameters | ||
---------- | ||
theta : scalar | ||
Rotation angle in radians | ||
Returns | ||
------- | ||
M : shape (3, 3) array | ||
Rotation matrix | ||
""" | ||
cos_t = np.cos(theta) | ||
sin_t = np.sin(theta) | ||
return np.array([[cos_t, -sin_t, 0], | ||
[sin_t, cos_t, 0], | ||
[0, 0, 1]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../data/ds107_sub012_highres.nii |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../data/ds114_sub009_highres_brain_222.nii |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../data/ds114_sub009_highres_moved.hdr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../data/ds114_sub009_highres_moved.img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.