Last active
May 17, 2017 14:48
-
-
Save mwaskom/e04cabb8d89912800f50f801d57e806e to your computer and use it in GitHub Desktop.
Create a subject-specific Wang 2015 visual field atlas annotation.
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
""""Create a subject-specific Wang 2015 visual field atlas annotation. | |
Convert the Wang atlas in subject-space (as created by Noah Benson's | |
template mapping scripts) from segmentation format to annotation format. | |
""" | |
import os | |
import sys | |
import numpy as np | |
import matplotlib.pyplot as plt | |
if __name__ == "__main__": | |
_, subj = sys.argv | |
seg_temp = "../data/{}/surf/{}.wang2015_atlas.mgz" | |
annot_temp = "../data/{}/label/{}.wang2015_atlas.annot" | |
ctab_fname = "wang2015_atlas.ctab" | |
names = ["Unknown", | |
"V1v", "V1d", "V2v", "V2d", "V3v", "V3d", | |
"hV4", "VO1", "VO2", "PHC1", "PHC2", | |
"V3A", "V3B", "LO1", "LO2", "TO1", "TO2", | |
"IPS0", "IPS1", "IPS2", "IPS3", "IPS4", "IPS5", | |
"SPL1", "hFEF"] | |
labels = np.arange(len(names)) | |
rgba = plt.cm.Spectral(np.linspace(0, 1, labels.size - 1)) | |
rgba = np.r_[[[0, 0, 0, 0]], rgba] | |
rgba = (rgba * 255).astype(np.int) | |
ctab = np.c_[labels, names, rgba] | |
np.savetxt(ctab_fname, ctab, delimiter="\t", fmt="%s") | |
for hemi in ["lh", "rh"]: | |
cmdline = ["mris_seg2annot", | |
"--ctab", ctab_fname, | |
"--seg", seg_temp.format(subj, hemi), | |
"--o", annot_temp.format(subj, hemi), | |
"--h", hemi, | |
"--s", subj] | |
os.system(" ".join(cmdline)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment