-
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.
- Loading branch information
Cedric (Huchuan) Xia
committed
Mar 8, 2018
1 parent
73fafe7
commit 37cff51
Showing
15 changed files
with
5,099 additions
and
0 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,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
200 changes: 200 additions & 0 deletions
200
.ipynb_checkpoints/forOne_PlotGenesOnBrain-checkpoint.ipynb
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,200 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%gui qt4" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import os.path as op\n", | ||
"import numpy as np\n", | ||
"from numpy import arange\n", | ||
"from numpy.random import permutation\n", | ||
"import nibabel as nib\n", | ||
"from surfer import Brain\n", | ||
"import pickle\n", | ||
"import pandas as pd" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Set up the working directory\n", | ||
"# All paths after this are relative path to the root of chead\n", | ||
"\n", | ||
"wk_dir = '/Users/hxia/Desktop/BBL/' # this is where I have mounted chead to on my laptop. \n", | ||
"# Change the above to an empty string if working directly on chead \n", | ||
"\n", | ||
"# Set up the project directory\n", | ||
"project_path = os.path.join(wk_dir,'data/joy/BBL/projects/prsConnectivity')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"donor = 15496\n", | ||
"numParcel = 100\n", | ||
"numNetwork = 7\n", | ||
"mm = 1\n", | ||
"parcel_annot_file = os.path.join(wk_dir,'data/joy/BBL/studies/pnc/template/Schaefer/FreeSurfer5.3/fsaverage/label',\\\n", | ||
" 'lh.Schaefer2018_%sParcels_%sNetworks_order.annot' % (numParcel,numNetwork))\n", | ||
"gene_coord_file = os.path.join(project_path,'ABI','gene_mapping','%sdonor_%sParcels_%sNetwork_%smm.pkl'\\\n", | ||
" % (donor, numParcel, numNetwork, mm))\n", | ||
"gene_coord = pickle.load( open( gene_coord_file, \"rb\" ) )\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"array(['Cont', 'Default', 'DorsAttn', 'Limbic', 'NotAssigned',\n", | ||
" 'SalVentAttn', 'SomMot', 'Vis'], dtype='|S11')" | ||
] | ||
}, | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"community_list = np.unique(gene_coord[4].values())\n", | ||
"community_color_list = ['orange','red','green','lightgreen','black',\\\n", | ||
" 'violet','blue','purple']\n", | ||
"\n", | ||
"#community_color_list = ['orange','red','green','lightgreen',\\\n", | ||
"# 'violet','blue','purple','orchid','salmon','black'\\\n", | ||
"# 'teal','gold','darkblue','crimson','beige','plum','silver']\n", | ||
"community_list" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"brain = Brain('fsaverage', \"lh\", \"inflated\",background='white',alpha=1)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 15, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"brain = Brain('fsaverage','lh', \"inflated\",views=['lat','med'], background='white',alpha=1)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 268, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"brain = Brain('fsaverage', \"lh\", \"sphere\", background='white',alpha=1)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 16, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for idx, community in enumerate(community_list):\n", | ||
" if community != 'NotAssigned':\n", | ||
" filtered_dict = {k:v for k,v in gene_coord[4].iteritems() if community in v}\n", | ||
" brain.add_foci(pd.DataFrame.as_matrix(gene_coord[0].loc[filtered_dict.keys()]),hemi='lh',map_surface='pial',\\\n", | ||
" color=community_color_list[idx],scale_factor=0.5)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 269, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"brain = Brain('fsaverage', \"lh\", \"sphere\",background='white')\n", | ||
"for idx, community in enumerate(community_list):\n", | ||
" if community != 'NotAssigned':\n", | ||
" filtered_dict = {k:v for k,v in gene_coord[4].iteritems() if community in v}\n", | ||
" brain.add_foci(pd.DataFrame.as_matrix(gene_coord[0].loc[filtered_dict.keys()]),map_surface='sphere',\\\n", | ||
" color=community_color_list[idx],scale_factor=0.5)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 294, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"brain.add_annotation(parcel_annot_file, borders=False,alpha=0.5)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"brain.add_annotation(parcel_annot_file, borders=False,alpha=0.5, hemi='lh')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"brain = Brain" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "myenv2", | ||
"language": "python", | ||
"name": "myenv2" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.14" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.