<jupyter_start><jupyter_text>Notebook to interact with and visualise cortical and laminar thickness<jupyter_code>import numpy as np
import nibabel as nb
import matplotlib_surface_plotting as msp
import matplotlib.pyplot as plt
import os
%matplotlib inline
#load surface data
data_dir='../data'
surf=nb.load(os.path.join(data_dir,'gray_left_327680.surf.gii'))
vertices, faces = surf.darrays[0].data,surf.darrays[1].data
#load thickness data. layers 1-6 & total cortical thickness
thickness = np.load(os.path.join(data_dir,'thicknesses_left.npy'))
total_thickness = thickness[-1]
#load parcellation
parcellation=np.loadtxt(os.path.join(data_dir,'HCP_left.txt'),dtype=int)
labels = np.loadtxt(os.path.join(data_dir,'HCP_labels.txt'),dtype=str)

print(thickness.shape)
print(vertices.shape)
print(parcellation.shape)
plt.hist(total_thickness);
plt.xlabel('cortical thickness (mm)')
#plot cortical thickness
msp.plot_surf(vertices,faces,total_thickness,vmin=1,vmax=4,
              cmap='turbo',cmap_label='Cortical\nthickness\n(mm)')


#find V1
v1_label = parcellation ==np.where(labels=='V1')[0][0]
#Plot V1 on to the surface
msp.plot_surf(vertices,faces,v1_label,vmin=0,vmax=1,cmap='viridis',colorbar=False)<jupyter_output><empty_output><jupyter_text>Workshop Task 1Sort the HCP ROIs according to their thickness<jupyter_code>#calculate mean thickness per ROI
#sort the labels by their values<jupyter_output><empty_output><jupyter_text>Workshop Task 2In which ROI is layer IV thickest?<jupyter_code>#<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12107329842931937, 'fraction_numerical': 0.015706806282722512, 'mean_word_length': 8.210843373493976, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '69671', 'license': 'MIT', 'n_tokens_mistral': 593, 'n_tokens_neox': 563, 'n_words': 105, 'path': 'notebooks/1_cortical_thickness.ipynb', 'repo_name': 'kwagstyl/cortical_layers_tutorial', 'size': '1528'}