subj = 'SEEG76'
subj_dir = 'd:\\\\CloudEpi\\Subjects\\\\'
from IPython.display import display, Markdown, Latex, Image, HTML
# %autosave 0
%matplotlib inline
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
''')
from pyepi.tools import inout, plots
from time import time
import pandas as pd
from surfer import Brain
import os
import datetime
tstart = time()
def Images(images, header=None, width="100%"): # to match Image syntax
if type(width)==type(1): width = "{}px".format(width)
html = ["<table style='width:{}; border: 0px solid black;'><tr>".format(width)]
if header is not None:
html += ["<th align='center'>{}</th>".format(h) for h in header] + ["</tr><tr>"]
for image in images:
html.append("<td><img src='{}' /></td>".format(image))
html.append("</tr></table>")
display(HTML(''.join(html)))
display(Markdown('##' + subj ))
3D rendering of the brain's pial surface with SEEG electrodes.
from mayavi import mlab
mlab.init_notebook('png',600,600, local=False)
coords = pd.read_excel(os.path.join(subj_dir, subj, 'Contact_coordinates.xlsx'))
brain = plots.implantation_scheme(subj, subj_dir, fig_size=(500, 500), brain_alpha=0.3,electrode_label_size=3)
view_orientations=plots.get_views(coords)
list_of_labels =['COR',
'SAG',
'AX' ]
# list_of_views = [os.path.join(subj_dir, subj, 'reports', 'implantation_scheme_' + label+ '.png')
# for label in list_of_labels]
list_of_views = ['implantation_scheme_' + label+ '.png'
for label in list_of_labels]
for v in range(0,len(view_orientations)):
brain.show_view(view_orientations[v])
img = brain.save_image(filename=list_of_views[v])
# img = brain.save_montage(os.path.join(subj_dir, subj, 'reports', 'implantation_scheme.png'),
# order = view_orientations, border_size=0)
# Image(os.path.join(subj_dir, subj, 'reports', 'implantation_scheme.png'))
# Images(list_of_views, header=list_of_labels, width="100%")
Images(list_of_views, header=None, width="100%")
try:
brain, circle, spes = plots.spes_responses_by_contacts(subj, subj_dir, fig_size=(500, 500),
flow='outbound', max_linewidth=10,
hide_buttons=True)
except:
print("""
The connectome can not be generated at this time.
Possible causes include missing SPES.xls file, contact name mismatch,
incorrect split of intracranial and scalp data, etc.
Check the raw data try again.""")
try:
brain2, circle2, spes2 = plots.spes_responses_by_contacts(subj, subj_dir, fig_size=(500, 500),
flow='inbound', max_linewidth=10,
hide_buttons=True)
except:
print("""
The connectome can not be generated at this time.
Possible causes include missing SPES.xls file, contact name mismatch,
incorrect split of intracranial and scalp data, etc.
Check the raw data try again.""")
current_date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print('Last update: ' + current_date + '. Took ' + str(time()-tstart) + ' seconds')