-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH,EXA add function to upsample from fsaverageX to fsaverage (#519)
* ENH,EXA add function to upsample from fsaverageX to fsaverage * EXA add more comments
- Loading branch information
Showing
3 changed files
with
129 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Examples with fsaverage | ||
------------------------------ | ||
|
||
Examples showing how to use PyCortex to visualize data on fsaverage. |
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,36 @@ | ||
""" | ||
=================== | ||
Upsample data from a lower resolution fsaverage template to fsaverage for visualization | ||
=================== | ||
This example shows how data in a lower resolution fsaverage template | ||
(e.g., fsaverage5 or fsaverage6) can be upsampled to the high resolution fsaverage | ||
template for visualization. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
import cortex | ||
|
||
subject = "fsaverage" | ||
|
||
# First we check if the fsaverage template is already in the pycortex filestore. If not, | ||
# we download the template from the web and add it to the filestore. | ||
if subject not in cortex.db.subjects: | ||
cortex.download_subject(subject) | ||
|
||
# Next we create some data on fsaverage5. Each hemisphere has 10242 vertices. | ||
n_vertices_fsaverage5 = 10242 | ||
data_fs5 = np.arange(1, n_vertices_fsaverage5 + 1) | ||
# We concatenate the data to itself to create a vector of length 20484, corresponding to | ||
# the two hemispheres together. | ||
data_fs5 = np.concatenate((data_fs5, data_fs5)) | ||
# Finally, we upsample the data to fsaverage. | ||
data_fs7 = cortex.freesurfer.upsample_to_fsaverage(data_fs5, "fsaverage5") | ||
|
||
# Now that the data is in the fsaverage template, we can visualize it in PyCortex as any | ||
# other vertex dataset. | ||
vtx = cortex.Vertex(data_fs7, subject, vmin=0, vmax=n_vertices_fsaverage5, cmap="turbo") | ||
cortex.quickshow(vtx, with_curvature=False, with_colorbar=False) | ||
plt.show() |