├── .ipynb_checkpoints └── stream4d-checkpoint.py ├── README.md ├── animate_frames.py ├── aseg_to_obj.py ├── keyframe_tractography.py ├── render.py ├── resources ├── FreeSurferColorLUT.txt ├── STREAM-4D_banner.jpg ├── STREAM-4D_premotor.gif ├── aseg_labels.json ├── fs_default.txt └── fs_label_luts.json ├── scene_template.py ├── source_estimation_animation.py ├── stream4d.py └── template.blend /.ipynb_checkpoints/stream4d-checkpoint.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | import os 4 | import subprocess 5 | import time 6 | import random 7 | 8 | from matplotlib import pyplot as plt 9 | import matplotlib 10 | matplotlib.use('Agg') 11 | 12 | import mne 13 | import mne_connectivity 14 | import nibabel as nib 15 | import numpy as np 16 | from scipy.ndimage import gaussian_filter 17 | from scipy.sparse import csr_matrix 18 | from scipy.spatial import KDTree 19 | from scipy.stats import norm 20 | 21 | # Utility 22 | def min_max_norm(a, min=None): 23 | """ 24 | Normalizes an array to [0, 1] using min-max normalization. 25 | 26 | Parameters: 27 | a (ndarray): Array to normalize. 28 | min (float, optional): Minimum value to use instead of np.min(a). 29 | 30 | Returns: 31 | ndarray: Normalized array. 32 | """ 33 | if min is not None: 34 | return(a - min)/(np.max(a) - min) 35 | else: 36 | return(a - np.min(a))/(np.max(a) - np.min(a)) 37 | 38 | def get_sparse_connectivity(faces, num_vertices): 39 | """ 40 | Constructs a sparse vertex adjacency matrix based on triangular mesh faces. 41 | 42 | Parameters: 43 | faces (ndarray): M x 3 array of triangle vertex indices. 44 | num_vertices (int): Total number of vertices. 45 | 46 | Returns: 47 | csr_matrix: Sparse connectivity matrix (num_vertices x num_vertices). 48 | """ 49 | row, col = [], [] 50 | for face in faces: 51 | # Ensure the face has at least 2 vertices (skip otherwise) 52 | if len(face) < 2: 53 | continue 54 | 55 | # For each vertex in the face, connect it to the other vertices 56 | for i, v in enumerate(face): 57 | if v < num_vertices: # Ensure the vertex index is within bounds 58 | linked_neighbors = [neighbor for neighbor in face if neighbor != v and neighbor < num_vertices] 59 | for neighbor in linked_neighbors: 60 | row.append(v) 61 | col.append(neighbor) 62 | 63 | # Set all entries to 1 (indicating a connection) 64 | data = np.ones(len(row)) 65 | connectivity = csr_matrix((data, (row, col)), shape=(num_vertices, num_vertices)) 66 | return connectivity 67 | 68 | # Geometry 69 | def get_streamline_endpoints(streamlines): 70 | streamline_endpoints = np.zeros((len(streamlines),2,3)) 71 | for i, streamline in enumerate(streamlines): 72 | streamline_endpoints[i] = [streamline[0], streamline[-1]] 73 | return streamline_endpoints 74 | 75 | def srf_to_wavefront(freesurfer_dir, subject, wavefront_output_dir): 76 | """ 77 | Converts FreeSurfer surface geometry to OBJ format for Blender visualization. 78 | 79 | Parameters: 80 | freesurfer_dir (str): Path to FreeSurfer recon-all directory. 81 | subject (str): Subject identifier. 82 | wavefront_output_dir (str): Directory to save .obj output. 83 | 84 | Returns: 85 | dict: Contains 'vertices', 'sphere_vertices', 'faces', 'n_vertices', and 'vertex_offset'. 86 | """ 87 | os.makedirs(wavefront_output_dir, exist_ok=True) 88 | output_dict = {} 89 | 90 | for tissue in ['white', 'pial']: 91 | all_sphere_vertices = [] 92 | all_vertices = [] 93 | all_faces = [] 94 | vertex_offset = 0 95 | 96 | for hemi in ['lh', 'rh']: 97 | input_surface = os.path.join(freesurfer_dir, subject, 'surf', f'{hemi}.{tissue}') 98 | adj = {'lh':-60, 'rh':60} 99 | 100 | # Read surface geometry and CRAS metadata 101 | vertices, faces, metadata = nib.freesurfer.read_geometry(input_surface, read_metadata=True) 102 | cras_offset = metadata.get('cras', np.zeros(3)) 103 | vertices += cras_offset 104 | 105 | sphere_vertices, _ = nib.freesurfer.read_geometry(os.path.join(freesurfer_dir, subject, 'surf', f'{hemi}.sphere')) 106 | sphere_vertices[:,0] += adj[hemi] 107 | all_sphere_vertices.append(sphere_vertices) 108 | 109 | # Adjust face indices by current offset 110 | faces += vertex_offset 111 | all_vertices.append(vertices) 112 | all_faces.append(faces) 113 | 114 | if hemi=='lh': 115 | vertex_offset += vertices.shape[0] 116 | 117 | # Combine both hemispheres 118 | all_vertices = np.vstack(all_vertices) 119 | all_faces = np.vstack(all_faces) 120 | all_sphere_vertices = np.vstack(all_sphere_vertices) 121 | 122 | # Write to .obj file 123 | output_obj = os.path.join(wavefront_output_dir, f'{tissue}.obj') 124 | with open(output_obj, 'w') as obj: 125 | for v in all_vertices: 126 | obj.write(f'v {v[0]} {v[1]} {v[2]}\n') 127 | for f in all_faces: 128 | obj.write(f'f {f[0]+1} {f[1]+1} {f[2]+1}\n') 129 | 130 | # Return geometry dictionary for further use 131 | if tissue == 'pial': 132 | output_dict = {'vertices':all_vertices, 133 | 'sphere_vertices':all_sphere_vertices, 134 | 'faces':all_faces, 135 | 'n_vertices':len(all_vertices), 136 | 'vertex_offset':vertex_offset} 137 | 138 | return(output_dict) 139 | 140 | def create_connectome_parcels(freesurfer_dir, subject, output_dir): 141 | """ 142 | Converts a subject's FreeSurfer aparc+aseg.mgz parcellation to a .mif file using MRtrix's labelconvert. 143 | 144 | Parameters: 145 | freesurfer_dir (str): Path to the FreeSurfer recon-all directory. 146 | subject (str): Freesurfer sbject identifier. 147 | output_dir (str): Directory to save the converted .mif file. 148 | 149 | Returns: 150 | str: Path to the generated .mif parcellation file. 151 | """ 152 | os.system( 153 | f'labelconvert {freesurfer_dir}/{subject}/mri/aparc+aseg.mgz ' 154 | f'{os.path.dirname(os.path.realpath(__file__))}/resources/FreeSurferColorLUT.txt {os.path.dirname(os.path.realpath(__file__))}/resources/fs_default.txt ' 155 | f'{output_dir}/{subject}.mif -force' 156 | ) 157 | return f'{output_dir}/{subject}.mif' 158 | 159 | # Streamline Management 160 | def get_streamline_subset(tractography_file, output_dir, n=15000, force=False): 161 | """ 162 | Loads a random subset of streamlines for visualization or analysis. 163 | 164 | Parameters: 165 | tractography_file (str): Path to .tck streamline file. 166 | output_dir (str): Directory to save or load subset from. 167 | n (int): Number of streamlines to sample. 168 | force (bool): Whether to overwrite existing subset. 169 | 170 | Returns: 171 | list of ndarray: Subset of streamlines. 172 | """ 173 | # If no subsample has been saved or if force generation is applied, load in full tractography output and generate sample 174 | if not os.path.exists(os.path.join(output_dir, 'streamline_subset.txt')) or force: 175 | raw_streamlines = nib.streamlines.load(tractography_file) 176 | streamlines = list(raw_streamlines.streamlines) 177 | streamline_subset = random.sample(streamlines, n) 178 | 179 | output_struct = [streamline.tolist() for streamline in streamline_subset] 180 | with open(os.path.join(output_dir, 'streamline_subset.txt'), 'w') as file: 181 | json.dump(output_struct, file) 182 | 183 | del raw_streamlines 184 | 185 | else: 186 | # Read in preexisting streamline subset 187 | with open(os.path.join(output_dir, 'streamline_subset.txt'), 'r') as file: 188 | streamline_subset_raw = json.load(file) 189 | streamline_subset = [np.array(streamline) for streamline in streamline_subset_raw] 190 | 191 | return(streamline_subset) 192 | 193 | def associate_vertices_to_streamlines(vertices, streamline_endpoints, distance_threshold): 194 | """ 195 | Associates surface vertices with streamlines whose endpoints are within a given distance threshold. 196 | 197 | Parameters: 198 | vertices (ndarray): N x 3 array of vertex coordinates. 199 | streamline_endpoints (ndarray): M x 2 x 3 array of streamline start and end points. 200 | distance_threshold (float): Distance threshold for associating streamlines to vertices. 201 | 202 | Returns: 203 | list of lists: A list where each entry contains indices of vertices associated with that streamline. 204 | """ 205 | n_streamlines = streamline_endpoints.shape[0] 206 | # Reshape endpoint coordinates to: (2 * N_streamlines, 3) 207 | endpoint_coords = streamline_endpoints.reshape(-1, 3) 208 | # Query all endpoint coordinates at once 209 | tree = KDTree(vertices) 210 | all_neighbors = tree.query_ball_point(endpoint_coords, distance_threshold) 211 | # Parse and combine results from each streamline's start and endpoint 212 | vertex_to_streamlines = [ 213 | list(set(all_neighbors[2*i] + all_neighbors[2*i + 1])) # Remove duplicates 214 | for i in range(n_streamlines) 215 | ] 216 | 217 | return vertex_to_streamlines 218 | 219 | # Source Estimation Processing 220 | def interpolate_surface_values_timeseries(vertices, stc_indices, stc_values_timeseries): 221 | """ 222 | Interpolates missing scalar values at vertices over time using nearest neighbor interpolation. 223 | 224 | Parameters: 225 | vertices (ndarray): N x 3 array of surface vertex coordinates. 226 | stc_indices (ndarray): Indices of vertices with known values. 227 | stc_values_timeseries (ndarray): Known values of shape (len(stc_indices), timepoints). 228 | 229 | Returns: 230 | ndarray: Interpolated values for all vertices, shape (N, timepoints). 231 | """ 232 | n_timepoints = stc_values_timeseries.shape[1] 233 | full_scalar_values = np.zeros((vertices.shape[0], n_timepoints)) 234 | 235 | # Set known scalar values for all timepoints 236 | full_scalar_values[stc_indices, :] = stc_values_timeseries 237 | 238 | missing_indices = np.where(full_scalar_values[:, 0] == 0)[0] # assumes missing values are 0 in all timepoints 239 | 240 | # Use KDTree to find the nearest known vertex for each missing vertex 241 | tree = KDTree(vertices[stc_indices]) 242 | _, nearest_known_indices = tree.query(vertices[missing_indices]) 243 | 244 | # Assign the scalar values of the nearest known vertex to each missing vertex for each timepoint 245 | full_scalar_values[missing_indices, :] = full_scalar_values[stc_indices][nearest_known_indices, :] 246 | 247 | return full_scalar_values 248 | 249 | def smooth_values_sparse_timeseries(connectivity, scalar_values_timeseries, num_passes=10): 250 | """ 251 | Smooths scalar values on a surface over time using neighbor averaging via a sparse connectivity matrix. 252 | 253 | Parameters: 254 | connectivity (csr_matrix): Sparse vertex adjacency matrix. 255 | scalar_values_timeseries (ndarray): Scalar values at each vertex and timepoint (N x T). 256 | num_passes (int): Number of laplacian smoothing passes to apply. 257 | 258 | Returns: 259 | ndarray: Smoothed scalar values (N x T). 260 | """ 261 | smoothed_values = scalar_values_timeseries.copy() 262 | for _ in range(num_passes): 263 | neighbor_sums = connectivity.dot(smoothed_values) 264 | 265 | non_zero_neighbors = connectivity.dot((smoothed_values != 0).astype(float)) 266 | 267 | # Avoid division by zero by only averaging where there are non-zero neighbors 268 | mask = non_zero_neighbors > 0 269 | smoothed_values[mask] = neighbor_sums[mask] / non_zero_neighbors[mask] 270 | 271 | return smoothed_values 272 | 273 | def threshold_stc(source_estimate_path, surface_geometry, output_dir, stim_onset, time_range, label=''): 274 | """ 275 | Thresholds source estimates using baseline z-score correction, interpolates missing values, 276 | applies temporal and spatial smoothing, and returns the final smoothed timeseries. 277 | 278 | Parameters: 279 | source_estimate_path (str): Path to .stc file. 280 | surface_geometry (dict): Output from `srf_to_wavefront`, includes vertices, faces, etc. 281 | output_dir (str): Output directory. 282 | stim_onset (int): Index of stimulus onset timepoint. 283 | time_range (ndarray): Time indices relative to stim_onset to include in final estimate. 284 | 285 | Returns: 286 | ndarray: Smoothed surface scalar values (n_timepoints x n_vertices). 287 | """ 288 | source_estimate = mne.read_source_estimate(source_estimate_path) 289 | stc_data = source_estimate.data 290 | 291 | lh_vertno = source_estimate.lh_vertno 292 | rh_vertno = source_estimate.rh_vertno + surface_geometry['vertex_offset'] 293 | vertno = np.hstack([lh_vertno, rh_vertno]) 294 | 295 | baseline_data = stc_data[:,:(stim_onset-10)] 296 | baseline_means = np.mean(baseline_data, axis=1) 297 | baseline_data_adj = baseline_data - baseline_means[:, np.newaxis] 298 | baseline_stds = np.std(baseline_data_adj, axis=1) 299 | 300 | stc_data_adj = stc_data - baseline_means[:, np.newaxis] 301 | 302 | p_value = 0.05/len(baseline_means) 303 | z_score = norm.ppf(1 - p_value / 2) * 2 304 | thresholds = z_score * baseline_stds 305 | 306 | stc_data_thresh = np.where(stc_data_adj > (baseline_means[:, np.newaxis] + thresholds[:, np.newaxis]), stc_data_adj, 0) 307 | 308 | time_index_range = stim_onset + time_range 309 | n_frames = len(time_range) 310 | 311 | hemisphere_scalars = np.zeros((n_frames, surface_geometry['n_vertices'])) 312 | interpolated_estimate = interpolate_surface_values_timeseries(surface_geometry['sphere_vertices'], vertno, stc_data_thresh[:, time_index_range]) 313 | temporally_smoothed_estimate = gaussian_filter(interpolated_estimate, sigma=[0, 2]) 314 | smoothed_estimate = smooth_values_sparse_timeseries(surface_geometry['connectivity'], temporally_smoothed_estimate) 315 | 316 | np.save(os.path.join(output_dir, 'source_estimates', 'smoothed', f'{label}smoothed.npy'), smoothed_estimate) 317 | return(smoothed_estimate) 318 | 319 | # Streamline Activation 320 | def link_streamline_activation(scalars, vertex_associations, streamlines, output_dir, vis_thresh=True, label='', save=True): 321 | """ 322 | Propagates scalar activation values from surface vertices to associated streamlines. 323 | 324 | Parameters: 325 | scalars (ndarray): Vertex activation values (N_vertices x timepoints). 326 | vertex_associations (list of lists): Streamline indices associated with each vertex. 327 | streamlines (list of ndarray): List of streamlines. 328 | output_dir (str): Output directory to save results. 329 | label (str): Optional prefix label for saved output. 330 | 331 | Returns: 332 | ndarray: Streamline activation timeseries (N_streamlines x timepoints). 333 | """ 334 | # min-max normalize source estimation values from 0-1 335 | soft_max = np.percentile(scalars, 99.95) 336 | if vis_thresh: 337 | thresh = np.percentile(scalars[scalars > 0], 90) 338 | else: 339 | thresh = np.min(scalars[scalars > 0]) 340 | 341 | normalized_scalars = (scalars - thresh) / (soft_max - thresh) 342 | normalized_scalars = np.where(normalized_scalars > 0, normalized_scalars, 0) 343 | 344 | n_streamlines, n_timepoints = len(streamlines), scalars.shape[1] 345 | active_streamlines = np.zeros((n_streamlines, n_timepoints)) 346 | 347 | # Iterate through each streamline and assign the maximum activation value from associated vertices 348 | for str_idx, vtx_indices in enumerate(vertex_associations): 349 | if not vtx_indices: 350 | continue 351 | streamline_activation = np.max(normalized_scalars[vtx_indices, :], axis=0) 352 | # streamline_activation = np.mean(normalized_scalars[vtx_indices, :], axis=0) 353 | active_streamlines[str_idx] = streamline_activation 354 | 355 | if save: 356 | # Save activation timeseries for Blender shading 357 | np.save(os.path.join(output_dir, 'source_estimates', 'normalized', f'{label}normalized.npy'), normalized_scalars) 358 | np.save(os.path.join(output_dir, 'tractography', f'{label}streamline_activation_timeseries.npy'), active_streamlines) 359 | 360 | return(active_streamlines) 361 | 362 | # Connectome Analysis 363 | def weighted_connectome_analysis(scalars, vertex_associations, streamlines, sift_weight_path, parcels_path, output_dir, label=''): 364 | """ 365 | Creates a weighted structural connectome based on streamline activation and anatomical weights. 366 | 367 | Parameters: 368 | scalars (ndarray): Vertex-level scalar activations over time (n_vertices x n_timepoints). 369 | vertex_associations (list of lists): Mapping from each vertex to associated streamline indices. 370 | streamlines (list): List of streamlines (each streamline is an array of 3D points). 371 | sift_weight_path (str): Path to text file with SIFT streamline weights. 372 | parcels_path (str): Path to parcellation file (e.g., an atlas) for connectome construction. 373 | label (str): Optional prefix for output filenames. 374 | 375 | Returns: 376 | None 377 | """ 378 | 379 | # Load SIFT weights if provided, otherwise default to equal weighting 380 | if sift_weight_path: 381 | with open(sift_weight_path, 'r') as weight_file: 382 | anatomical_weights = np.array(weight_file.readlines()[-1].split(' ')).astype(np.float64) 383 | else: 384 | anatomical_weights = np.ones(len(streamlines)) 385 | 386 | # Compute streamline-level activation over time from surface scalars 387 | streamline_activations = link_streamline_activation( 388 | scalars, vertex_associations, streamlines, 389 | output_dir=os.path.join(output_dir, 'connectome'), 390 | save=False, vis_thresh=None, label=label 391 | ) 392 | 393 | # Integrate activation across time for each streamline 394 | streamline_activations_integrated = np.sum(streamline_activations, axis=1) 395 | 396 | # Multiply by anatomical weights and apply nonlinear scaling 397 | streamline_activations_integrated_anat_weighted = streamline_activations_integrated**1.5 * anatomical_weights 398 | del streamline_activations # Free memory 399 | 400 | # Select only streamlines with non-zero activation for analysis 401 | streamline_mask = [sl for (sl, val) in zip(streamlines, streamline_activations_integrated) if val] 402 | 403 | # Normalize and scale weights for tck2connectome input 404 | streamline_scalars_mask = min_max_norm( 405 | streamline_activations_integrated_anat_weighted[streamline_activations_integrated_anat_weighted > 0] 406 | ) * 10 407 | 408 | weights_output_path = os.path.join(output_dir, 'connectome', f'{label}activation_integration_weights.txt') 409 | np.savetxt(weights_output_path, 410 | streamline_scalars_mask, delimiter=' ', newline=' ') 411 | 412 | # Save filtered active streamlines to .tck 413 | tractogram = nib.streamlines.Tractogram(streamline_mask, affine_to_rasmm=np.eye(4)) 414 | active_streamline_path = os.path.join(output_dir, 'connectome', f'{label}active_streamlines.tck') 415 | nib.streamlines.save(tractogram, active_streamline_path) 416 | 417 | # Generate connectome matrix using MRtrix tck2connectome 418 | parcel_output = os.path.join(output_dir, 'connectome', f'{label}parcels.csv') 419 | parcel_assignments_output = os.path.join(output_dir, 'connectome', f'{label}assignments_parcels.csv') 420 | 421 | env = os.environ.copy() 422 | env['MRTRIX_NOGUI'] = '1' 423 | subprocess.run([ 424 | 'tck2connectome', '-symmetric', '-zero_diagonal', 425 | active_streamline_path, parcels_path, parcel_output, 426 | '-scale_invnodevol', 427 | '-tck_weights_in', weights_output_path, 428 | '-out_assignments', parcel_assignments_output, 429 | '-force' 430 | ], env=env) 431 | 432 | # Load parcellation label LUT for node names and colors 433 | with open(f"{os.path.dirname(os.path.realpath(__file__))}/resources/fs_label_luts.json", "r") as f: 434 | fs_label_luts = json.load(f) 435 | labels = list(fs_label_luts.keys()) 436 | node_colors = list(fs_label_luts.values()) 437 | 438 | # Load the resulting connectome matrix 439 | connectome = np.loadtxt(f'{output_dir}/connectome/{label}parcels.csv', delimiter=',') 440 | 441 | # Determine which nodes are highly connected for styling 442 | max_conn_per_node = np.max(connectome, axis=1) 443 | label_colors = [ 444 | '#555555' if max_conn < np.percentile(connectome, 99.5) else 'white' 445 | for max_conn in max_conn_per_node 446 | ] 447 | 448 | # Normalize connectome matrix for visualization 449 | connectome_scaled = connectome * (1 / np.percentile(connectome, 99.95)) 450 | np.savetxt(os.path.join(output_dir, 'connectome', f'{label}connectome.txt'), connectome_scaled) 451 | 452 | # Compute circular layout and plot connectome 453 | node_angles = mne.viz.circular_layout(labels, labels) 454 | fig, ax = mne_connectivity.viz.plot_connectivity_circle( 455 | connectome_scaled, labels, colormap='magma', 456 | vmin=0, vmax=1, node_angles=node_angles, 457 | linewidth=3, node_colors=node_colors, 458 | colorbar=False, fontsize_names=10 459 | ) 460 | 461 | # Recolor labels based on threshold 462 | for text, color in zip(ax.texts, label_colors): 463 | text.set_color(color) 464 | 465 | # Save final connectome visualization 466 | fig.savefig(f'{output_dir}/connectome/{label}connectome.svg', dpi=300, transparent=False) 467 | plt.close(fig) 468 | 469 | def average_cortical_thickness(freesurfer_dir, subject): 470 | """ 471 | Returns the average cortical thickness of a FreeSurfer subject. 472 | 473 | Parameters: 474 | freesurfer_dir (str): Path to the FreeSurfer subjects directory. 475 | subject (str): Subject ID. 476 | 477 | Returns: 478 | float: Average cortical thickness across both hemispheres. 479 | """ 480 | surf_dir = os.path.join(freesurfer_dir, subject, 'surf') 481 | lh_thickness = nib.freesurfer.io.read_morph_data(os.path.join(surf_dir, 'lh.thickness')) 482 | rh_thickness = nib.freesurfer.io.read_morph_data(os.path.join(surf_dir, 'rh.thickness')) 483 | # Concatenate and compute the mean thickness 484 | all_thickness = np.concatenate([lh_thickness, rh_thickness]) 485 | return(np.mean(all_thickness)) 486 | 487 | # Pipeline Control 488 | def run_stream4d(freesurfer_dir, subject, tractography_path, source_estimate_path, output_dir, connectome=True, sift_weight_path="", label="", dist_threshold=None): 489 | """ 490 | Runs STREAM-4D integration pipeline: loads surface and tractography data, thresholds source estimates, 491 | links activation to streamlines, and saves outputs for visualization and connectomics. 492 | 493 | Parameters: 494 | freesurfer_dir (str): Path to FreeSurfer recon-all directory. 495 | subject (str): Subject identifier. 496 | tractography_path (str): Path to .tck tractography file. 497 | source_estimate_path (str): Path to .stc source estimate. 498 | output_dir (str): Directory to store pipeline outputs. 499 | label (str): Optional label prefix for output files. 500 | 501 | Returns: 502 | None 503 | """ 504 | start_time = time.time() 505 | print('------------------------------') 506 | print(' STREAM-4D ') 507 | print('------------------------------') 508 | 509 | print('[]: setting up directories') 510 | for subdir in ['wavefront', 'tractography', 'connectome', 'source_estimates/raw', 'source_estimates/smoothed', 'source_estimates/normalized', 'render']: 511 | os.makedirs(os.path.join(output_dir, subdir), exist_ok=True) 512 | 513 | tract_link_path = os.path.join(output_dir, "tractography", os.path.basename(tractography_path)) 514 | stc_link_path = os.path.join(output_dir, "source_estimates", "raw", os.path.basename(source_estimate_path)) 515 | os.system(f'ln -s {tractography_path} {tract_link_path}') 516 | os.system(f'ln -s {source_estimate_path} {stc_link_path}') 517 | 518 | 519 | if label: 520 | label = label + '_' 521 | 522 | print('\nLoading FreeSurfer Surface Geometry\n') 523 | surface_geometry = srf_to_wavefront(freesurfer_dir, subject, os.path.join(output_dir, 'wavefront')) 524 | surface_geometry['connectivity'] = get_sparse_connectivity(surface_geometry['faces'], surface_geometry['n_vertices']) 525 | 526 | print('Sampling Tractography Data\n') 527 | streamlines = get_streamline_subset(tractography_path, os.path.join(output_dir, 'tractography')) 528 | 529 | print('Extracting Sample Endpoints\n') 530 | streamline_endpoints = get_streamline_endpoints(streamlines) 531 | 532 | print('Thresholding Source Estimate\n') 533 | scalars = threshold_stc(source_estimate_path=source_estimate_path, surface_geometry=surface_geometry, output_dir=output_dir, stim_onset=500, time_range=np.arange(-50, 200), label=label) 534 | 535 | print('Associating Streamlines to Vertices\n') 536 | if not dist_threshold: 537 | dist_threshold = average_cortical_thickness(freesurfer_dir, subject) 538 | print(f'Computing associations with distance threshold: {dist_threshold}mm\n') 539 | 540 | vertex_associations = associate_vertices_to_streamlines(surface_geometry['vertices'], streamline_endpoints, dist_threshold) 541 | 542 | print('Linking Activation Timeseries\n') 543 | link_streamline_activation(scalars, vertex_associations, streamlines, output_dir, label=label) 544 | print(f'Associations Complete! Renderable output saved to {output_dir}') 545 | 546 | if connectome: 547 | print('Running Connectome Analysis\n') 548 | print('Loading Tractography Data') 549 | conn_streamlines = list(nib.streamlines.load(tractography_path).streamlines) 550 | print('Extracting Streamline Endpoints\n') 551 | conn_streamline_endpoints = get_streamline_endpoints(conn_streamlines) 552 | conn_vertex_associations = associate_vertices_to_streamlines(surface_geometry['vertices'], conn_streamline_endpoints, dist_threshold) 553 | print('Creating Connectome Parcellation\n') 554 | parcels = create_connectome_parcels(freesurfer_dir, subject, f'{output_dir}/connectome') 555 | print('Creating Structural Connectome with figures\n') 556 | weighted_connectome_analysis(scalars, conn_vertex_associations, conn_streamlines, sift_weight_path, parcels, output_dir, label) 557 | 558 | elapsed_time = time.time() - start_time 559 | print(f'\nSTREAM-4D completed in {elapsed_time / 60:.2f} minutes ({elapsed_time:.2f} seconds).') 560 | 561 | def main(): 562 | parser = argparse.ArgumentParser(description="Assign streamline activation intensity from source estimate") 563 | parser.add_argument("-t", "--tractography_path", type=str, help=".tck tractography file containing streamline data") 564 | parser.add_argument("-e", "--source_estimate_path", type=str, help=".stc source estimation path (MNE output, compatibility to improve with future releases)") 565 | parser.add_argument("-w", "--sift_weight_path", type=str, default="", help=".txt tcksift output to weight structural connectome") 566 | parser.add_argument("-f", "--freesurfer_dir", type=str, help="Path to the directory containing FreeSurfer's 'recon-all' output.") 567 | parser.add_argument("-s", "--subject", type=str, help="FreeSurfer Reconall subject") 568 | parser.add_argument("-o", "--output_dir", type=str, help="Output directory path") 569 | parser.add_argument("-l", "--label", type=str, default="", help="Optional label to prefix output files") 570 | parser.add_argument("-d", "--distance_threshold", type=float, default=None, help="Distance threshold for associating streamlines to vertices (in mm)") 571 | parser.add_argument("--no-connectome", dest="connectome", action="store_false", help="Option to not run connectome analysis (performed by default)") 572 | args = parser.parse_args() 573 | 574 | run_stream4d(args.freesurfer_dir, args.subject, args.tractography_path, args.source_estimate_path, args.output_dir, args.connectome, args.sift_weight_path, args.label, args.distance_threshold) 575 | 576 | if __name__ == "__main__": 577 | main() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # STREAM-4D 2 | ### Surface to Tractography time-Resolved EEG Activation Mapping in 4 Dimensions 3 | 4 | ![alt text](https://github.com/ComaRecoveryLab/STREAM-4D/blob/main/resources/STREAM-4D_premotor.gif "STREAM-4D Left Premotor Stimulation") 5 | 6 | Verson 1.0.0 7 | 8 | To enhance mechanistic understanding of effective connectivity in the human brain, we created a tool that links high-temporal resolution transcranial magnetic stimulation electroencephalography (TMS-EEG) with high-spatial resolution diffusion MRI. This tool, Surface to Tractography Real-time EEG Activation Mapping in 4 Dimensions (STREAM-4D), integrates electrophysiologic source estimation models from TMS-evoked potentials (TEPs) with structural connectivity models from diffusion MRI tractography. Our proof-of-principle application of this pipeline is described in ["Visualizing Effective Connectivity in the Human Brain"](https://doi.org/10.1101/2025.03.06.641642). 9 | 10 | The current pipeline is built for use with .src source estimation files (the output of [MNE Python](https://mne.tools/stable/index.html) source localization), .tck tractograms (the output of [MRTrix](https://www.mrtrix.org) tckgen), and [Freesurfer](https://surfer.nmr.mgh.harvard.edu) surface outputs. 11 | 12 | The pipeline consists of two commands: First generating the associations between streamlines and surface activation, and then loading, keyframing, and rendering using [Blender](https://www.blender.org). For the render.py script to be executed successfully, Blender must be accessible from the command line in the environment. 13 | 14 | ``` 15 | python stream4d.py [-t TRACTOGRAPHY_PATH] [-e SOURCE_ESTIMATE_PATH] [-w SIFT_WEIGHT_PATH] [-f FREESURFER_DIR] [-s SUBJECT] [-l LABEL] [-o OUTPUT_DIR] [--no-connectome] 16 | 17 | python render.py [-s SUBJECT] [-l LABEL] [-o OUTPUT_DIR] 18 | ``` 19 | 20 | ## Repo Contributors 21 | 22 | - Alexander Atalay ([asatalay@stanford.edu](mailto:asatalay@mstanford.edu)) 23 | 24 | ## Acknowledgments 25 | 26 | This work was supported by the Chen Institute Mass General Research Scholar Award, Mass General Neuroscience Transformative Scholar Award, Tiny Blue Dot Foundation, NIH National Institute of Neurological Disorders and Stroke (R01NS138257), NIH Director’s Office (DP2HD101400), and MIT/MGH Brain Arousal State Control Innovation Center (BASCIC) project. 27 | -------------------------------------------------------------------------------- /animate_frames.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import os 3 | import glob 4 | import argparse 5 | 6 | def create_video_from_images(image_folder, output_video, fps=24, label=""): 7 | label = f"{label}_" if label else "" 8 | # Get a sorted list of all the PNG images in the blender output directory 9 | images = sorted(glob.glob(os.path.join(image_folder, f"{label}*.png"))) 10 | try: 11 | images.sort(key=lambda x: int(x.split('.')[0])) 12 | except: 13 | images.sort() 14 | 15 | if not images: 16 | print("No images found in the directory.") 17 | exit() 18 | 19 | # Read the first image to get the dimensions 20 | frame = cv2.imread(images[0]) 21 | height, width, layers = frame.shape 22 | 23 | # Define the video codec and create VideoWriter object 24 | fourcc = cv2.VideoWriter_fourcc(*'mp4v') 25 | video = cv2.VideoWriter(output_video, fourcc, fps, (width, height)) 26 | 27 | # Loop through all images and add them to the video 28 | for image in images: 29 | frame = cv2.imread(image) 30 | video.write(frame) 31 | 32 | # Release the video writer 33 | video.release() 34 | print(f"Video saved to {output_video}") 35 | 36 | def main(): 37 | parser = argparse.ArgumentParser(description="Create a video from a sequence of images.") 38 | parser.add_argument("-i", "--image_folder", type=str, help="Path to the folder containing PNG images.") 39 | parser.add_argument("-o", "--output_video", type=str, help="Output path for the video file.") 40 | parser.add_argument("-f", "--fps", type=int, default=24, help="Frames per second for the output video (default: 24).") 41 | parser.add_argument("-l", "--label", type=str, default="", help="Session Label (optional)") 42 | 43 | args = parser.parse_args() 44 | 45 | create_video_from_images(args.image_folder, args.output_video, args.fps args.label) 46 | 47 | if __name__ == "__main__": 48 | main() 49 | -------------------------------------------------------------------------------- /aseg_to_obj.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | import os 4 | import shutil 5 | import subprocess 6 | 7 | import numpy as np 8 | import nibabel as nib 9 | 10 | with open('./resources/aseg_labels.json', 'r') as aseg_label_path: 11 | aseg_labels = json.load(aseg_label_path) 12 | 13 | def execute_command(command, log=False, silent=True): 14 | """Runs an input shell command and optionally logs the output to a file.""" 15 | try: 16 | output = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, encoding='utf-8') 17 | 18 | if log: 19 | with open(log, 'a') as log_path: 20 | log_path.write(f'{output}\n\n') 21 | elif not silent: 22 | print(output,'\n') 23 | 24 | except subprocess.CalledProcessError as e: 25 | if log: 26 | with open(log, 'a') as log: 27 | log.write(f'Error running: \n{command}\n\n') 28 | log.write(f'{e.output}\n') 29 | else: 30 | print(output,'\n') 31 | 32 | def extract_label(recon_all_dir, label_index, output_file): 33 | """Extract a specific label from aseg file and save it as a binary volume.""" 34 | input_file = f"{recon_all_dir}/mri/aseg.mgz" 35 | 36 | if type(label_index) == list: 37 | join_niftis = [] 38 | for label in label_index: 39 | tmp_file = output_file.replace(output_file.split('/')[-1], label + '.nii.gz') 40 | command = f"mri_binarize --i {input_file} --match {label} --o {tmp_file}" 41 | execute_command(command) 42 | join_niftis.append(tmp_file) 43 | 44 | command = f"fslmaths {join_niftis[0]} -add " + " -add ".join(join_niftis[1:]) + f" {output_file}" 45 | execute_command(command) 46 | 47 | else: 48 | command = f"mri_binarize --i {input_file} --match {label_index} --o {output_file}" 49 | execute_command(command) 50 | 51 | command = f"fslmaths {output_file} -mul 1 {output_file}" 52 | execute_command(command) 53 | 54 | def nii2obj(input_nifti, output_object): 55 | """Use nii2mesh package to convert segmentation nifti into surface""" 56 | command = f"nii2mesh {input_nifti} -l 0 {output_object}" 57 | execute_command(command) 58 | 59 | def convert_aseg_to_surface(recon_all_dir, output_dir, aseg_label, label_index): 60 | os.makedirs(f"{output_dir}/tmp", exist_ok=True) 61 | input_path = f"{recon_all_dir}/mri/aseg.mgz" 62 | nifti_output = f"{output_dir}/tmp/{aseg_label}.nii.gz" 63 | output_object = f"{output_dir}/{aseg_label}.obj" 64 | 65 | extract_label(recon_all_dir, label_index, nifti_output) 66 | nii2obj(nifti_output, output_object) 67 | 68 | shutil.rmtree(f'{output_dir}/tmp') -------------------------------------------------------------------------------- /keyframe_tractography.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import sys 3 | import numpy as np 4 | import argparse 5 | 6 | def parse_arguments(): 7 | # Remove Blender's own arguments by splitting at "--". 8 | if "--" not in sys.argv: 9 | print("Error: Missing '--' to separate Blender args from script args.") 10 | sys.exit(1) 11 | 12 | script_args = sys.argv[sys.argv.index("--") + 1:] 13 | 14 | # Set up argparse for the script arguments. 15 | parser = argparse.ArgumentParser(description="Parse arguments for Blender script.") 16 | parser.add_argument("--streamline_activation", required=True, help=".npy file containing streamline activation timeseries") 17 | 18 | args = parser.parse_args(script_args) 19 | return args 20 | 21 | args = parse_arguments() 22 | streamline_activation_timeseries_path = args.streamline_activation 23 | 24 | # Load the activation time series 25 | streamline_activation_timeseries = np.load(streamline_activation_timeseries_path) 26 | # Retrieve the existing "Streamlines Collection" 27 | streamline_collection = bpy.data.collections.get("Streamlines Collection") 28 | if streamline_collection is None: 29 | raise ValueError("Streamlines Collection not found. Please ensure the streamlines are imported and in the Blender file.") 30 | 31 | else: 32 | print(f"Streamline sample: {streamline_collection.name} found with {len(streamline_collection.objects)} streamlines.") 33 | 34 | # Iterate over each streamline and set activation keyframes 35 | for index, obj in enumerate(streamline_collection.objects): 36 | # print(f"\rKeyframing streamline {index + 1}/{len(streamline_collection.objects)}") 37 | activations = streamline_activation_timeseries[index, :] 38 | 39 | # Set keyframes for the 'activation' property 40 | for frame, is_active in enumerate(activations, start=1): 41 | if "activation" not in obj: 42 | obj["activation"] = 0.0 43 | obj.id_properties_ui("activation").update(min=0.0, max=1.0) 44 | 45 | obj["activation"] = is_active 46 | obj.keyframe_insert(data_path='["activation"]', frame=frame) 47 | 48 | print(f"Keyframing complete") 49 | 50 | # Save File 51 | bpy.ops.wm.save_mainfile() -------------------------------------------------------------------------------- /render.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | from animate_frames import create_video_from_images 4 | 5 | global code_dir 6 | # Set code directory 7 | code_dir = os.path.dirname(os.path.abspath(__file__)) 8 | 9 | def setup_blender(subject, output_dir): 10 | """Set up Blender for rendering""" 11 | os.system(f"blender --background --python {code_dir}/scene_template.py -- --subject {subject} --output {output_dir}") 12 | 13 | def keyframe_tractography(output_dir, label=""): 14 | """Keyframe the streamlines""" 15 | os.sytem(f"blender --background {output_dir}/{subject}.blend --python {code_dir}/keyframe_tractography.py -- --streamline_activation {output_dir}/tractography/{label}streamline_activation_timeseries.npy") 16 | 17 | def render_output(subject, output_dir, label=""): 18 | blender_file = f'{output_dir}/{subject}.blend' 19 | 20 | os.system(f'''\ 21 | blender --background {blender_file} \ 22 | --engine BLENDER_EEVEE \ 23 | --render-output {output_dir}/render/{label}_frame_####.png \ 24 | --python {code_dir}/source_estimation_animation.py -- --source_estimation {output_dir}/source_estimation/normalized/{label}normalized.npy \ 25 | --render-anim 26 | ''') 27 | 28 | 29 | if __name__ == "__main__": 30 | parser = argparse.ArgumentParser(description="Parse arguments for Blender script.") 31 | parser.add_argument("-s", "--subject", required=True, help="Subject Identifier") 32 | parser.add_argument("-l", "--label", required=False, default="", help="Session Label (optional)") 33 | parser.add_argument("-o", "--output_dir", required=True, help="STREAM-4D Subject Output Directory") 34 | 35 | args = parser.parse_args() 36 | subject = args.subject 37 | output_dir = args.output_dir 38 | label = f"{args.label}_" if args.label else "" 39 | 40 | setup_blender(subject, output_dir) 41 | keyframe_tractography(output_dir, label) 42 | render_output(subject, output_dir, label) 43 | create_video_from_images(os.path.join(output_dir, "render"), os.path.join(output_dir, f"{label}_STREAM-4D.mp4"), fps=24, label=label) 44 | -------------------------------------------------------------------------------- /resources/FreeSurferColorLUT.txt: -------------------------------------------------------------------------------- 1 | 2 | #No. Label Name: R G B A 3 | 4 | 0 Unknown 0 0 0 0 5 | 1 Left-Cerebral-Exterior 70 130 180 0 6 | 2 Left-Cerebral-White-Matter 245 245 245 0 7 | 3 Left-Cerebral-Cortex 205 62 78 0 8 | 4 Left-Lateral-Ventricle 120 18 134 0 9 | 5 Left-Inf-Lat-Vent 196 58 250 0 10 | 6 Left-Cerebellum-Exterior 0 148 0 0 11 | 7 Left-Cerebellum-White-Matter 220 248 164 0 12 | 8 Left-Cerebellum-Cortex 230 148 34 0 13 | 9 Left-Thalamus-unused 0 118 14 0 14 | 10 Left-Thalamus 0 118 14 0 15 | 11 Left-Caudate 122 186 220 0 16 | 12 Left-Putamen 236 13 176 0 17 | 13 Left-Pallidum 12 48 255 0 18 | 14 3rd-Ventricle 204 182 142 0 19 | 15 4th-Ventricle 42 204 164 0 20 | 16 Brain-Stem 119 159 176 0 21 | 17 Left-Hippocampus 220 216 20 0 22 | 18 Left-Amygdala 103 255 255 0 23 | 19 Left-Insula 80 196 98 0 24 | 20 Left-Operculum 60 58 210 0 25 | 21 Line-1 60 58 210 0 26 | 22 Line-2 60 58 210 0 27 | 23 Line-3 60 58 210 0 28 | 24 CSF 60 60 60 0 29 | 25 Left-Lesion 255 165 0 0 30 | 26 Left-Accumbens-area 255 165 0 0 31 | 27 Left-Substancia-Nigra 0 255 127 0 32 | 28 Left-VentralDC 165 42 42 0 33 | 29 Left-undetermined 135 206 235 0 34 | 30 Left-vessel 160 32 240 0 35 | 31 Left-choroid-plexus 0 200 200 0 36 | 32 Left-F3orb 100 50 100 0 37 | 33 Left-aOg 122 135 50 0 38 | 34 Left-WMCrowns 123 135 50 0 39 | 35 Left-mOg 51 50 135 0 40 | 36 Left-pOg 74 155 60 0 41 | 37 Left-Stellate 120 62 43 0 42 | 38 Left-Porg 74 155 60 0 43 | 39 Left-Aorg 122 135 50 0 44 | 40 Right-Cerebral-Exterior 70 130 180 0 45 | 41 Right-Cerebral-White-Matter 245 245 245 0 46 | 42 Right-Cerebral-Cortex 205 62 78 0 47 | 43 Right-Lateral-Ventricle 120 18 134 0 48 | 44 Right-Inf-Lat-Vent 196 58 250 0 49 | 45 Right-Cerebellum-Exterior 0 148 0 0 50 | 46 Right-Cerebellum-White-Matter 220 248 164 0 51 | 47 Right-Cerebellum-Cortex 230 148 34 0 52 | 48 Right-Thalamus-unused 0 118 14 0 53 | 49 Right-Thalamus 0 118 14 0 54 | 50 Right-Caudate 122 186 220 0 55 | 51 Right-Putamen 236 13 176 0 56 | 52 Right-Pallidum 13 48 255 0 57 | 53 Right-Hippocampus 220 216 20 0 58 | 54 Right-Amygdala 103 255 255 0 59 | 55 Right-Insula 80 196 98 0 60 | 56 Right-Operculum 60 58 210 0 61 | 57 Right-Lesion 255 165 0 0 62 | 58 Right-Accumbens-area 255 165 0 0 63 | 59 Right-Substancia-Nigra 0 255 127 0 64 | 60 Right-VentralDC 165 42 42 0 65 | 61 Right-undetermined 135 206 235 0 66 | 62 Right-vessel 160 32 240 0 67 | 63 Right-choroid-plexus 0 200 221 0 68 | 64 Right-F3orb 100 50 100 0 69 | 65 Right-lOg 135 50 74 0 70 | 66 Right-WMCrowns 122 135 50 0 71 | 67 Right-mOg 51 50 135 0 72 | 68 Right-pOg 74 155 60 0 73 | 69 Right-Stellate 120 62 43 0 74 | 70 Right-Porg 74 155 60 0 75 | 71 Right-Aorg 122 135 50 0 76 | 72 5th-Ventricle 120 190 150 0 77 | 73 Left-Interior 122 135 50 0 78 | 74 Right-Interior 122 135 50 0 79 | # 75/76 removed. duplicates of 4/43 80 | # new 75/76 added 81 | 75 Left-Locus-Coeruleus 91 97 255 0 82 | 76 Right-Locus-Coeruleus 0 7 218 0 83 | 77 WM-hypointensities 200 70 255 0 84 | 78 Left-WM-hypointensities 255 148 10 0 85 | 79 Right-WM-hypointensities 255 148 10 0 86 | 80 non-WM-hypointensities 164 108 226 0 87 | 81 Left-non-WM-hypointensities 164 108 226 0 88 | 82 Right-non-WM-hypointensities 164 108 226 0 89 | 83 Left-F1 255 218 185 0 90 | 84 Right-F1 255 218 185 0 91 | 85 Optic-Chiasm 234 169 30 0 92 | 192 Corpus_Callosum 0 0 160 0 93 | 94 | 86 Left_future_WMSA 200 120 255 0 95 | 87 Right_future_WMSA 200 121 255 0 96 | 88 future_WMSA 200 122 255 0 97 | 98 | 96 Left-Amygdala-Anterior 205 10 125 0 99 | 97 Right-Amygdala-Anterior 205 10 125 0 100 | 98 Dura 160 32 240 0 101 | 102 | 99 Lesion 255 165 0 0 103 | 104 | 100 Left-wm-intensity-abnormality 124 140 178 0 105 | 101 Left-caudate-intensity-abnormality 125 140 178 0 106 | 102 Left-putamen-intensity-abnormality 126 140 178 0 107 | 103 Left-accumbens-intensity-abnormality 127 140 178 0 108 | 104 Left-pallidum-intensity-abnormality 124 141 178 0 109 | 105 Left-amygdala-intensity-abnormality 124 142 178 0 110 | 106 Left-hippocampus-intensity-abnormality 124 143 178 0 111 | 107 Left-thalamus-intensity-abnormality 124 144 178 0 112 | 108 Left-VDC-intensity-abnormality 124 140 179 0 113 | 109 Right-wm-intensity-abnormality 124 140 178 0 114 | 110 Right-caudate-intensity-abnormality 125 140 178 0 115 | 111 Right-putamen-intensity-abnormality 126 140 178 0 116 | 112 Right-accumbens-intensity-abnormality 127 140 178 0 117 | 113 Right-pallidum-intensity-abnormality 124 141 178 0 118 | 114 Right-amygdala-intensity-abnormality 124 142 178 0 119 | 115 Right-hippocampus-intensity-abnormality 124 143 178 0 120 | 116 Right-thalamus-intensity-abnormality 124 144 178 0 121 | 117 Right-VDC-intensity-abnormality 124 140 179 0 122 | 123 | 118 Epidermis 255 20 147 0 124 | 119 Conn-Tissue 205 179 139 0 125 | 120 SC-Fat-Muscle 238 238 209 0 126 | 121 Cranium 200 200 200 0 127 | 122 CSF-SA 74 255 74 0 128 | 123 Muscle 238 0 0 0 129 | 124 Ear 0 0 139 0 130 | 125 Adipose 173 255 47 0 131 | 126 Spinal-Cord 133 203 229 0 132 | 127 Soft-Tissue 26 237 57 0 133 | 128 Nerve 34 139 34 0 134 | 129 Bone 30 144 255 0 135 | 130 AirCavity 196 160 128 0 136 | 131 Orbital-Fat 238 59 59 0 137 | 132 Tongue 221 39 200 0 138 | 133 Nasal-Structures 238 174 238 0 139 | 134 Globe 255 0 0 0 140 | 135 Teeth 72 61 139 0 141 | 136 Left-Caudate-Putamen 21 39 132 0 142 | 137 Right-Caudate-Putamen 21 39 132 0 143 | 138 Left-Claustrum 65 135 20 0 144 | 139 Right-Claustrum 65 135 20 0 145 | 140 Cornea 134 4 160 0 146 | 142 Diploe 221 226 68 0 147 | 143 Vitreous-Humor 255 255 254 0 148 | 144 Lens 52 209 226 0 149 | 145 Aqueous-Humor 239 160 223 0 150 | 146 Outer-Table 70 130 180 0 151 | 147 Inner-Table 70 130 181 0 152 | 148 Periosteum 139 121 94 0 153 | 149 Endosteum 224 224 224 0 154 | 150 R-C-S 255 0 0 0 155 | 151 Iris 205 205 0 0 156 | 152 SC-Adipose-Muscle 238 238 209 0 157 | 153 SC-Tissue 139 121 94 0 158 | 154 Orbital-Adipose 238 59 59 0 159 | 160 | 155 Left-IntCapsule-Ant 238 59 59 0 161 | 156 Right-IntCapsule-Ant 238 59 59 0 162 | 157 Left-IntCapsule-Pos 62 10 205 0 163 | 158 Right-IntCapsule-Pos 62 10 205 0 164 | 165 | # These labels are for babies/children 166 | 159 Left-Cerebral-WM-unmyelinated 0 118 14 0 167 | 160 Right-Cerebral-WM-unmyelinated 0 118 14 0 168 | 161 Left-Cerebral-WM-myelinated 220 216 21 0 169 | 162 Right-Cerebral-WM-myelinated 220 216 21 0 170 | 163 Left-Subcortical-Gray-Matter 122 186 220 0 171 | 164 Right-Subcortical-Gray-Matter 122 186 220 0 172 | 165 Skull 120 120 120 0 173 | 166 Posterior-fossa 14 48 255 0 174 | 167 Scalp 166 42 42 0 175 | 168 Hematoma 121 18 134 0 176 | 169 Left-Basal-Ganglia 236 13 127 0 177 | 176 Right-Basal-Ganglia 236 13 126 0 178 | 179 | # Label names and colors for Brainstem consituents 180 | # No. Label Name: R G B A 181 | 170 brainstem 119 159 176 0 182 | 171 DCG 119 0 176 0 183 | 172 Vermis 119 100 176 0 184 | 173 Midbrain 242 104 76 0 185 | 174 Pons 206 195 58 0 186 | 175 Medulla 119 159 176 0 187 | 177 Vermis-White-Matter 119 50 176 0 188 | 178 SCP 142 182 0 0 189 | 179 Floculus 19 100 176 0 190 | 191 | #176 Right-Basal-Ganglia found in babies/children section above 192 | 193 | 180 Left-Cortical-Dysplasia 73 61 139 0 194 | 181 Right-Cortical-Dysplasia 73 62 139 0 195 | 182 CblumNodulus 10 100 176 0 196 | 183 Left-Vermis 119 100 176 0 197 | 184 Right-Vermis 100 119 176 0 198 | 199 | #192 Corpus_Callosum listed after #85 above 200 | 193 Left-hippocampal_fissure 0 196 255 0 201 | 194 Left-CADG-head 255 164 164 0 202 | 195 Left-subiculum 196 196 0 0 203 | 196 Left-fimbria 0 100 255 0 204 | 197 Right-hippocampal_fissure 128 196 164 0 205 | 198 Right-CADG-head 0 126 75 0 206 | 199 Right-subiculum 128 96 64 0 207 | 200 Right-fimbria 0 50 128 0 208 | 201 alveus 255 204 153 0 209 | 202 perforant_pathway 255 128 128 0 210 | 203 parasubiculum 175 175 75 0 211 | 204 presubiculum 64 0 64 0 212 | 205 subiculum 0 0 255 0 213 | 206 CA1 255 0 0 0 214 | 207 CA2 128 128 255 0 215 | 208 CA3 0 128 0 0 216 | 209 CA4 196 160 128 0 217 | 210 GC-DG 32 200 255 0 218 | 211 HATA 128 255 128 0 219 | 212 fimbria 204 153 204 0 220 | 213 lateral_ventricle 121 17 136 0 221 | 214 molecular_layer_HP 128 0 0 0 222 | 215 hippocampal_fissure 128 32 255 0 223 | 216 entorhinal_cortex 255 204 102 0 224 | 217 molecular_layer_subiculum 128 128 128 0 225 | 218 Amygdala 104 255 255 0 226 | 219 Cerebral_White_Matter 0 226 0 0 227 | 220 Cerebral_Cortex 205 63 78 0 228 | 221 Inf_Lat_Vent 197 58 250 0 229 | 222 Perirhinal 33 150 250 0 230 | 223 Cerebral_White_Matter_Edge 226 0 0 0 231 | 224 Background 100 100 100 0 232 | 225 Ectorhinal 197 150 250 0 233 | 226 HP_tail 170 170 255 0 234 | 227 Polymorphic-Layer 128 255 128 0 235 | 228 Intracellular-Space 204 153 204 0 236 | 229 molecular_layer_DG 168 0 0 0 237 | 230 Prosubiculum 252 132 8 0 238 | 239 | 231 HP_body 0 255 0 0 240 | 232 HP_head 255 0 0 0 241 | 242 | 233 presubiculum-head 32 0 32 0 243 | 234 presubiculum-body 64 0 64 0 244 | 235 subiculum-head 0 0 175 0 245 | 236 subiculum-body 0 0 255 0 246 | 237 CA1-head 175 75 75 0 247 | 238 CA1-body 255 0 0 0 248 | 239 CA3-head 0 80 0 0 249 | 240 CA3-body 0 128 0 0 250 | 241 CA4-head 120 90 50 0 251 | 242 CA4-body 196 160 128 0 252 | 243 GC-ML-DG-head 75 125 175 0 253 | 244 GC-ML-DG-body 32 200 255 0 254 | 245 molecular_layer_HP-head 100 25 25 0 255 | 246 molecular_layer_HP-body 128 0 0 0 256 | 257 | 247 FreezeSurface 10 100 100 0 258 | 259 | 250 Fornix 255 0 0 0 260 | 251 CC_Posterior 0 0 64 0 261 | 252 CC_Mid_Posterior 0 0 112 0 262 | 253 CC_Central 0 0 160 0 263 | 254 CC_Mid_Anterior 0 0 208 0 264 | 255 CC_Anterior 0 0 255 0 265 | 266 | # This is for keeping track of voxel changes 267 | 256 Voxel-Unchanged 0 0 0 0 268 | 269 | 257 CSF-ExtraCerebral 60 60 60 0 270 | 258 Head-ExtraCerebral 150 150 200 0 271 | 259 Eye-Fluid 60 60 60 0 272 | 260 BoneOrAir 119 159 176 0 273 | 261 PossibleFluid 120 18 134 0 274 | 262 Sinus 196 160 128 0 275 | 263 Left-Eustachian 119 159 176 0 276 | 264 Right-Eustachian 119 159 176 0 277 | 265 Left-Eyeball 60 60 60 0 278 | 266 Right-Eyeball 60 60 60 0 279 | 280 | 270 ctx-lh-infragranular 205 70 78 0 281 | 271 ctx-lh-layer1 210 80 78 0 282 | 272 ctx-lh-layer2 215 90 78 0 283 | 273 ctx-lh-layer3 220 100 78 0 284 | 274 ctx-lh-layer4 225 110 78 0 285 | 275 ctx-lh-layer5 230 120 78 0 286 | 276 ctx-lh-layer6 235 135 78 0 287 | 277 ctx-lh-supragranular 240 140 78 0 288 | 289 | # lymph node and vascular labels 290 | 331 Aorta 255 0 0 0 291 | 332 Left-Common-IliacA 255 80 0 0 292 | 333 Right-Common-IliacA 255 160 0 0 293 | 334 Left-External-IliacA 255 255 0 0 294 | 335 Right-External-IliacA 0 255 0 0 295 | 336 Left-Internal-IliacA 255 0 160 0 296 | 337 Right-Internal-IliacA 255 0 255 0 297 | 338 Left-Lateral-SacralA 255 50 80 0 298 | 339 Right-Lateral-SacralA 80 255 50 0 299 | 340 Left-ObturatorA 160 255 50 0 300 | 341 Right-ObturatorA 160 200 255 0 301 | 342 Left-Internal-PudendalA 0 255 160 0 302 | 343 Right-Internal-PudendalA 0 0 255 0 303 | 344 Left-UmbilicalA 80 50 255 0 304 | 345 Right-UmbilicalA 160 0 255 0 305 | 346 Left-Inf-RectalA 255 210 0 0 306 | 347 Right-Inf-RectalA 0 160 255 0 307 | 348 Left-Common-IliacV 255 200 80 0 308 | 349 Right-Common-IliacV 255 200 160 0 309 | 350 Left-External-IliacV 255 80 200 0 310 | 351 Right-External-IliacV 255 160 200 0 311 | 352 Left-Internal-IliacV 30 255 80 0 312 | 353 Right-Internal-IliacV 80 200 255 0 313 | 354 Left-ObturatorV 80 255 200 0 314 | 355 Right-ObturatorV 195 255 200 0 315 | 356 Left-Internal-PudendalV 120 200 20 0 316 | 357 Right-Internal-PudendalV 170 10 200 0 317 | 358 Pos-Lymph 20 130 180 0 318 | 359 Neg-Lymph 20 180 130 0 319 | 320 | 370 ctx-rh-infragranular 205 70 130 0 321 | 371 ctx-rh-layer1 210 80 130 0 322 | 372 ctx-rh-layer2 215 90 130 0 323 | 373 ctx-rh-layer3 220 100 130 0 324 | 374 ctx-rh-layer4 225 110 130 0 325 | 375 ctx-rh-layer5 230 120 130 0 326 | 376 ctx-rh-layer6 235 135 130 0 327 | 377 ctx-rh-supragranular 240 140 130 0 328 | 329 | 400 V1 206 62 78 0 330 | 401 V2 121 18 134 0 331 | 402 BA44 199 58 250 0 332 | 403 BA45 1 148 0 0 333 | 404 BA4a 221 248 164 0 334 | 405 BA4p 231 148 34 0 335 | 406 BA6 1 118 14 0 336 | 407 BA2 120 118 14 0 337 | 408 BA1_old 123 186 221 0 338 | 409 BAun2 238 13 177 0 339 | 410 BA1 123 186 220 0 340 | 411 BA2b 138 13 206 0 341 | 412 BA3a 238 130 176 0 342 | 413 BA3b 218 230 76 0 343 | 414 MT 38 213 176 0 344 | 415 AIPS_AIP_l 1 225 176 0 345 | 416 AIPS_AIP_r 1 225 176 0 346 | 417 AIPS_VIP_l 200 2 100 0 347 | 418 AIPS_VIP_r 200 2 100 0 348 | 419 IPL_PFcm_l 5 200 90 0 349 | 420 IPL_PFcm_r 5 200 90 0 350 | 421 IPL_PF_l 100 5 200 0 351 | 422 IPL_PFm_l 25 255 100 0 352 | 423 IPL_PFm_r 25 255 100 0 353 | 424 IPL_PFop_l 230 7 100 0 354 | 425 IPL_PFop_r 230 7 100 0 355 | 426 IPL_PF_r 100 5 200 0 356 | 427 IPL_PFt_l 150 10 200 0 357 | 428 IPL_PFt_r 150 10 200 0 358 | 429 IPL_PGa_l 175 10 176 0 359 | 430 IPL_PGa_r 175 10 176 0 360 | 431 IPL_PGp_l 10 100 255 0 361 | 432 IPL_PGp_r 10 100 255 0 362 | 433 Visual_V3d_l 150 45 70 0 363 | 434 Visual_V3d_r 150 45 70 0 364 | 435 Visual_V4_l 45 200 15 0 365 | 436 Visual_V4_r 45 200 15 0 366 | 437 Visual_V5_b 227 45 100 0 367 | 438 Visual_VP_l 227 45 100 0 368 | 439 Visual_VP_r 227 45 100 0 369 | 370 | # wm lesions 371 | 498 wmsa 143 188 143 0 372 | 499 other_wmsa 255 248 220 0 373 | 374 | # HiRes Hippocampus labeling 375 | 500 right_CA2_3 17 85 136 0 376 | 501 right_alveus 119 187 102 0 377 | 502 right_CA1 204 68 34 0 378 | 503 right_fimbria 204 0 255 0 379 | 504 right_presubiculum 221 187 17 0 380 | 505 right_hippocampal_fissure 153 221 238 0 381 | 506 right_CA4_DG 51 17 17 0 382 | 507 right_subiculum 0 119 85 0 383 | 508 right_fornix 20 100 200 0 384 | 385 | 550 left_CA2_3 17 85 137 0 386 | 551 left_alveus 119 187 103 0 387 | 552 left_CA1 204 68 35 0 388 | 553 left_fimbria 204 0 254 0 389 | 554 left_presubiculum 221 187 16 0 390 | 555 left_hippocampal_fissure 153 221 239 0 391 | 556 left_CA4_DG 51 17 18 0 392 | 557 left_subiculum 0 119 86 0 393 | 558 left_fornix 20 100 201 0 394 | 395 | 600 Tumor 254 254 254 0 396 | 397 | 398 | # Cerebellar parcellation labels from SUIT (matches labels in cma.h) 399 | #No. Label Name: R G B A 400 | 601 Cbm_Left_I_IV 70 130 180 0 401 | 602 Cbm_Right_I_IV 245 245 245 0 402 | 603 Cbm_Left_V 205 62 78 0 403 | 604 Cbm_Right_V 120 18 134 0 404 | 605 Cbm_Left_VI 196 58 250 0 405 | 606 Cbm_Vermis_VI 0 148 0 0 406 | 607 Cbm_Right_VI 220 248 164 0 407 | 608 Cbm_Left_CrusI 230 148 34 0 408 | 609 Cbm_Vermis_CrusI 0 118 14 0 409 | 610 Cbm_Right_CrusI 0 118 14 0 410 | 611 Cbm_Left_CrusII 122 186 220 0 411 | 612 Cbm_Vermis_CrusII 236 13 176 0 412 | 613 Cbm_Right_CrusII 12 48 255 0 413 | 614 Cbm_Left_VIIb 204 182 142 0 414 | 615 Cbm_Vermis_VIIb 42 204 164 0 415 | 616 Cbm_Right_VIIb 119 159 176 0 416 | 617 Cbm_Left_VIIIa 220 216 20 0 417 | 618 Cbm_Vermis_VIIIa 103 255 255 0 418 | 619 Cbm_Right_VIIIa 80 196 98 0 419 | 620 Cbm_Left_VIIIb 60 58 210 0 420 | 621 Cbm_Vermis_VIIIb 60 58 210 0 421 | 622 Cbm_Right_VIIIb 60 58 210 0 422 | 623 Cbm_Left_IX 60 58 210 0 423 | 624 Cbm_Vermis_IX 60 60 60 0 424 | 625 Cbm_Right_IX 255 165 0 0 425 | 626 Cbm_Left_X 255 165 0 0 426 | 627 Cbm_Vermis_X 0 255 127 0 427 | 628 Cbm_Right_X 165 42 42 0 428 | 429 | # Cerebellar lobule parcellations 430 | 640 Cbm_Right_I_V_med 204 0 0 0 431 | 641 Cbm_Right_I_V_mid 255 0 0 0 432 | 642 Cbm_Right_VI_med 0 0 255 0 433 | 643 Cbm_Right_VI_mid 30 144 255 0 434 | 644 Cbm_Right_VI_lat 100 212 237 0 435 | 645 Cbm_Right_CrusI_med 218 165 32 0 436 | 646 Cbm_Right_CrusI_mid 255 215 0 0 437 | 647 Cbm_Right_CrusI_lat 255 255 166 0 438 | 648 Cbm_Right_CrusII_med 153 0 204 0 439 | 649 Cbm_Right_CrusII_mid 153 141 209 0 440 | 650 Cbm_Right_CrusII_lat 204 204 255 0 441 | 651 Cbm_Right_7med 31 212 194 0 442 | 652 Cbm_Right_7mid 3 255 237 0 443 | 653 Cbm_Right_7lat 204 255 255 0 444 | 654 Cbm_Right_8med 86 74 147 0 445 | 655 Cbm_Right_8mid 114 114 190 0 446 | 656 Cbm_Right_8lat 184 178 255 0 447 | 657 Cbm_Right_PUNs 126 138 37 0 448 | 658 Cbm_Right_TONs 189 197 117 0 449 | 659 Cbm_Right_FLOs 240 230 140 0 450 | 660 Cbm_Left_I_V_med 204 0 0 0 451 | 661 Cbm_Left_I_V_mid 255 0 0 0 452 | 662 Cbm_Left_VI_med 0 0 255 0 453 | 663 Cbm_Left_VI_mid 30 144 255 0 454 | 664 Cbm_Left_VI_lat 100 212 237 0 455 | 665 Cbm_Left_CrusI_med 218 165 32 0 456 | 666 Cbm_Left_CrusI_mid 255 215 0 0 457 | 667 Cbm_Left_CrusI_lat 255 255 166 0 458 | 668 Cbm_Left_CrusII_med 153 0 204 0 459 | 669 Cbm_Left_CrusII_mid 153 141 209 0 460 | 670 Cbm_Left_CrusII_lat 204 204 255 0 461 | 671 Cbm_Left_7med 31 212 194 0 462 | 672 Cbm_Left_7mid 3 255 237 0 463 | 673 Cbm_Left_7lat 204 255 255 0 464 | 674 Cbm_Left_8med 86 74 147 0 465 | 675 Cbm_Left_8mid 114 114 190 0 466 | 676 Cbm_Left_8lat 184 178 255 0 467 | 677 Cbm_Left_PUNs 126 138 37 0 468 | 678 Cbm_Left_TONs 189 197 117 0 469 | 679 Cbm_Left_FLOs 240 230 140 0 470 | # Added by DNG 7/31/14 471 | 690 CbmWM_Gyri_Left 122 135 50 0 472 | 691 CbmWM_Gyri_Right 122 135 50 0 473 | 474 | 701 CSF-FSL-FAST 120 18 134 0 475 | 702 GrayMatter-FSL-FAST 205 62 78 0 476 | 703 WhiteMatter-FSL-FAST 0 225 0 0 477 | 478 | 801 L_hypothalamus_anterior_inferior 250 255 50 0 479 | 802 L_hypothalamus_anterior_superior 80 200 255 0 480 | 803 L_hypothalamus_posterior 255 160 0 0 481 | 804 L_hypothalamus_tubular_inferior 255 160 200 0 482 | 805 L_hypothalamus_tubular_superior 20 180 130 0 483 | 806 R_hypothalamus_anterior_inferior 250 255 50 0 484 | 807 R_hypothalamus_anterior_superior 80 200 255 0 485 | 808 R_hypothalamus_posterior 255 160 0 0 486 | 809 R_hypothalamus_tubular_inferior 255 160 200 0 487 | 810 R_hypothalamus_tubular_superior 20 180 130 0 488 | 489 | # SAMSEG-CHARM + 400 490 | 901 Air-Internal 0 170 0 0 491 | 902 Artery 204 0 0 255 492 | 906 EyeBalls 230 189 66 255 493 | 907 Other-Tissues 85 85 0 0 494 | 908 Rectus-Muscles 190 50 73 255 495 | 909 Mucosa 255 160 188 255 496 | 911 Skin 85 85 85 0 497 | 912 Charm-Spinal-Cord 0 187 169 255 498 | 914 Vein 0 84 255 255 499 | 915 Bone-Cortical 0 85 0 0 500 | 916 Bone-Cancellous 190 156 120 255 501 | 917 Charm-Background 0 168 255 255 502 | 920 Cortical-CSF 120 133 217 255 503 | 930 Optic-Nerve 0 191 122 255 504 | 505 | 506 | 999 SUSPICIOUS 255 100 100 0 507 | 508 | # Below is the color table for the cortical labels of the seg volume 509 | # created by mri_aparc2aseg in which the aseg cortex label is replaced 510 | # by the labels in the aparc. It also supports wm labels that will 511 | # eventually be created by mri_aparc2aseg. Otherwise, the aseg labels 512 | # do not change from above. The cortical lables are the same as in 513 | # colortable_desikan_killiany.txt, except that left hemisphere has 514 | # 1000 added to the index and the right has 2000 added. The label 515 | # names are also prepended with ctx-lh or ctx-rh. The white matter 516 | # labels are the same as in colortable_desikan_killiany.txt, except 517 | # that left hemisphere has 3000 added to the index and the right has 518 | # 4000 added. The label names are also prepended with wm-lh or wm-rh. 519 | # Centrum semiovale is also labled with 5001 (left) and 5002 (right). 520 | # Even further below are the color tables for aparc.a2005s and aparc.a2009s. 521 | 522 | #No. Label Name: R G B A 523 | 1000 ctx-lh-unknown 25 5 25 0 524 | 1001 ctx-lh-bankssts 25 100 40 0 525 | 1002 ctx-lh-caudalanteriorcingulate 125 100 160 0 526 | 1003 ctx-lh-caudalmiddlefrontal 100 25 0 0 527 | 1004 ctx-lh-corpuscallosum 120 70 50 0 528 | 1005 ctx-lh-cuneus 220 20 100 0 529 | 1006 ctx-lh-entorhinal 220 20 10 0 530 | 1007 ctx-lh-fusiform 180 220 140 0 531 | 1008 ctx-lh-inferiorparietal 220 60 220 0 532 | 1009 ctx-lh-inferiortemporal 180 40 120 0 533 | 1010 ctx-lh-isthmuscingulate 140 20 140 0 534 | 1011 ctx-lh-lateraloccipital 20 30 140 0 535 | 1012 ctx-lh-lateralorbitofrontal 35 75 50 0 536 | 1013 ctx-lh-lingual 225 140 140 0 537 | 1014 ctx-lh-medialorbitofrontal 200 35 75 0 538 | 1015 ctx-lh-middletemporal 160 100 50 0 539 | 1016 ctx-lh-parahippocampal 20 220 60 0 540 | 1017 ctx-lh-paracentral 60 220 60 0 541 | 1018 ctx-lh-parsopercularis 220 180 140 0 542 | 1019 ctx-lh-parsorbitalis 20 100 50 0 543 | 1020 ctx-lh-parstriangularis 220 60 20 0 544 | 1021 ctx-lh-pericalcarine 120 100 60 0 545 | 1022 ctx-lh-postcentral 220 20 20 0 546 | 1023 ctx-lh-posteriorcingulate 220 180 220 0 547 | 1024 ctx-lh-precentral 60 20 220 0 548 | 1025 ctx-lh-precuneus 160 140 180 0 549 | 1026 ctx-lh-rostralanteriorcingulate 80 20 140 0 550 | 1027 ctx-lh-rostralmiddlefrontal 75 50 125 0 551 | 1028 ctx-lh-superiorfrontal 20 220 160 0 552 | 1029 ctx-lh-superiorparietal 20 180 140 0 553 | 1030 ctx-lh-superiortemporal 140 220 220 0 554 | 1031 ctx-lh-supramarginal 80 160 20 0 555 | 1032 ctx-lh-frontalpole 100 0 100 0 556 | 1033 ctx-lh-temporalpole 70 70 70 0 557 | 1034 ctx-lh-transversetemporal 150 150 200 0 558 | 1035 ctx-lh-insula 255 192 32 0 559 | 560 | 2000 ctx-rh-unknown 25 5 25 0 561 | 2001 ctx-rh-bankssts 25 100 40 0 562 | 2002 ctx-rh-caudalanteriorcingulate 125 100 160 0 563 | 2003 ctx-rh-caudalmiddlefrontal 100 25 0 0 564 | 2004 ctx-rh-corpuscallosum 120 70 50 0 565 | 2005 ctx-rh-cuneus 220 20 100 0 566 | 2006 ctx-rh-entorhinal 220 20 10 0 567 | 2007 ctx-rh-fusiform 180 220 140 0 568 | 2008 ctx-rh-inferiorparietal 220 60 220 0 569 | 2009 ctx-rh-inferiortemporal 180 40 120 0 570 | 2010 ctx-rh-isthmuscingulate 140 20 140 0 571 | 2011 ctx-rh-lateraloccipital 20 30 140 0 572 | 2012 ctx-rh-lateralorbitofrontal 35 75 50 0 573 | 2013 ctx-rh-lingual 225 140 140 0 574 | 2014 ctx-rh-medialorbitofrontal 200 35 75 0 575 | 2015 ctx-rh-middletemporal 160 100 50 0 576 | 2016 ctx-rh-parahippocampal 20 220 60 0 577 | 2017 ctx-rh-paracentral 60 220 60 0 578 | 2018 ctx-rh-parsopercularis 220 180 140 0 579 | 2019 ctx-rh-parsorbitalis 20 100 50 0 580 | 2020 ctx-rh-parstriangularis 220 60 20 0 581 | 2021 ctx-rh-pericalcarine 120 100 60 0 582 | 2022 ctx-rh-postcentral 220 20 20 0 583 | 2023 ctx-rh-posteriorcingulate 220 180 220 0 584 | 2024 ctx-rh-precentral 60 20 220 0 585 | 2025 ctx-rh-precuneus 160 140 180 0 586 | 2026 ctx-rh-rostralanteriorcingulate 80 20 140 0 587 | 2027 ctx-rh-rostralmiddlefrontal 75 50 125 0 588 | 2028 ctx-rh-superiorfrontal 20 220 160 0 589 | 2029 ctx-rh-superiorparietal 20 180 140 0 590 | 2030 ctx-rh-superiortemporal 140 220 220 0 591 | 2031 ctx-rh-supramarginal 80 160 20 0 592 | 2032 ctx-rh-frontalpole 100 0 100 0 593 | 2033 ctx-rh-temporalpole 70 70 70 0 594 | 2034 ctx-rh-transversetemporal 150 150 200 0 595 | 2035 ctx-rh-insula 255 192 32 0 596 | 597 | 3000 wm-lh-unknown 230 250 230 0 598 | 3001 wm-lh-bankssts 230 155 215 0 599 | 3002 wm-lh-caudalanteriorcingulate 130 155 95 0 600 | 3003 wm-lh-caudalmiddlefrontal 155 230 255 0 601 | 3004 wm-lh-corpuscallosum 135 185 205 0 602 | 3005 wm-lh-cuneus 35 235 155 0 603 | 3006 wm-lh-entorhinal 35 235 245 0 604 | 3007 wm-lh-fusiform 75 35 115 0 605 | 3008 wm-lh-inferiorparietal 35 195 35 0 606 | 3009 wm-lh-inferiortemporal 75 215 135 0 607 | 3010 wm-lh-isthmuscingulate 115 235 115 0 608 | 3011 wm-lh-lateraloccipital 235 225 115 0 609 | 3012 wm-lh-lateralorbitofrontal 220 180 205 0 610 | 3013 wm-lh-lingual 30 115 115 0 611 | 3014 wm-lh-medialorbitofrontal 55 220 180 0 612 | 3015 wm-lh-middletemporal 95 155 205 0 613 | 3016 wm-lh-parahippocampal 235 35 195 0 614 | 3017 wm-lh-paracentral 195 35 195 0 615 | 3018 wm-lh-parsopercularis 35 75 115 0 616 | 3019 wm-lh-parsorbitalis 235 155 205 0 617 | 3020 wm-lh-parstriangularis 35 195 235 0 618 | 3021 wm-lh-pericalcarine 135 155 195 0 619 | 3022 wm-lh-postcentral 35 235 235 0 620 | 3023 wm-lh-posteriorcingulate 35 75 35 0 621 | 3024 wm-lh-precentral 195 235 35 0 622 | 3025 wm-lh-precuneus 95 115 75 0 623 | 3026 wm-lh-rostralanteriorcingulate 175 235 115 0 624 | 3027 wm-lh-rostralmiddlefrontal 180 205 130 0 625 | 3028 wm-lh-superiorfrontal 235 35 95 0 626 | 3029 wm-lh-superiorparietal 235 75 115 0 627 | 3030 wm-lh-superiortemporal 115 35 35 0 628 | 3031 wm-lh-supramarginal 175 95 235 0 629 | 3032 wm-lh-frontalpole 155 255 155 0 630 | 3033 wm-lh-temporalpole 185 185 185 0 631 | 3034 wm-lh-transversetemporal 105 105 55 0 632 | 3035 wm-lh-insula 20 220 160 0 633 | 634 | 4000 wm-rh-unknown 230 250 230 0 635 | 4001 wm-rh-bankssts 230 155 215 0 636 | 4002 wm-rh-caudalanteriorcingulate 130 155 95 0 637 | 4003 wm-rh-caudalmiddlefrontal 155 230 255 0 638 | 4004 wm-rh-corpuscallosum 135 185 205 0 639 | 4005 wm-rh-cuneus 35 235 155 0 640 | 4006 wm-rh-entorhinal 35 235 245 0 641 | 4007 wm-rh-fusiform 75 35 115 0 642 | 4008 wm-rh-inferiorparietal 35 195 35 0 643 | 4009 wm-rh-inferiortemporal 75 215 135 0 644 | 4010 wm-rh-isthmuscingulate 115 235 115 0 645 | 4011 wm-rh-lateraloccipital 235 225 115 0 646 | 4012 wm-rh-lateralorbitofrontal 220 180 205 0 647 | 4013 wm-rh-lingual 30 115 115 0 648 | 4014 wm-rh-medialorbitofrontal 55 220 180 0 649 | 4015 wm-rh-middletemporal 95 155 205 0 650 | 4016 wm-rh-parahippocampal 235 35 195 0 651 | 4017 wm-rh-paracentral 195 35 195 0 652 | 4018 wm-rh-parsopercularis 35 75 115 0 653 | 4019 wm-rh-parsorbitalis 235 155 205 0 654 | 4020 wm-rh-parstriangularis 35 195 235 0 655 | 4021 wm-rh-pericalcarine 135 155 195 0 656 | 4022 wm-rh-postcentral 35 235 235 0 657 | 4023 wm-rh-posteriorcingulate 35 75 35 0 658 | 4024 wm-rh-precentral 195 235 35 0 659 | 4025 wm-rh-precuneus 95 115 75 0 660 | 4026 wm-rh-rostralanteriorcingulate 175 235 115 0 661 | 4027 wm-rh-rostralmiddlefrontal 180 205 130 0 662 | 4028 wm-rh-superiorfrontal 235 35 95 0 663 | 4029 wm-rh-superiorparietal 235 75 115 0 664 | 4030 wm-rh-superiortemporal 115 35 35 0 665 | 4031 wm-rh-supramarginal 175 95 235 0 666 | 4032 wm-rh-frontalpole 155 255 155 0 667 | 4033 wm-rh-temporalpole 185 185 185 0 668 | 4034 wm-rh-transversetemporal 105 105 55 0 669 | 4035 wm-rh-insula 20 220 160 0 670 | 671 | # Below is the color table for a lobar parcellation obtained from running: 672 | # mri_annotation2label --subject subject --hemi lh --lobesStrict lobes 673 | # mri_annotation2label --subject subject --hemi rh --lobesStrict lobes 674 | # mri_aparc2aseg --s subject --rip-unknown --volmask \ 675 | # --o aparc.lobes.mgz --annot lobes \ 676 | # --base-offset 300 [--base-offset must be last arg] 677 | 678 | 1301 ctx-lh-frontal-lobe 25 100 40 0 679 | 1303 ctx-lh-cingulate-lobe 100 25 0 0 680 | 1304 ctx-lh-occipital-lobe 120 70 50 0 681 | 1305 ctx-lh-temporal-lobe 220 20 100 0 682 | 1306 ctx-lh-parietal-lobe 220 20 10 0 683 | 1307 ctx-lh-insula-lobe 255 192 32 0 684 | 685 | 2301 ctx-rh-frontal-lobe 25 100 40 0 686 | 2303 ctx-rh-cingulate-lobe 100 25 0 0 687 | 2304 ctx-rh-occipital-lobe 120 70 50 0 688 | 2305 ctx-rh-temporal-lobe 220 20 100 0 689 | 2306 ctx-rh-parietal-lobe 220 20 10 0 690 | 2307 ctx-rh-insula-lobe 255 192 32 0 691 | 692 | # Below is the color table for a lobar white matter parcellation 693 | # obtained from running: 694 | # mri_annotation2label --subject subject --hemi lh --lobesStrict lobes 695 | # mri_annotation2label --subject subject --hemi rh --lobesStrict lobes 696 | # mri_aparc2aseg --s subject --labelwm --hypo-as-wm --rip-unknown \ 697 | # --volmask --o wmparc.lobes.mgz --ctxseg aparc+aseg.mgz \ 698 | # --annot lobes --base-offset 200 [--base-offset must be last arg] 699 | 700 | 3201 wm-lh-frontal-lobe 235 35 95 0 701 | 3203 wm-lh-cingulate-lobe 35 75 35 0 702 | 3204 wm-lh-occipital-lobe 135 155 195 0 703 | 3205 wm-lh-temporal-lobe 115 35 35 0 704 | 3206 wm-lh-parietal-lobe 35 195 35 0 705 | 3207 wm-lh-insula-lobe 20 220 160 0 706 | 707 | 4201 wm-rh-frontal-lobe 235 35 95 0 708 | 4203 wm-rh-cingulate-lobe 35 75 35 0 709 | 4204 wm-rh-occipital-lobe 135 155 195 0 710 | 4205 wm-rh-temporal-lobe 115 35 35 0 711 | 4206 wm-rh-parietal-lobe 35 195 35 0 712 | 4207 wm-rh-insula-lobe 20 220 160 0 713 | 714 | # Below is the color table for the cortical labels of the seg volume 715 | # created by mri_aparc2aseg (with --a2005s flag) in which the aseg 716 | # cortex label is replaced by the labels in the aparc.a2005s. The 717 | # cortical labels are the same as in Simple_surface_labels2005.txt, 718 | # except that left hemisphere has 1100 added to the index and the 719 | # right has 2100 added. The label names are also prepended with 720 | # ctx-lh or ctx-rh. The aparc.a2009s labels are further below 721 | 722 | #No. Label Name: R G B A 723 | 1100 ctx-lh-Unknown 0 0 0 0 724 | 1101 ctx-lh-Corpus_callosum 50 50 50 0 725 | 1102 ctx-lh-G_and_S_Insula_ONLY_AVERAGE 180 20 30 0 726 | 1103 ctx-lh-G_cingulate-Isthmus 60 25 25 0 727 | 1104 ctx-lh-G_cingulate-Main_part 25 60 60 0 728 | 729 | 1200 ctx-lh-G_cingulate-caudal_ACC 25 60 61 0 730 | 1201 ctx-lh-G_cingulate-rostral_ACC 25 90 60 0 731 | 1202 ctx-lh-G_cingulate-posterior 25 120 60 0 732 | 733 | 1205 ctx-lh-S_cingulate-caudal_ACC 25 150 60 0 734 | 1206 ctx-lh-S_cingulate-rostral_ACC 25 180 60 0 735 | 1207 ctx-lh-S_cingulate-posterior 25 210 60 0 736 | 737 | 1210 ctx-lh-S_pericallosal-caudal 25 150 90 0 738 | 1211 ctx-lh-S_pericallosal-rostral 25 180 90 0 739 | 1212 ctx-lh-S_pericallosal-posterior 25 210 90 0 740 | 741 | 1105 ctx-lh-G_cuneus 180 20 20 0 742 | 1106 ctx-lh-G_frontal_inf-Opercular_part 220 20 100 0 743 | 1107 ctx-lh-G_frontal_inf-Orbital_part 140 60 60 0 744 | 1108 ctx-lh-G_frontal_inf-Triangular_part 180 220 140 0 745 | 1109 ctx-lh-G_frontal_middle 140 100 180 0 746 | 1110 ctx-lh-G_frontal_superior 180 20 140 0 747 | 1111 ctx-lh-G_frontomarginal 140 20 140 0 748 | 1112 ctx-lh-G_insular_long 21 10 10 0 749 | 1113 ctx-lh-G_insular_short 225 140 140 0 750 | 1114 ctx-lh-G_and_S_occipital_inferior 23 60 180 0 751 | 1115 ctx-lh-G_occipital_middle 180 60 180 0 752 | 1116 ctx-lh-G_occipital_superior 20 220 60 0 753 | 1117 ctx-lh-G_occipit-temp_lat-Or_fusiform 60 20 140 0 754 | 1118 ctx-lh-G_occipit-temp_med-Lingual_part 220 180 140 0 755 | 1119 ctx-lh-G_occipit-temp_med-Parahippocampal_part 65 100 20 0 756 | 1120 ctx-lh-G_orbital 220 60 20 0 757 | 1121 ctx-lh-G_paracentral 60 100 60 0 758 | 1122 ctx-lh-G_parietal_inferior-Angular_part 20 60 220 0 759 | 1123 ctx-lh-G_parietal_inferior-Supramarginal_part 100 100 60 0 760 | 1124 ctx-lh-G_parietal_superior 220 180 220 0 761 | 1125 ctx-lh-G_postcentral 20 180 140 0 762 | 1126 ctx-lh-G_precentral 60 140 180 0 763 | 1127 ctx-lh-G_precuneus 25 20 140 0 764 | 1128 ctx-lh-G_rectus 20 60 100 0 765 | 1129 ctx-lh-G_subcallosal 60 220 20 0 766 | 1130 ctx-lh-G_subcentral 60 20 220 0 767 | 1131 ctx-lh-G_temporal_inferior 220 220 100 0 768 | 1132 ctx-lh-G_temporal_middle 180 60 60 0 769 | 1133 ctx-lh-G_temp_sup-G_temp_transv_and_interm_S 60 60 220 0 770 | 1134 ctx-lh-G_temp_sup-Lateral_aspect 220 60 220 0 771 | 1135 ctx-lh-G_temp_sup-Planum_polare 65 220 60 0 772 | 1136 ctx-lh-G_temp_sup-Planum_tempolare 25 140 20 0 773 | 1137 ctx-lh-G_and_S_transverse_frontopolar 13 0 250 0 774 | 1138 ctx-lh-Lat_Fissure-ant_sgt-ramus_horizontal 61 20 220 0 775 | 1139 ctx-lh-Lat_Fissure-ant_sgt-ramus_vertical 61 20 60 0 776 | 1140 ctx-lh-Lat_Fissure-post_sgt 61 60 100 0 777 | 1141 ctx-lh-Medial_wall 25 25 25 0 778 | 1142 ctx-lh-Pole_occipital 140 20 60 0 779 | 1143 ctx-lh-Pole_temporal 220 180 20 0 780 | 1144 ctx-lh-S_calcarine 63 180 180 0 781 | 1145 ctx-lh-S_central 221 20 10 0 782 | 1146 ctx-lh-S_central_insula 21 220 20 0 783 | 1147 ctx-lh-S_cingulate-Main_part_and_Intracingulate 183 100 20 0 784 | 1148 ctx-lh-S_cingulate-Marginalis_part 221 20 100 0 785 | 1149 ctx-lh-S_circular_insula_anterior 221 60 140 0 786 | 1150 ctx-lh-S_circular_insula_inferior 221 20 220 0 787 | 1151 ctx-lh-S_circular_insula_superior 61 220 220 0 788 | 1152 ctx-lh-S_collateral_transverse_ant 100 200 200 0 789 | 1153 ctx-lh-S_collateral_transverse_post 10 200 200 0 790 | 1154 ctx-lh-S_frontal_inferior 221 220 20 0 791 | 1155 ctx-lh-S_frontal_middle 141 20 100 0 792 | 1156 ctx-lh-S_frontal_superior 61 220 100 0 793 | 1157 ctx-lh-S_frontomarginal 21 220 60 0 794 | 1158 ctx-lh-S_intermedius_primus-Jensen 141 60 20 0 795 | 1159 ctx-lh-S_intraparietal-and_Parietal_transverse 143 20 220 0 796 | 1160 ctx-lh-S_occipital_anterior 61 20 180 0 797 | 1161 ctx-lh-S_occipital_middle_and_Lunatus 101 60 220 0 798 | 1162 ctx-lh-S_occipital_superior_and_transversalis 21 20 140 0 799 | 1163 ctx-lh-S_occipito-temporal_lateral 221 140 20 0 800 | 1164 ctx-lh-S_occipito-temporal_medial_and_S_Lingual 141 100 220 0 801 | 1165 ctx-lh-S_orbital-H_shapped 101 20 20 0 802 | 1166 ctx-lh-S_orbital_lateral 221 100 20 0 803 | 1167 ctx-lh-S_orbital_medial-Or_olfactory 181 200 20 0 804 | 1168 ctx-lh-S_paracentral 21 180 140 0 805 | 1169 ctx-lh-S_parieto_occipital 101 100 180 0 806 | 1170 ctx-lh-S_pericallosal 181 220 20 0 807 | 1171 ctx-lh-S_postcentral 21 140 200 0 808 | 1172 ctx-lh-S_precentral-Inferior-part 21 20 240 0 809 | 1173 ctx-lh-S_precentral-Superior-part 21 20 200 0 810 | 1174 ctx-lh-S_subcentral_ant 61 180 60 0 811 | 1175 ctx-lh-S_subcentral_post 61 180 250 0 812 | 1176 ctx-lh-S_suborbital 21 20 60 0 813 | 1177 ctx-lh-S_subparietal 101 60 60 0 814 | 1178 ctx-lh-S_supracingulate 21 220 220 0 815 | 1179 ctx-lh-S_temporal_inferior 21 180 180 0 816 | 1180 ctx-lh-S_temporal_superior 223 220 60 0 817 | 1181 ctx-lh-S_temporal_transverse 221 60 60 0 818 | 819 | 2100 ctx-rh-Unknown 0 0 0 0 820 | 2101 ctx-rh-Corpus_callosum 50 50 50 0 821 | 2102 ctx-rh-G_and_S_Insula_ONLY_AVERAGE 180 20 30 0 822 | 2103 ctx-rh-G_cingulate-Isthmus 60 25 25 0 823 | 2104 ctx-rh-G_cingulate-Main_part 25 60 60 0 824 | 825 | 2105 ctx-rh-G_cuneus 180 20 20 0 826 | 2106 ctx-rh-G_frontal_inf-Opercular_part 220 20 100 0 827 | 2107 ctx-rh-G_frontal_inf-Orbital_part 140 60 60 0 828 | 2108 ctx-rh-G_frontal_inf-Triangular_part 180 220 140 0 829 | 2109 ctx-rh-G_frontal_middle 140 100 180 0 830 | 2110 ctx-rh-G_frontal_superior 180 20 140 0 831 | 2111 ctx-rh-G_frontomarginal 140 20 140 0 832 | 2112 ctx-rh-G_insular_long 21 10 10 0 833 | 2113 ctx-rh-G_insular_short 225 140 140 0 834 | 2114 ctx-rh-G_and_S_occipital_inferior 23 60 180 0 835 | 2115 ctx-rh-G_occipital_middle 180 60 180 0 836 | 2116 ctx-rh-G_occipital_superior 20 220 60 0 837 | 2117 ctx-rh-G_occipit-temp_lat-Or_fusiform 60 20 140 0 838 | 2118 ctx-rh-G_occipit-temp_med-Lingual_part 220 180 140 0 839 | 2119 ctx-rh-G_occipit-temp_med-Parahippocampal_part 65 100 20 0 840 | 2120 ctx-rh-G_orbital 220 60 20 0 841 | 2121 ctx-rh-G_paracentral 60 100 60 0 842 | 2122 ctx-rh-G_parietal_inferior-Angular_part 20 60 220 0 843 | 2123 ctx-rh-G_parietal_inferior-Supramarginal_part 100 100 60 0 844 | 2124 ctx-rh-G_parietal_superior 220 180 220 0 845 | 2125 ctx-rh-G_postcentral 20 180 140 0 846 | 2126 ctx-rh-G_precentral 60 140 180 0 847 | 2127 ctx-rh-G_precuneus 25 20 140 0 848 | 2128 ctx-rh-G_rectus 20 60 100 0 849 | 2129 ctx-rh-G_subcallosal 60 220 20 0 850 | 2130 ctx-rh-G_subcentral 60 20 220 0 851 | 2131 ctx-rh-G_temporal_inferior 220 220 100 0 852 | 2132 ctx-rh-G_temporal_middle 180 60 60 0 853 | 2133 ctx-rh-G_temp_sup-G_temp_transv_and_interm_S 60 60 220 0 854 | 2134 ctx-rh-G_temp_sup-Lateral_aspect 220 60 220 0 855 | 2135 ctx-rh-G_temp_sup-Planum_polare 65 220 60 0 856 | 2136 ctx-rh-G_temp_sup-Planum_tempolare 25 140 20 0 857 | 2137 ctx-rh-G_and_S_transverse_frontopolar 13 0 250 0 858 | 2138 ctx-rh-Lat_Fissure-ant_sgt-ramus_horizontal 61 20 220 0 859 | 2139 ctx-rh-Lat_Fissure-ant_sgt-ramus_vertical 61 20 60 0 860 | 2140 ctx-rh-Lat_Fissure-post_sgt 61 60 100 0 861 | 2141 ctx-rh-Medial_wall 25 25 25 0 862 | 2142 ctx-rh-Pole_occipital 140 20 60 0 863 | 2143 ctx-rh-Pole_temporal 220 180 20 0 864 | 2144 ctx-rh-S_calcarine 63 180 180 0 865 | 2145 ctx-rh-S_central 221 20 10 0 866 | 2146 ctx-rh-S_central_insula 21 220 20 0 867 | 2147 ctx-rh-S_cingulate-Main_part_and_Intracingulate 183 100 20 0 868 | 2148 ctx-rh-S_cingulate-Marginalis_part 221 20 100 0 869 | 2149 ctx-rh-S_circular_insula_anterior 221 60 140 0 870 | 2150 ctx-rh-S_circular_insula_inferior 221 20 220 0 871 | 2151 ctx-rh-S_circular_insula_superior 61 220 220 0 872 | 2152 ctx-rh-S_collateral_transverse_ant 100 200 200 0 873 | 2153 ctx-rh-S_collateral_transverse_post 10 200 200 0 874 | 2154 ctx-rh-S_frontal_inferior 221 220 20 0 875 | 2155 ctx-rh-S_frontal_middle 141 20 100 0 876 | 2156 ctx-rh-S_frontal_superior 61 220 100 0 877 | 2157 ctx-rh-S_frontomarginal 21 220 60 0 878 | 2158 ctx-rh-S_intermedius_primus-Jensen 141 60 20 0 879 | 2159 ctx-rh-S_intraparietal-and_Parietal_transverse 143 20 220 0 880 | 2160 ctx-rh-S_occipital_anterior 61 20 180 0 881 | 2161 ctx-rh-S_occipital_middle_and_Lunatus 101 60 220 0 882 | 2162 ctx-rh-S_occipital_superior_and_transversalis 21 20 140 0 883 | 2163 ctx-rh-S_occipito-temporal_lateral 221 140 20 0 884 | 2164 ctx-rh-S_occipito-temporal_medial_and_S_Lingual 141 100 220 0 885 | 2165 ctx-rh-S_orbital-H_shapped 101 20 20 0 886 | 2166 ctx-rh-S_orbital_lateral 221 100 20 0 887 | 2167 ctx-rh-S_orbital_medial-Or_olfactory 181 200 20 0 888 | 2168 ctx-rh-S_paracentral 21 180 140 0 889 | 2169 ctx-rh-S_parieto_occipital 101 100 180 0 890 | 2170 ctx-rh-S_pericallosal 181 220 20 0 891 | 2171 ctx-rh-S_postcentral 21 140 200 0 892 | 2172 ctx-rh-S_precentral-Inferior-part 21 20 240 0 893 | 2173 ctx-rh-S_precentral-Superior-part 21 20 200 0 894 | 2174 ctx-rh-S_subcentral_ant 61 180 60 0 895 | 2175 ctx-rh-S_subcentral_post 61 180 250 0 896 | 2176 ctx-rh-S_suborbital 21 20 60 0 897 | 2177 ctx-rh-S_subparietal 101 60 60 0 898 | 2178 ctx-rh-S_supracingulate 21 220 220 0 899 | 2179 ctx-rh-S_temporal_inferior 21 180 180 0 900 | 2180 ctx-rh-S_temporal_superior 223 220 60 0 901 | 2181 ctx-rh-S_temporal_transverse 221 60 60 0 902 | 903 | 904 | 2200 ctx-rh-G_cingulate-caudal_ACC 25 60 61 0 905 | 2201 ctx-rh-G_cingulate-rostral_ACC 25 90 60 0 906 | 2202 ctx-rh-G_cingulate-posterior 25 120 60 0 907 | 908 | 2205 ctx-rh-S_cingulate-caudal_ACC 25 150 60 0 909 | 2206 ctx-rh-S_cingulate-rostral_ACC 25 180 60 0 910 | 2207 ctx-rh-S_cingulate-posterior 25 210 60 0 911 | 912 | 2210 ctx-rh-S_pericallosal-caudal 25 150 90 0 913 | 2211 ctx-rh-S_pericallosal-rostral 25 180 90 0 914 | 2212 ctx-rh-S_pericallosal-posterior 25 210 90 0 915 | 916 | 3100 wm-lh-Unknown 0 0 0 0 917 | 3101 wm-lh-Corpus_callosum 50 50 50 0 918 | 3102 wm-lh-G_and_S_Insula_ONLY_AVERAGE 180 20 30 0 919 | 3103 wm-lh-G_cingulate-Isthmus 60 25 25 0 920 | 3104 wm-lh-G_cingulate-Main_part 25 60 60 0 921 | 3105 wm-lh-G_cuneus 180 20 20 0 922 | 3106 wm-lh-G_frontal_inf-Opercular_part 220 20 100 0 923 | 3107 wm-lh-G_frontal_inf-Orbital_part 140 60 60 0 924 | 3108 wm-lh-G_frontal_inf-Triangular_part 180 220 140 0 925 | 3109 wm-lh-G_frontal_middle 140 100 180 0 926 | 3110 wm-lh-G_frontal_superior 180 20 140 0 927 | 3111 wm-lh-G_frontomarginal 140 20 140 0 928 | 3112 wm-lh-G_insular_long 21 10 10 0 929 | 3113 wm-lh-G_insular_short 225 140 140 0 930 | 3114 wm-lh-G_and_S_occipital_inferior 23 60 180 0 931 | 3115 wm-lh-G_occipital_middle 180 60 180 0 932 | 3116 wm-lh-G_occipital_superior 20 220 60 0 933 | 3117 wm-lh-G_occipit-temp_lat-Or_fusiform 60 20 140 0 934 | 3118 wm-lh-G_occipit-temp_med-Lingual_part 220 180 140 0 935 | 3119 wm-lh-G_occipit-temp_med-Parahippocampal_part 65 100 20 0 936 | 3120 wm-lh-G_orbital 220 60 20 0 937 | 3121 wm-lh-G_paracentral 60 100 60 0 938 | 3122 wm-lh-G_parietal_inferior-Angular_part 20 60 220 0 939 | 3123 wm-lh-G_parietal_inferior-Supramarginal_part 100 100 60 0 940 | 3124 wm-lh-G_parietal_superior 220 180 220 0 941 | 3125 wm-lh-G_postcentral 20 180 140 0 942 | 3126 wm-lh-G_precentral 60 140 180 0 943 | 3127 wm-lh-G_precuneus 25 20 140 0 944 | 3128 wm-lh-G_rectus 20 60 100 0 945 | 3129 wm-lh-G_subcallosal 60 220 20 0 946 | 3130 wm-lh-G_subcentral 60 20 220 0 947 | 3131 wm-lh-G_temporal_inferior 220 220 100 0 948 | 3132 wm-lh-G_temporal_middle 180 60 60 0 949 | 3133 wm-lh-G_temp_sup-G_temp_transv_and_interm_S 60 60 220 0 950 | 3134 wm-lh-G_temp_sup-Lateral_aspect 220 60 220 0 951 | 3135 wm-lh-G_temp_sup-Planum_polare 65 220 60 0 952 | 3136 wm-lh-G_temp_sup-Planum_tempolare 25 140 20 0 953 | 3137 wm-lh-G_and_S_transverse_frontopolar 13 0 250 0 954 | 3138 wm-lh-Lat_Fissure-ant_sgt-ramus_horizontal 61 20 220 0 955 | 3139 wm-lh-Lat_Fissure-ant_sgt-ramus_vertical 61 20 60 0 956 | 3140 wm-lh-Lat_Fissure-post_sgt 61 60 100 0 957 | 3141 wm-lh-Medial_wall 25 25 25 0 958 | 3142 wm-lh-Pole_occipital 140 20 60 0 959 | 3143 wm-lh-Pole_temporal 220 180 20 0 960 | 3144 wm-lh-S_calcarine 63 180 180 0 961 | 3145 wm-lh-S_central 221 20 10 0 962 | 3146 wm-lh-S_central_insula 21 220 20 0 963 | 3147 wm-lh-S_cingulate-Main_part_and_Intracingulate 183 100 20 0 964 | 3148 wm-lh-S_cingulate-Marginalis_part 221 20 100 0 965 | 3149 wm-lh-S_circular_insula_anterior 221 60 140 0 966 | 3150 wm-lh-S_circular_insula_inferior 221 20 220 0 967 | 3151 wm-lh-S_circular_insula_superior 61 220 220 0 968 | 3152 wm-lh-S_collateral_transverse_ant 100 200 200 0 969 | 3153 wm-lh-S_collateral_transverse_post 10 200 200 0 970 | 3154 wm-lh-S_frontal_inferior 221 220 20 0 971 | 3155 wm-lh-S_frontal_middle 141 20 100 0 972 | 3156 wm-lh-S_frontal_superior 61 220 100 0 973 | 3157 wm-lh-S_frontomarginal 21 220 60 0 974 | 3158 wm-lh-S_intermedius_primus-Jensen 141 60 20 0 975 | 3159 wm-lh-S_intraparietal-and_Parietal_transverse 143 20 220 0 976 | 3160 wm-lh-S_occipital_anterior 61 20 180 0 977 | 3161 wm-lh-S_occipital_middle_and_Lunatus 101 60 220 0 978 | 3162 wm-lh-S_occipital_superior_and_transversalis 21 20 140 0 979 | 3163 wm-lh-S_occipito-temporal_lateral 221 140 20 0 980 | 3164 wm-lh-S_occipito-temporal_medial_and_S_Lingual 141 100 220 0 981 | 3165 wm-lh-S_orbital-H_shapped 101 20 20 0 982 | 3166 wm-lh-S_orbital_lateral 221 100 20 0 983 | 3167 wm-lh-S_orbital_medial-Or_olfactory 181 200 20 0 984 | 3168 wm-lh-S_paracentral 21 180 140 0 985 | 3169 wm-lh-S_parieto_occipital 101 100 180 0 986 | 3170 wm-lh-S_pericallosal 181 220 20 0 987 | 3171 wm-lh-S_postcentral 21 140 200 0 988 | 3172 wm-lh-S_precentral-Inferior-part 21 20 240 0 989 | 3173 wm-lh-S_precentral-Superior-part 21 20 200 0 990 | 3174 wm-lh-S_subcentral_ant 61 180 60 0 991 | 3175 wm-lh-S_subcentral_post 61 180 250 0 992 | 3176 wm-lh-S_suborbital 21 20 60 0 993 | 3177 wm-lh-S_subparietal 101 60 60 0 994 | 3178 wm-lh-S_supracingulate 21 220 220 0 995 | 3179 wm-lh-S_temporal_inferior 21 180 180 0 996 | 3180 wm-lh-S_temporal_superior 223 220 60 0 997 | 3181 wm-lh-S_temporal_transverse 221 60 60 0 998 | 999 | 4100 wm-rh-Unknown 0 0 0 0 1000 | 4101 wm-rh-Corpus_callosum 50 50 50 0 1001 | 4102 wm-rh-G_and_S_Insula_ONLY_AVERAGE 180 20 30 0 1002 | 4103 wm-rh-G_cingulate-Isthmus 60 25 25 0 1003 | 4104 wm-rh-G_cingulate-Main_part 25 60 60 0 1004 | 4105 wm-rh-G_cuneus 180 20 20 0 1005 | 4106 wm-rh-G_frontal_inf-Opercular_part 220 20 100 0 1006 | 4107 wm-rh-G_frontal_inf-Orbital_part 140 60 60 0 1007 | 4108 wm-rh-G_frontal_inf-Triangular_part 180 220 140 0 1008 | 4109 wm-rh-G_frontal_middle 140 100 180 0 1009 | 4110 wm-rh-G_frontal_superior 180 20 140 0 1010 | 4111 wm-rh-G_frontomarginal 140 20 140 0 1011 | 4112 wm-rh-G_insular_long 21 10 10 0 1012 | 4113 wm-rh-G_insular_short 225 140 140 0 1013 | 4114 wm-rh-G_and_S_occipital_inferior 23 60 180 0 1014 | 4115 wm-rh-G_occipital_middle 180 60 180 0 1015 | 4116 wm-rh-G_occipital_superior 20 220 60 0 1016 | 4117 wm-rh-G_occipit-temp_lat-Or_fusiform 60 20 140 0 1017 | 4118 wm-rh-G_occipit-temp_med-Lingual_part 220 180 140 0 1018 | 4119 wm-rh-G_occipit-temp_med-Parahippocampal_part 65 100 20 0 1019 | 4120 wm-rh-G_orbital 220 60 20 0 1020 | 4121 wm-rh-G_paracentral 60 100 60 0 1021 | 4122 wm-rh-G_parietal_inferior-Angular_part 20 60 220 0 1022 | 4123 wm-rh-G_parietal_inferior-Supramarginal_part 100 100 60 0 1023 | 4124 wm-rh-G_parietal_superior 220 180 220 0 1024 | 4125 wm-rh-G_postcentral 20 180 140 0 1025 | 4126 wm-rh-G_precentral 60 140 180 0 1026 | 4127 wm-rh-G_precuneus 25 20 140 0 1027 | 4128 wm-rh-G_rectus 20 60 100 0 1028 | 4129 wm-rh-G_subcallosal 60 220 20 0 1029 | 4130 wm-rh-G_subcentral 60 20 220 0 1030 | 4131 wm-rh-G_temporal_inferior 220 220 100 0 1031 | 4132 wm-rh-G_temporal_middle 180 60 60 0 1032 | 4133 wm-rh-G_temp_sup-G_temp_transv_and_interm_S 60 60 220 0 1033 | 4134 wm-rh-G_temp_sup-Lateral_aspect 220 60 220 0 1034 | 4135 wm-rh-G_temp_sup-Planum_polare 65 220 60 0 1035 | 4136 wm-rh-G_temp_sup-Planum_tempolare 25 140 20 0 1036 | 4137 wm-rh-G_and_S_transverse_frontopolar 13 0 250 0 1037 | 4138 wm-rh-Lat_Fissure-ant_sgt-ramus_horizontal 61 20 220 0 1038 | 4139 wm-rh-Lat_Fissure-ant_sgt-ramus_vertical 61 20 60 0 1039 | 4140 wm-rh-Lat_Fissure-post_sgt 61 60 100 0 1040 | 4141 wm-rh-Medial_wall 25 25 25 0 1041 | 4142 wm-rh-Pole_occipital 140 20 60 0 1042 | 4143 wm-rh-Pole_temporal 220 180 20 0 1043 | 4144 wm-rh-S_calcarine 63 180 180 0 1044 | 4145 wm-rh-S_central 221 20 10 0 1045 | 4146 wm-rh-S_central_insula 21 220 20 0 1046 | 4147 wm-rh-S_cingulate-Main_part_and_Intracingulate 183 100 20 0 1047 | 4148 wm-rh-S_cingulate-Marginalis_part 221 20 100 0 1048 | 4149 wm-rh-S_circular_insula_anterior 221 60 140 0 1049 | 4150 wm-rh-S_circular_insula_inferior 221 20 220 0 1050 | 4151 wm-rh-S_circular_insula_superior 61 220 220 0 1051 | 4152 wm-rh-S_collateral_transverse_ant 100 200 200 0 1052 | 4153 wm-rh-S_collateral_transverse_post 10 200 200 0 1053 | 4154 wm-rh-S_frontal_inferior 221 220 20 0 1054 | 4155 wm-rh-S_frontal_middle 141 20 100 0 1055 | 4156 wm-rh-S_frontal_superior 61 220 100 0 1056 | 4157 wm-rh-S_frontomarginal 21 220 60 0 1057 | 4158 wm-rh-S_intermedius_primus-Jensen 141 60 20 0 1058 | 4159 wm-rh-S_intraparietal-and_Parietal_transverse 143 20 220 0 1059 | 4160 wm-rh-S_occipital_anterior 61 20 180 0 1060 | 4161 wm-rh-S_occipital_middle_and_Lunatus 101 60 220 0 1061 | 4162 wm-rh-S_occipital_superior_and_transversalis 21 20 140 0 1062 | 4163 wm-rh-S_occipito-temporal_lateral 221 140 20 0 1063 | 4164 wm-rh-S_occipito-temporal_medial_and_S_Lingual 141 100 220 0 1064 | 4165 wm-rh-S_orbital-H_shapped 101 20 20 0 1065 | 4166 wm-rh-S_orbital_lateral 221 100 20 0 1066 | 4167 wm-rh-S_orbital_medial-Or_olfactory 181 200 20 0 1067 | 4168 wm-rh-S_paracentral 21 180 140 0 1068 | 4169 wm-rh-S_parieto_occipital 101 100 180 0 1069 | 4170 wm-rh-S_pericallosal 181 220 20 0 1070 | 4171 wm-rh-S_postcentral 21 140 200 0 1071 | 4172 wm-rh-S_precentral-Inferior-part 21 20 240 0 1072 | 4173 wm-rh-S_precentral-Superior-part 21 20 200 0 1073 | 4174 wm-rh-S_subcentral_ant 61 180 60 0 1074 | 4175 wm-rh-S_subcentral_post 61 180 250 0 1075 | 4176 wm-rh-S_suborbital 21 20 60 0 1076 | 4177 wm-rh-S_subparietal 101 60 60 0 1077 | 4178 wm-rh-S_supracingulate 21 220 220 0 1078 | 4179 wm-rh-S_temporal_inferior 21 180 180 0 1079 | 4180 wm-rh-S_temporal_superior 223 220 60 0 1080 | 4181 wm-rh-S_temporal_transverse 221 60 60 0 1081 | 1082 | 5001 Left-UnsegmentedWhiteMatter 20 30 40 0 1083 | 5002 Right-UnsegmentedWhiteMatter 20 30 40 0 1084 | 1085 | # Below is the color table for white-matter pathways produced by dmri_paths 1086 | 1087 | #No. Label Name: R G B A 1088 | # 1089 | 5100 fmajor 204 102 102 0 1090 | 5101 fminor 204 102 102 0 1091 | 5102 cc.body 204 102 102 0 1092 | 5103 cc.bodyc 255 153 153 0 1093 | 5104 cc.bodypf 255 153 153 0 1094 | 5105 cc.bodypm 255 204 204 0 1095 | 5106 cc.bodyp 255 102 102 0 1096 | 5107 cc.bodyt 255 204 204 0 1097 | 5108 cc.genu 255 102 102 0 1098 | 5109 cc.rostrum 204 51 51 0 1099 | 5110 cc.splenium 204 51 51 0 1100 | 5111 acomm 204 102 102 0 1101 | 5112 mcp 102 51 153 0 1102 | # 1103 | 5200 lh.atr 255 255 102 0 1104 | 5201 lh.cab 153 204 0 0 1105 | 5202 lh.ccg 0 153 153 0 1106 | 5203 lh.cst 204 153 255 0 1107 | 5204 lh.ilf 255 153 51 0 1108 | 5205 lh.slfp 204 204 204 0 1109 | 5206 lh.slft 153 255 255 0 1110 | 5207 lh.unc 102 153 255 0 1111 | 5208 lh.cb 0 153 153 0 1112 | 5209 lh.slf 204 204 204 0 1113 | 5210 lh.af 153 255 255 0 1114 | 5211 lh.ifof 51 153 51 0 1115 | 5212 lh.fx 255 153 204 0 1116 | 5213 lh.fat 204 51 102 0 1117 | 5214 lh.or 153 102 255 0 1118 | 5215 lh.mlf 255 255 204 0 1119 | 5216 lh.slf1 51 204 255 0 1120 | 5217 lh.slf2 51 255 204 0 1121 | 5218 lh.slf3 204 204 204 0 1122 | 5219 lh.afd 153 255 255 0 1123 | 5220 lh.afv 153 255 255 0 1124 | 5221 lh.ar 153 0 204 0 1125 | 5222 lh.cbd 0 153 153 0 1126 | 5223 lh.cbv 153 204 0 0 1127 | 5224 lh.emc 51 153 51 0 1128 | 5225 lh.uf 102 153 255 0 1129 | # 1130 | 5300 rh.atr 255 255 102 0 1131 | 5301 rh.cab 153 204 0 0 1132 | 5302 rh.ccg 0 153 153 0 1133 | 5303 rh.cst 204 153 255 0 1134 | 5304 rh.ilf 255 153 51 0 1135 | 5305 rh.slfp 204 204 204 0 1136 | 5306 rh.slft 153 255 255 0 1137 | 5307 rh.unc 102 153 255 0 1138 | 5308 rh.cb 0 153 153 0 1139 | 5309 rh.slf 204 204 204 0 1140 | 5310 rh.af 153 255 255 0 1141 | 5311 rh.ifof 51 153 51 0 1142 | 5312 rh.fx 255 153 204 0 1143 | 5313 rh.fat 204 51 102 0 1144 | 5314 rh.or 153 102 255 0 1145 | 5315 rh.mlf 255 255 204 0 1146 | 5316 rh.slf1 51 204 255 0 1147 | 5317 rh.slf2 51 255 204 0 1148 | 5318 rh.slf3 204 204 204 0 1149 | 5319 rh.afd 153 255 255 0 1150 | 5320 rh.afv 153 255 255 0 1151 | 5321 rh.ar 153 0 204 0 1152 | 5322 rh.cbd 0 153 153 0 1153 | 5323 rh.cbv 153 204 0 0 1154 | 5324 rh.emc 51 153 51 0 1155 | 5325 rh.uf 102 153 255 0 1156 | 1157 | ######################################## 1158 | 1159 | 6000 CST-orig 0 255 0 0 1160 | 6001 CST-hammer 255 255 0 0 1161 | 6002 CST-CVS 0 255 255 0 1162 | 6003 CST-flirt 0 0 255 0 1163 | 1164 | 6010 Left-SLF1 236 16 231 0 1165 | 6020 Right-SLF1 237 18 232 0 1166 | 1167 | 6030 Left-SLF3 236 13 227 0 1168 | 6040 Right-SLF3 236 17 228 0 1169 | 1170 | 6050 Left-CST 1 255 1 0 1171 | 6060 Right-CST 2 255 1 0 1172 | 1173 | 6070 Left-SLF2 236 14 230 0 1174 | 6080 Right-SLF2 237 14 230 0 1175 | 1176 | #No. Label Name: R G B A 1177 | 1178 | 7001 Lateral-nucleus 72 132 181 0 1179 | 7002 Basolateral-nucleus 243 243 243 0 1180 | 7003 Basal-nucleus 207 63 79 0 1181 | 7004 Centromedial-nucleus 121 20 135 0 1182 | 7005 Central-nucleus 197 60 248 0 1183 | 7006 Medial-nucleus 2 149 2 0 1184 | 7007 Cortical-nucleus 221 249 166 0 1185 | 7008 Accessory-Basal-nucleus 232 146 35 0 1186 | 7009 Corticoamygdaloid-transitio 20 60 120 0 1187 | 7010 Anterior-amygdaloid-area-AAA 250 250 0 0 1188 | 7011 Fusion-amygdala-HP-FAH 122 187 222 0 1189 | 7012 Hippocampal-amygdala-transition-HATA 237 12 177 0 1190 | 7013 Endopiriform-nucleus 10 49 255 0 1191 | 7014 Lateral-nucleus-olfactory-tract 205 184 144 0 1192 | 7015 Paralaminar-nucleus 45 205 165 0 1193 | 7016 Intercalated-nucleus 117 160 175 0 1194 | 7017 Prepiriform-cortex 221 217 21 0 1195 | 7018 Periamygdaloid-cortex 20 60 120 0 1196 | 7019 Envelope-Amygdala 141 21 100 0 1197 | 7020 Extranuclear-Amydala 225 140 141 0 1198 | 1199 | 7100 Brainstem-inferior-colliculus 42 201 168 0 1200 | 7101 Brainstem-cochlear-nucleus 168 104 162 0 1201 | 1202 | 7201 DR 121 255 250 0 1203 | 7202 MnR 0 255 0 0 1204 | 7203 PAG 153 153 255 0 1205 | 7204 VTA 255 0 255 0 1206 | 1207 | # replaced by 75 1208 | #7301 Left-LC 0 0 255 0 1209 | 7302 Left-LDTg 255 127 0 0 1210 | 7303 Left-mRt 255 0 0 0 1211 | 7304 Left-PBC 255 255 0 0 1212 | 7305 Left-PnO 0 127 255 0 1213 | 7306 Left-PTg 127 0 255 0 1214 | 1215 | # replaced by 76 1216 | #7401 Right-LC 0 0 255 0 1217 | 7402 Right-LDTg 255 127 0 0 1218 | 7403 Right-mRt 255 0 0 0 1219 | 7404 Right-PBC 255 255 0 0 1220 | 7405 Right-PnO 0 127 255 0 1221 | 7406 Right-PTg 127 0 255 0 1222 | 1223 | 8001 Thalamus-Anterior 74 130 181 0 1224 | 8002 Thalamus-Ventral-anterior 242 241 240 0 1225 | 8003 Thalamus-Lateral-dorsal 206 65 78 0 1226 | 8004 Thalamus-Lateral-posterior 120 21 133 0 1227 | 8005 Thalamus-Ventral-lateral 195 61 246 0 1228 | 8006 Thalamus-Ventral-posterior-medial 3 147 6 0 1229 | 8007 Thalamus-Ventral-posterior-lateral 220 251 163 0 1230 | 8008 Thalamus-intralaminar 232 146 33 0 1231 | 8009 Thalamus-centromedian 4 114 14 0 1232 | 8010 Thalamus-mediodorsal 121 184 220 0 1233 | 8011 Thalamus-medial 235 11 175 0 1234 | 8012 Thalamus-pulvinar 12 46 250 0 1235 | 8013 Thalamus-lateral-geniculate 203 182 143 0 1236 | 8014 Thalamus-medial-geniculate 42 204 167 0 1237 | 1238 | 1239 | 1240 | # 1241 | # Labels for thalamus parcellation using histological atlas (Iglesias et al.) 1242 | # 1243 | 1244 | 8103 Left-AV 0 85 0 0 1245 | 8104 Left-CeM 170 85 0 0 1246 | 8105 Left-CL 0 170 0 0 1247 | 8106 Left-CM 170 170 0 0 1248 | 8108 Left-LD 170 255 0 0 1249 | 8109 Left-LGN 0 0 127 0 1250 | 8110 Left-LP 0 85 127 0 1251 | 8111 Left-L-Sg 170 85 127 0 1252 | 8112 Left-MDl 0 170 127 0 1253 | 8113 Left-MDm 170 170 127 0 1254 | 8115 Left-MGN 170 255 127 0 1255 | 8116 Left-MV(Re) 0 0 255 0 1256 | 8117 Left-Pc 170 0 255 0 1257 | 8118 Left-Pf 0 85 255 0 1258 | 8119 Left-Pt 170 85 255 0 1259 | 8120 Left-PuA 0 170 255 0 1260 | 8121 Left-PuI 170 170 255 0 1261 | 8122 Left-PuL 0 255 255 0 1262 | 8123 Left-PuM 170 255 255 0 1263 | 8125 Left-R 255 0 0 0 1264 | 8126 Left-VA 85 85 0 0 1265 | 8127 Left-VAmc 255 85 0 0 1266 | 8128 Left-VLa 85 170 0 0 1267 | 8129 Left-VLp 255 170 0 0 1268 | 8130 Left-VM 85 255 0 0 1269 | 8133 Left-VPL 255 0 255 0 1270 | 8134 Left-PaV 120 18 134 0 1271 | 8135 Left-PuMm 170 255 255 0 1272 | 8136 Left-PuMl 140 240 255 0 1273 | 1274 | 8203 Right-AV 0 85 0 0 1275 | 8204 Right-CeM 170 85 0 0 1276 | 8205 Right-CL 0 170 0 0 1277 | 8206 Right-CM 170 170 0 0 1278 | 8208 Right-LD 170 255 0 0 1279 | 8209 Right-LGN 0 0 127 0 1280 | 8210 Right-LP 0 85 127 0 1281 | 8211 Right-L-Sg 170 85 127 0 1282 | 8212 Right-MDl 0 170 127 0 1283 | 8213 Right-MDm 170 170 127 0 1284 | 8215 Right-MGN 170 255 127 0 1285 | 8216 Right-MV(Re) 0 0 255 0 1286 | 8217 Right-Pc 170 0 255 0 1287 | 8218 Right-Pf 0 85 255 0 1288 | 8219 Right-Pt 170 85 255 0 1289 | 8220 Right-PuA 0 170 255 0 1290 | 8221 Right-PuI 170 170 255 0 1291 | 8222 Right-PuL 0 255 255 0 1292 | 8223 Right-PuM 170 255 255 0 1293 | 8225 Right-R 255 0 0 0 1294 | 8226 Right-VA 85 85 0 0 1295 | 8227 Right-VAmc 255 85 0 0 1296 | 8228 Right-VLa 85 170 0 0 1297 | 8229 Right-VLp 255 170 0 0 1298 | 8230 Right-VM 85 255 0 0 1299 | 8233 Right-VPL 255 0 255 0 1300 | 8234 Right-PaV 120 18 134 0 1301 | 8235 Right-PuMm 170 255 255 0 1302 | 8236 Right-PuMl 140 240 255 0 1303 | 1304 | # 1305 | # Labels for thalamus parcellation using probabilistic tractography. See: 1306 | # Functional--Anatomical Validation and Individual Variation of Diffusion 1307 | # Tractography-based Segmentation of the Human Thalamus; Cerebral Cortex 1308 | # January 2005;15:31--39, doi:10.1093/cercor/bhh105, Advance Access 1309 | # publication July 6, 2004 1310 | # 1311 | 1312 | #No. Label Name: R G B A 1313 | 9000 ctx-lh-prefrontal 50 100 30 0 1314 | 9001 ctx-lh-primary-motor 30 100 45 0 1315 | 9002 ctx-lh-premotor 130 100 165 0 1316 | 9003 ctx-lh-temporal 105 25 5 0 1317 | 9004 ctx-lh-posterior-parietal 125 70 55 0 1318 | 9005 ctx-lh-prim-sec-somatosensory 225 20 105 0 1319 | 9006 ctx-lh-occipital 225 20 15 0 1320 | 1321 | 9500 ctx-rh-prefrontal 50 200 30 0 1322 | 9501 ctx-rh-primary-motor 30 150 45 0 1323 | 9502 ctx-rh-premotor 130 150 165 0 1324 | 9503 ctx-rh-temporal 105 75 5 0 1325 | 9504 ctx-rh-posterior-parietal 125 120 55 0 1326 | 9505 ctx-rh-prim-sec-somatosensory 225 70 105 0 1327 | 9506 ctx-rh-occipital 225 70 15 0 1328 | 1329 | # Below is the color table for the cortical labels of the seg volume 1330 | # created by mri_aparc2aseg (with --a2009s flag) in which the aseg 1331 | # cortex label is replaced by the labels in the aparc.a2009s. The 1332 | # cortical labels are the same as in Simple_surface_labels2009.txt, 1333 | # except that left hemisphere has 11100 added to the index and the 1334 | # right has 12100 added. The label names are also prepended with 1335 | # ctx_lh_, ctx_rh_, wm_lh_ and wm_rh_ (note usage of _ instead of - 1336 | # to differentiate from a2005s labels). 1337 | 1338 | #No. Label Name: R G B A 1339 | 11100 ctx_lh_Unknown 0 0 0 0 1340 | 11101 ctx_lh_G_and_S_frontomargin 23 220 60 0 1341 | 11102 ctx_lh_G_and_S_occipital_inf 23 60 180 0 1342 | 11103 ctx_lh_G_and_S_paracentral 63 100 60 0 1343 | 11104 ctx_lh_G_and_S_subcentral 63 20 220 0 1344 | 11105 ctx_lh_G_and_S_transv_frontopol 13 0 250 0 1345 | 11106 ctx_lh_G_and_S_cingul-Ant 26 60 0 0 1346 | 11107 ctx_lh_G_and_S_cingul-Mid-Ant 26 60 75 0 1347 | 11108 ctx_lh_G_and_S_cingul-Mid-Post 26 60 150 0 1348 | 11109 ctx_lh_G_cingul-Post-dorsal 25 60 250 0 1349 | 11110 ctx_lh_G_cingul-Post-ventral 60 25 25 0 1350 | 11111 ctx_lh_G_cuneus 180 20 20 0 1351 | 11112 ctx_lh_G_front_inf-Opercular 220 20 100 0 1352 | 11113 ctx_lh_G_front_inf-Orbital 140 60 60 0 1353 | 11114 ctx_lh_G_front_inf-Triangul 180 220 140 0 1354 | 11115 ctx_lh_G_front_middle 140 100 180 0 1355 | 11116 ctx_lh_G_front_sup 180 20 140 0 1356 | 11117 ctx_lh_G_Ins_lg_and_S_cent_ins 23 10 10 0 1357 | 11118 ctx_lh_G_insular_short 225 140 140 0 1358 | 11119 ctx_lh_G_occipital_middle 180 60 180 0 1359 | 11120 ctx_lh_G_occipital_sup 20 220 60 0 1360 | 11121 ctx_lh_G_oc-temp_lat-fusifor 60 20 140 0 1361 | 11122 ctx_lh_G_oc-temp_med-Lingual 220 180 140 0 1362 | 11123 ctx_lh_G_oc-temp_med-Parahip 65 100 20 0 1363 | 11124 ctx_lh_G_orbital 220 60 20 0 1364 | 11125 ctx_lh_G_pariet_inf-Angular 20 60 220 0 1365 | 11126 ctx_lh_G_pariet_inf-Supramar 100 100 60 0 1366 | 11127 ctx_lh_G_parietal_sup 220 180 220 0 1367 | 11128 ctx_lh_G_postcentral 20 180 140 0 1368 | 11129 ctx_lh_G_precentral 60 140 180 0 1369 | 11130 ctx_lh_G_precuneus 25 20 140 0 1370 | 11131 ctx_lh_G_rectus 20 60 100 0 1371 | 11132 ctx_lh_G_subcallosal 60 220 20 0 1372 | 11133 ctx_lh_G_temp_sup-G_T_transv 60 60 220 0 1373 | 11134 ctx_lh_G_temp_sup-Lateral 220 60 220 0 1374 | 11135 ctx_lh_G_temp_sup-Plan_polar 65 220 60 0 1375 | 11136 ctx_lh_G_temp_sup-Plan_tempo 25 140 20 0 1376 | 11137 ctx_lh_G_temporal_inf 220 220 100 0 1377 | 11138 ctx_lh_G_temporal_middle 180 60 60 0 1378 | 11139 ctx_lh_Lat_Fis-ant-Horizont 61 20 220 0 1379 | 11140 ctx_lh_Lat_Fis-ant-Vertical 61 20 60 0 1380 | 11141 ctx_lh_Lat_Fis-post 61 60 100 0 1381 | 11142 ctx_lh_Medial_wall 25 25 25 0 1382 | 11143 ctx_lh_Pole_occipital 140 20 60 0 1383 | 11144 ctx_lh_Pole_temporal 220 180 20 0 1384 | 11145 ctx_lh_S_calcarine 63 180 180 0 1385 | 11146 ctx_lh_S_central 221 20 10 0 1386 | 11147 ctx_lh_S_cingul-Marginalis 221 20 100 0 1387 | 11148 ctx_lh_S_circular_insula_ant 221 60 140 0 1388 | 11149 ctx_lh_S_circular_insula_inf 221 20 220 0 1389 | 11150 ctx_lh_S_circular_insula_sup 61 220 220 0 1390 | 11151 ctx_lh_S_collat_transv_ant 100 200 200 0 1391 | 11152 ctx_lh_S_collat_transv_post 10 200 200 0 1392 | 11153 ctx_lh_S_front_inf 221 220 20 0 1393 | 11154 ctx_lh_S_front_middle 141 20 100 0 1394 | 11155 ctx_lh_S_front_sup 61 220 100 0 1395 | 11156 ctx_lh_S_interm_prim-Jensen 141 60 20 0 1396 | 11157 ctx_lh_S_intrapariet_and_P_trans 143 20 220 0 1397 | 11158 ctx_lh_S_oc_middle_and_Lunatus 101 60 220 0 1398 | 11159 ctx_lh_S_oc_sup_and_transversal 21 20 140 0 1399 | 11160 ctx_lh_S_occipital_ant 61 20 180 0 1400 | 11161 ctx_lh_S_oc-temp_lat 221 140 20 0 1401 | 11162 ctx_lh_S_oc-temp_med_and_Lingual 141 100 220 0 1402 | 11163 ctx_lh_S_orbital_lateral 221 100 20 0 1403 | 11164 ctx_lh_S_orbital_med-olfact 181 200 20 0 1404 | 11165 ctx_lh_S_orbital-H_Shaped 101 20 20 0 1405 | 11166 ctx_lh_S_parieto_occipital 101 100 180 0 1406 | 11167 ctx_lh_S_pericallosal 181 220 20 0 1407 | 11168 ctx_lh_S_postcentral 21 140 200 0 1408 | 11169 ctx_lh_S_precentral-inf-part 21 20 240 0 1409 | 11170 ctx_lh_S_precentral-sup-part 21 20 200 0 1410 | 11171 ctx_lh_S_suborbital 21 20 60 0 1411 | 11172 ctx_lh_S_subparietal 101 60 60 0 1412 | 11173 ctx_lh_S_temporal_inf 21 180 180 0 1413 | 11174 ctx_lh_S_temporal_sup 223 220 60 0 1414 | 11175 ctx_lh_S_temporal_transverse 221 60 60 0 1415 | 11300 ctx_lh_high_myelin 60 162 60 0 1416 | 1417 | 12100 ctx_rh_Unknown 0 0 0 0 1418 | 12101 ctx_rh_G_and_S_frontomargin 23 220 60 0 1419 | 12102 ctx_rh_G_and_S_occipital_inf 23 60 180 0 1420 | 12103 ctx_rh_G_and_S_paracentral 63 100 60 0 1421 | 12104 ctx_rh_G_and_S_subcentral 63 20 220 0 1422 | 12105 ctx_rh_G_and_S_transv_frontopol 13 0 250 0 1423 | 12106 ctx_rh_G_and_S_cingul-Ant 26 60 0 0 1424 | 12107 ctx_rh_G_and_S_cingul-Mid-Ant 26 60 75 0 1425 | 12108 ctx_rh_G_and_S_cingul-Mid-Post 26 60 150 0 1426 | 12109 ctx_rh_G_cingul-Post-dorsal 25 60 250 0 1427 | 12110 ctx_rh_G_cingul-Post-ventral 60 25 25 0 1428 | 12111 ctx_rh_G_cuneus 180 20 20 0 1429 | 12112 ctx_rh_G_front_inf-Opercular 220 20 100 0 1430 | 12113 ctx_rh_G_front_inf-Orbital 140 60 60 0 1431 | 12114 ctx_rh_G_front_inf-Triangul 180 220 140 0 1432 | 12115 ctx_rh_G_front_middle 140 100 180 0 1433 | 12116 ctx_rh_G_front_sup 180 20 140 0 1434 | 12117 ctx_rh_G_Ins_lg_and_S_cent_ins 23 10 10 0 1435 | 12118 ctx_rh_G_insular_short 225 140 140 0 1436 | 12119 ctx_rh_G_occipital_middle 180 60 180 0 1437 | 12120 ctx_rh_G_occipital_sup 20 220 60 0 1438 | 12121 ctx_rh_G_oc-temp_lat-fusifor 60 20 140 0 1439 | 12122 ctx_rh_G_oc-temp_med-Lingual 220 180 140 0 1440 | 12123 ctx_rh_G_oc-temp_med-Parahip 65 100 20 0 1441 | 12124 ctx_rh_G_orbital 220 60 20 0 1442 | 12125 ctx_rh_G_pariet_inf-Angular 20 60 220 0 1443 | 12126 ctx_rh_G_pariet_inf-Supramar 100 100 60 0 1444 | 12127 ctx_rh_G_parietal_sup 220 180 220 0 1445 | 12128 ctx_rh_G_postcentral 20 180 140 0 1446 | 12129 ctx_rh_G_precentral 60 140 180 0 1447 | 12130 ctx_rh_G_precuneus 25 20 140 0 1448 | 12131 ctx_rh_G_rectus 20 60 100 0 1449 | 12132 ctx_rh_G_subcallosal 60 220 20 0 1450 | 12133 ctx_rh_G_temp_sup-G_T_transv 60 60 220 0 1451 | 12134 ctx_rh_G_temp_sup-Lateral 220 60 220 0 1452 | 12135 ctx_rh_G_temp_sup-Plan_polar 65 220 60 0 1453 | 12136 ctx_rh_G_temp_sup-Plan_tempo 25 140 20 0 1454 | 12137 ctx_rh_G_temporal_inf 220 220 100 0 1455 | 12138 ctx_rh_G_temporal_middle 180 60 60 0 1456 | 12139 ctx_rh_Lat_Fis-ant-Horizont 61 20 220 0 1457 | 12140 ctx_rh_Lat_Fis-ant-Vertical 61 20 60 0 1458 | 12141 ctx_rh_Lat_Fis-post 61 60 100 0 1459 | 12142 ctx_rh_Medial_wall 25 25 25 0 1460 | 12143 ctx_rh_Pole_occipital 140 20 60 0 1461 | 12144 ctx_rh_Pole_temporal 220 180 20 0 1462 | 12145 ctx_rh_S_calcarine 63 180 180 0 1463 | 12146 ctx_rh_S_central 221 20 10 0 1464 | 12147 ctx_rh_S_cingul-Marginalis 221 20 100 0 1465 | 12148 ctx_rh_S_circular_insula_ant 221 60 140 0 1466 | 12149 ctx_rh_S_circular_insula_inf 221 20 220 0 1467 | 12150 ctx_rh_S_circular_insula_sup 61 220 220 0 1468 | 12151 ctx_rh_S_collat_transv_ant 100 200 200 0 1469 | 12152 ctx_rh_S_collat_transv_post 10 200 200 0 1470 | 12153 ctx_rh_S_front_inf 221 220 20 0 1471 | 12154 ctx_rh_S_front_middle 141 20 100 0 1472 | 12155 ctx_rh_S_front_sup 61 220 100 0 1473 | 12156 ctx_rh_S_interm_prim-Jensen 141 60 20 0 1474 | 12157 ctx_rh_S_intrapariet_and_P_trans 143 20 220 0 1475 | 12158 ctx_rh_S_oc_middle_and_Lunatus 101 60 220 0 1476 | 12159 ctx_rh_S_oc_sup_and_transversal 21 20 140 0 1477 | 12160 ctx_rh_S_occipital_ant 61 20 180 0 1478 | 12161 ctx_rh_S_oc-temp_lat 221 140 20 0 1479 | 12162 ctx_rh_S_oc-temp_med_and_Lingual 141 100 220 0 1480 | 12163 ctx_rh_S_orbital_lateral 221 100 20 0 1481 | 12164 ctx_rh_S_orbital_med-olfact 181 200 20 0 1482 | 12165 ctx_rh_S_orbital-H_Shaped 101 20 20 0 1483 | 12166 ctx_rh_S_parieto_occipital 101 100 180 0 1484 | 12167 ctx_rh_S_pericallosal 181 220 20 0 1485 | 12168 ctx_rh_S_postcentral 21 140 200 0 1486 | 12169 ctx_rh_S_precentral-inf-part 21 20 240 0 1487 | 12170 ctx_rh_S_precentral-sup-part 21 20 200 0 1488 | 12171 ctx_rh_S_suborbital 21 20 60 0 1489 | 12172 ctx_rh_S_subparietal 101 60 60 0 1490 | 12173 ctx_rh_S_temporal_inf 21 180 180 0 1491 | 12174 ctx_rh_S_temporal_sup 223 220 60 0 1492 | 12175 ctx_rh_S_temporal_transverse 221 60 60 0 1493 | 12300 ctx_rh_high_myelin 60 200 60 0 1494 | 1495 | #No. Label Name: R G B A 1496 | 13100 wm_lh_Unknown 0 0 0 0 1497 | 13101 wm_lh_G_and_S_frontomargin 23 220 60 0 1498 | 13102 wm_lh_G_and_S_occipital_inf 23 60 180 0 1499 | 13103 wm_lh_G_and_S_paracentral 63 100 60 0 1500 | 13104 wm_lh_G_and_S_subcentral 63 20 220 0 1501 | 13105 wm_lh_G_and_S_transv_frontopol 13 0 250 0 1502 | 13106 wm_lh_G_and_S_cingul-Ant 26 60 0 0 1503 | 13107 wm_lh_G_and_S_cingul-Mid-Ant 26 60 75 0 1504 | 13108 wm_lh_G_and_S_cingul-Mid-Post 26 60 150 0 1505 | 13109 wm_lh_G_cingul-Post-dorsal 25 60 250 0 1506 | 13110 wm_lh_G_cingul-Post-ventral 60 25 25 0 1507 | 13111 wm_lh_G_cuneus 180 20 20 0 1508 | 13112 wm_lh_G_front_inf-Opercular 220 20 100 0 1509 | 13113 wm_lh_G_front_inf-Orbital 140 60 60 0 1510 | 13114 wm_lh_G_front_inf-Triangul 180 220 140 0 1511 | 13115 wm_lh_G_front_middle 140 100 180 0 1512 | 13116 wm_lh_G_front_sup 180 20 140 0 1513 | 13117 wm_lh_G_Ins_lg_and_S_cent_ins 23 10 10 0 1514 | 13118 wm_lh_G_insular_short 225 140 140 0 1515 | 13119 wm_lh_G_occipital_middle 180 60 180 0 1516 | 13120 wm_lh_G_occipital_sup 20 220 60 0 1517 | 13121 wm_lh_G_oc-temp_lat-fusifor 60 20 140 0 1518 | 13122 wm_lh_G_oc-temp_med-Lingual 220 180 140 0 1519 | 13123 wm_lh_G_oc-temp_med-Parahip 65 100 20 0 1520 | 13124 wm_lh_G_orbital 220 60 20 0 1521 | 13125 wm_lh_G_pariet_inf-Angular 20 60 220 0 1522 | 13126 wm_lh_G_pariet_inf-Supramar 100 100 60 0 1523 | 13127 wm_lh_G_parietal_sup 220 180 220 0 1524 | 13128 wm_lh_G_postcentral 20 180 140 0 1525 | 13129 wm_lh_G_precentral 60 140 180 0 1526 | 13130 wm_lh_G_precuneus 25 20 140 0 1527 | 13131 wm_lh_G_rectus 20 60 100 0 1528 | 13132 wm_lh_G_subcallosal 60 220 20 0 1529 | 13133 wm_lh_G_temp_sup-G_T_transv 60 60 220 0 1530 | 13134 wm_lh_G_temp_sup-Lateral 220 60 220 0 1531 | 13135 wm_lh_G_temp_sup-Plan_polar 65 220 60 0 1532 | 13136 wm_lh_G_temp_sup-Plan_tempo 25 140 20 0 1533 | 13137 wm_lh_G_temporal_inf 220 220 100 0 1534 | 13138 wm_lh_G_temporal_middle 180 60 60 0 1535 | 13139 wm_lh_Lat_Fis-ant-Horizont 61 20 220 0 1536 | 13140 wm_lh_Lat_Fis-ant-Vertical 61 20 60 0 1537 | 13141 wm_lh_Lat_Fis-post 61 60 100 0 1538 | 13142 wm_lh_Medial_wall 25 25 25 0 1539 | 13143 wm_lh_Pole_occipital 140 20 60 0 1540 | 13144 wm_lh_Pole_temporal 220 180 20 0 1541 | 13145 wm_lh_S_calcarine 63 180 180 0 1542 | 13146 wm_lh_S_central 221 20 10 0 1543 | 13147 wm_lh_S_cingul-Marginalis 221 20 100 0 1544 | 13148 wm_lh_S_circular_insula_ant 221 60 140 0 1545 | 13149 wm_lh_S_circular_insula_inf 221 20 220 0 1546 | 13150 wm_lh_S_circular_insula_sup 61 220 220 0 1547 | 13151 wm_lh_S_collat_transv_ant 100 200 200 0 1548 | 13152 wm_lh_S_collat_transv_post 10 200 200 0 1549 | 13153 wm_lh_S_front_inf 221 220 20 0 1550 | 13154 wm_lh_S_front_middle 141 20 100 0 1551 | 13155 wm_lh_S_front_sup 61 220 100 0 1552 | 13156 wm_lh_S_interm_prim-Jensen 141 60 20 0 1553 | 13157 wm_lh_S_intrapariet_and_P_trans 143 20 220 0 1554 | 13158 wm_lh_S_oc_middle_and_Lunatus 101 60 220 0 1555 | 13159 wm_lh_S_oc_sup_and_transversal 21 20 140 0 1556 | 13160 wm_lh_S_occipital_ant 61 20 180 0 1557 | 13161 wm_lh_S_oc-temp_lat 221 140 20 0 1558 | 13162 wm_lh_S_oc-temp_med_and_Lingual 141 100 220 0 1559 | 13163 wm_lh_S_orbital_lateral 221 100 20 0 1560 | 13164 wm_lh_S_orbital_med-olfact 181 200 20 0 1561 | 13165 wm_lh_S_orbital-H_Shaped 101 20 20 0 1562 | 13166 wm_lh_S_parieto_occipital 101 100 180 0 1563 | 13167 wm_lh_S_pericallosal 181 220 20 0 1564 | 13168 wm_lh_S_postcentral 21 140 200 0 1565 | 13169 wm_lh_S_precentral-inf-part 21 20 240 0 1566 | 13170 wm_lh_S_precentral-sup-part 21 20 200 0 1567 | 13171 wm_lh_S_suborbital 21 20 60 0 1568 | 13172 wm_lh_S_subparietal 101 60 60 0 1569 | 13173 wm_lh_S_temporal_inf 21 180 180 0 1570 | 13174 wm_lh_S_temporal_sup 223 220 60 0 1571 | 13175 wm_lh_S_temporal_transverse 221 60 60 0 1572 | 1573 | 14100 wm_rh_Unknown 0 0 0 0 1574 | 14101 wm_rh_G_and_S_frontomargin 23 220 60 0 1575 | 14102 wm_rh_G_and_S_occipital_inf 23 60 180 0 1576 | 14103 wm_rh_G_and_S_paracentral 63 100 60 0 1577 | 14104 wm_rh_G_and_S_subcentral 63 20 220 0 1578 | 14105 wm_rh_G_and_S_transv_frontopol 13 0 250 0 1579 | 14106 wm_rh_G_and_S_cingul-Ant 26 60 0 0 1580 | 14107 wm_rh_G_and_S_cingul-Mid-Ant 26 60 75 0 1581 | 14108 wm_rh_G_and_S_cingul-Mid-Post 26 60 150 0 1582 | 14109 wm_rh_G_cingul-Post-dorsal 25 60 250 0 1583 | 14110 wm_rh_G_cingul-Post-ventral 60 25 25 0 1584 | 14111 wm_rh_G_cuneus 180 20 20 0 1585 | 14112 wm_rh_G_front_inf-Opercular 220 20 100 0 1586 | 14113 wm_rh_G_front_inf-Orbital 140 60 60 0 1587 | 14114 wm_rh_G_front_inf-Triangul 180 220 140 0 1588 | 14115 wm_rh_G_front_middle 140 100 180 0 1589 | 14116 wm_rh_G_front_sup 180 20 140 0 1590 | 14117 wm_rh_G_Ins_lg_and_S_cent_ins 23 10 10 0 1591 | 14118 wm_rh_G_insular_short 225 140 140 0 1592 | 14119 wm_rh_G_occipital_middle 180 60 180 0 1593 | 14120 wm_rh_G_occipital_sup 20 220 60 0 1594 | 14121 wm_rh_G_oc-temp_lat-fusifor 60 20 140 0 1595 | 14122 wm_rh_G_oc-temp_med-Lingual 220 180 140 0 1596 | 14123 wm_rh_G_oc-temp_med-Parahip 65 100 20 0 1597 | 14124 wm_rh_G_orbital 220 60 20 0 1598 | 14125 wm_rh_G_pariet_inf-Angular 20 60 220 0 1599 | 14126 wm_rh_G_pariet_inf-Supramar 100 100 60 0 1600 | 14127 wm_rh_G_parietal_sup 220 180 220 0 1601 | 14128 wm_rh_G_postcentral 20 180 140 0 1602 | 14129 wm_rh_G_precentral 60 140 180 0 1603 | 14130 wm_rh_G_precuneus 25 20 140 0 1604 | 14131 wm_rh_G_rectus 20 60 100 0 1605 | 14132 wm_rh_G_subcallosal 60 220 20 0 1606 | 14133 wm_rh_G_temp_sup-G_T_transv 60 60 220 0 1607 | 14134 wm_rh_G_temp_sup-Lateral 220 60 220 0 1608 | 14135 wm_rh_G_temp_sup-Plan_polar 65 220 60 0 1609 | 14136 wm_rh_G_temp_sup-Plan_tempo 25 140 20 0 1610 | 14137 wm_rh_G_temporal_inf 220 220 100 0 1611 | 14138 wm_rh_G_temporal_middle 180 60 60 0 1612 | 14139 wm_rh_Lat_Fis-ant-Horizont 61 20 220 0 1613 | 14140 wm_rh_Lat_Fis-ant-Vertical 61 20 60 0 1614 | 14141 wm_rh_Lat_Fis-post 61 60 100 0 1615 | 14142 wm_rh_Medial_wall 25 25 25 0 1616 | 14143 wm_rh_Pole_occipital 140 20 60 0 1617 | 14144 wm_rh_Pole_temporal 220 180 20 0 1618 | 14145 wm_rh_S_calcarine 63 180 180 0 1619 | 14146 wm_rh_S_central 221 20 10 0 1620 | 14147 wm_rh_S_cingul-Marginalis 221 20 100 0 1621 | 14148 wm_rh_S_circular_insula_ant 221 60 140 0 1622 | 14149 wm_rh_S_circular_insula_inf 221 20 220 0 1623 | 14150 wm_rh_S_circular_insula_sup 61 220 220 0 1624 | 14151 wm_rh_S_collat_transv_ant 100 200 200 0 1625 | 14152 wm_rh_S_collat_transv_post 10 200 200 0 1626 | 14153 wm_rh_S_front_inf 221 220 20 0 1627 | 14154 wm_rh_S_front_middle 141 20 100 0 1628 | 14155 wm_rh_S_front_sup 61 220 100 0 1629 | 14156 wm_rh_S_interm_prim-Jensen 141 60 20 0 1630 | 14157 wm_rh_S_intrapariet_and_P_trans 143 20 220 0 1631 | 14158 wm_rh_S_oc_middle_and_Lunatus 101 60 220 0 1632 | 14159 wm_rh_S_oc_sup_and_transversal 21 20 140 0 1633 | 14160 wm_rh_S_occipital_ant 61 20 180 0 1634 | 14161 wm_rh_S_oc-temp_lat 221 140 20 0 1635 | 14162 wm_rh_S_oc-temp_med_and_Lingual 141 100 220 0 1636 | 14163 wm_rh_S_orbital_lateral 221 100 20 0 1637 | 14164 wm_rh_S_orbital_med-olfact 181 200 20 0 1638 | 14165 wm_rh_S_orbital-H_Shaped 101 20 20 0 1639 | 14166 wm_rh_S_parieto_occipital 101 100 180 0 1640 | 14167 wm_rh_S_pericallosal 181 220 20 0 1641 | 14168 wm_rh_S_postcentral 21 140 200 0 1642 | 14169 wm_rh_S_precentral-inf-part 21 20 240 0 1643 | 14170 wm_rh_S_precentral-sup-part 21 20 200 0 1644 | 14171 wm_rh_S_suborbital 21 20 60 0 1645 | 14172 wm_rh_S_subparietal 101 60 60 0 1646 | 14173 wm_rh_S_temporal_inf 21 180 180 0 1647 | 14174 wm_rh_S_temporal_sup 223 220 60 0 1648 | 14175 wm_rh_S_temporal_transverse 221 60 60 0 1649 | 1650 | -------------------------------------------------------------------------------- /resources/STREAM-4D_banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComaRecoveryLab/STREAM-4D/fa7923c4b2ca5277a1de43b97ddb111f673cf8c3/resources/STREAM-4D_banner.jpg -------------------------------------------------------------------------------- /resources/STREAM-4D_premotor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComaRecoveryLab/STREAM-4D/fa7923c4b2ca5277a1de43b97ddb111f673cf8c3/resources/STREAM-4D_premotor.gif -------------------------------------------------------------------------------- /resources/aseg_labels.json: -------------------------------------------------------------------------------- 1 | { 2 | "Cerebral-Exterior": [ 3 | "1", 4 | "40" 5 | ], 6 | "Cerebral-White-Matter": [ 7 | "2", 8 | "41" 9 | ], 10 | "Cerebral-Cortex": [ 11 | "3", 12 | "42" 13 | ], 14 | "Lateral-Ventricle": [ 15 | "4", 16 | "43" 17 | ], 18 | "Inf-Lat-Vent": [ 19 | "5", 20 | "44" 21 | ], 22 | "Cerebellum-Exterior": [ 23 | "6", 24 | "45" 25 | ], 26 | "Cerebellum-White-Matter": [ 27 | "7", 28 | "46" 29 | ], 30 | "Cerebellum-Cortex": [ 31 | "8", 32 | "47" 33 | ], 34 | "Thalamus": [ 35 | "9", 36 | "48" 37 | ], 38 | "Thalamus-Proper": [ 39 | "10", 40 | "49" 41 | ], 42 | "Caudate": [ 43 | "11", 44 | "50" 45 | ], 46 | "Putamen": [ 47 | "12", 48 | "51" 49 | ], 50 | "Pallidum": [ 51 | "13", 52 | "52" 53 | ], 54 | "3rd-Ventricle": "14", 55 | "4th-Ventricle": "15", 56 | "Brain-Stem": "16", 57 | "Hippocampus": [ 58 | "17", 59 | "53" 60 | ], 61 | "Amygdala": [ 62 | "18", 63 | "54" 64 | ], 65 | "Insula": [ 66 | "19", 67 | "55" 68 | ], 69 | "Operculum": [ 70 | "20", 71 | "56" 72 | ], 73 | "CSF": "24", 74 | "Lesion": [ 75 | "25", 76 | "57" 77 | ], 78 | "Accumbens-area": [ 79 | "26", 80 | "58" 81 | ], 82 | "Substancia-Nigra": [ 83 | "27", 84 | "59" 85 | ], 86 | "VentralDC": [ 87 | "28", 88 | "60" 89 | ], 90 | "undetermined": [ 91 | "29", 92 | "61" 93 | ], 94 | "choroid-plexus": [ 95 | "31", 96 | "63" 97 | ], 98 | "Caudate/Putamen": [ 99 | "36", 100 | "137" 101 | ], 102 | "Stellate": [ 103 | "37", 104 | "69" 105 | ], 106 | "5th-Ventricle": "72", 107 | "Lateral-Ventricles": [ 108 | "75", 109 | "76" 110 | ], 111 | "F1": [ 112 | "83", 113 | "84" 114 | ], 115 | "Optic-Chiasm": "85", 116 | "Corpus_Callosum": "86", 117 | "Amygdala-Anterior": [ 118 | "96", 119 | "97" 120 | ], 121 | "Claustrum": [ 122 | "138", 123 | "139" 124 | ] 125 | } 126 | -------------------------------------------------------------------------------- /resources/fs_default.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2008-2021 the MRtrix3 contributors. 2 | # 3 | # This Source Code Form is subject to the terms of the Mozilla Public 4 | # License, v. 2.0. If a copy of the MPL was not distributed with this 5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | # 7 | # Covered Software is provided under this License on an "as is" 8 | # basis, without warranty of any kind, either expressed, implied, or 9 | # statutory, including, without limitation, warranties that the 10 | # Covered Software is free of defects, merchantable, fit for a 11 | # particular purpose or non-infringing. 12 | # See the Mozilla Public License v. 2.0 for more details. 13 | # 14 | # For more details, see http://www.mrtrix.org/. 15 | 16 | # Lookup table for extracting the relevant grey matter parcellations from the default FreeSurfer segmentation (desikan_killiany) 17 | 18 | 0 ??? Unknown 0 0 0 0 19 | 20 | 1 L.BSTS ctx-lh-bankssts 25 100 40 255 21 | 2 L.CACG ctx-lh-caudalanteriorcingulate 125 100 160 255 22 | 3 L.CMFG ctx-lh-caudalmiddlefrontal 100 25 0 255 23 | 4 L.CU ctx-lh-cuneus 220 20 100 255 24 | 5 L.EC ctx-lh-entorhinal 220 20 10 255 25 | 6 L.FG ctx-lh-fusiform 180 220 140 255 26 | 7 L.IPG ctx-lh-inferiorparietal 220 60 220 255 27 | 8 L.ITG ctx-lh-inferiortemporal 180 40 120 255 28 | 9 L.ICG ctx-lh-isthmuscingulate 140 20 140 255 29 | 10 L.LOG ctx-lh-lateraloccipital 20 30 140 255 30 | 11 L.LOFG ctx-lh-lateralorbitofrontal 35 75 50 255 31 | 12 L.LG ctx-lh-lingual 225 140 140 255 32 | 13 L.MOFG ctx-lh-medialorbitofrontal 200 35 75 255 33 | 14 L.MTG ctx-lh-middletemporal 160 100 50 255 34 | 15 L.PHIG ctx-lh-parahippocampal 20 220 60 255 35 | 16 L.PaCG ctx-lh-paracentral 60 220 60 255 36 | 17 L.POP ctx-lh-parsopercularis 220 180 140 255 37 | 18 L.POR ctx-lh-parsorbitalis 20 100 50 255 38 | 19 L.PTR ctx-lh-parstriangularis 220 60 20 255 39 | 20 L.PCAL ctx-lh-pericalcarine 120 100 60 255 40 | 21 L.PoCG ctx-lh-postcentral 220 20 20 255 41 | 22 L.PCG ctx-lh-posteriorcingulate 220 180 220 255 42 | 23 L.PrCG ctx-lh-precentral 60 20 220 255 43 | 24 L.PCU ctx-lh-precuneus 160 140 180 255 44 | 25 L.RACG ctx-lh-rostralanteriorcingulate 80 20 140 255 45 | 26 L.RMFG ctx-lh-rostralmiddlefrontal 75 50 125 255 46 | 27 L.SFG ctx-lh-superiorfrontal 20 220 160 255 47 | 28 L.SPG ctx-lh-superiorparietal 20 180 140 255 48 | 29 L.STG ctx-lh-superiortemporal 140 220 220 255 49 | 30 L.SMG ctx-lh-supramarginal 80 160 20 255 50 | 31 L.FP ctx-lh-frontalpole 100 0 100 255 51 | 32 L.TP ctx-lh-temporalpole 70 70 70 255 52 | 33 L.TTG ctx-lh-transversetemporal 150 150 200 255 53 | 34 L.IN ctx-lh-insula 255 192 32 255 54 | 55 | 35 L.CER Left-Cerebellum-Cortex 230 148 34 255 56 | 57 | 36 L.TH Left-Thalamus 0 118 14 255 58 | 37 L.CA Left-Caudate 122 186 220 255 59 | 38 L.PU Left-Putamen 236 13 176 255 60 | 39 L.PA Left-Pallidum 12 48 255 255 61 | 40 L.HI Left-Hippocampus 220 216 20 255 62 | 41 L.AM Left-Amygdala 103 255 255 255 63 | 42 L.AC Left-Accumbens-area 255 165 0 255 64 | 65 | 43 R.TH Right-Thalamus 0 118 14 255 66 | 44 R.CA Right-Caudate 122 186 220 255 67 | 45 R.PU Right-Putamen 236 13 176 255 68 | 46 R.PA Right-Pallidum 13 48 255 255 69 | 47 R.HI Right-Hippocampus 220 216 20 255 70 | 48 R.AM Right-Amygdala 103 255 255 255 71 | 49 R.AC Right-Accumbens-area 255 165 0 255 72 | 73 | 50 R.BSTS ctx-rh-bankssts 25 100 40 255 74 | 51 R.CACG ctx-rh-caudalanteriorcingulate 125 100 160 255 75 | 52 R.CMFG ctx-rh-caudalmiddlefrontal 100 25 0 255 76 | 53 R.CU ctx-rh-cuneus 220 20 100 255 77 | 54 R.EC ctx-rh-entorhinal 220 20 10 255 78 | 55 R.FG ctx-rh-fusiform 180 220 140 255 79 | 56 R.IPG ctx-rh-inferiorparietal 220 60 220 255 80 | 57 R.ITG ctx-rh-inferiortemporal 180 40 120 255 81 | 58 R.ICG ctx-rh-isthmuscingulate 140 20 140 255 82 | 59 R.LOG ctx-rh-lateraloccipital 20 30 140 255 83 | 60 R.LOFG ctx-rh-lateralorbitofrontal 35 75 50 255 84 | 61 R.LG ctx-rh-lingual 225 140 140 255 85 | 62 R.MOFG ctx-rh-medialorbitofrontal 200 35 75 255 86 | 63 R.MTG ctx-rh-middletemporal 160 100 50 255 87 | 64 R.PHIG ctx-rh-parahippocampal 20 220 60 255 88 | 65 R.PaCG ctx-rh-paracentral 60 220 60 255 89 | 66 R.POP ctx-rh-parsopercularis 220 180 140 255 90 | 67 R.POR ctx-rh-parsorbitalis 20 100 50 255 91 | 68 R.PTR ctx-rh-parstriangularis 220 60 20 255 92 | 69 R.PCAL ctx-rh-pericalcarine 120 100 60 255 93 | 70 R.PoCG ctx-rh-postcentral 220 20 20 255 94 | 71 R.PCG ctx-rh-posteriorcingulate 220 180 220 255 95 | 72 R.PrCG ctx-rh-precentral 60 20 220 255 96 | 73 R.PCU ctx-rh-precuneus 160 140 180 255 97 | 74 R.RACG ctx-rh-rostralanteriorcingulate 80 20 140 255 98 | 75 R.RMFG ctx-rh-rostralmiddlefrontal 75 50 125 255 99 | 76 R.SFG ctx-rh-superiorfrontal 20 220 160 255 100 | 77 R.SPG ctx-rh-superiorparietal 20 180 140 255 101 | 78 R.STG ctx-rh-superiortemporal 140 220 220 255 102 | 79 R.SMG ctx-rh-supramarginal 80 160 20 255 103 | 80 R.FP ctx-rh-frontalpole 100 0 100 255 104 | 81 R.TP ctx-rh-temporalpole 70 70 70 255 105 | 82 R.TTG ctx-rh-transversetemporal 150 150 200 255 106 | 83 R.IN ctx-rh-insula 255 192 32 255 107 | 108 | 84 R.CER Right-Cerebellum-Cortex 230 148 34 255 109 | 110 | -------------------------------------------------------------------------------- /resources/fs_label_luts.json: -------------------------------------------------------------------------------- 1 | { 2 | "ctx-lh-bankssts": [ 3 | 0.09803921568627451, 4 | 0.39215686274509803, 5 | 0.1568627450980392 6 | ], 7 | "ctx-lh-caudalanteriorcingulate": [ 8 | 0.49019607843137253, 9 | 0.39215686274509803, 10 | 0.6274509803921569 11 | ], 12 | "ctx-lh-caudalmiddlefrontal": [ 13 | 0.39215686274509803, 14 | 0.09803921568627451, 15 | 0.0 16 | ], 17 | "ctx-lh-cuneus": [ 18 | 0.8627450980392157, 19 | 0.0784313725490196, 20 | 0.39215686274509803 21 | ], 22 | "ctx-lh-entorhinal": [ 23 | 0.8627450980392157, 24 | 0.0784313725490196, 25 | 0.0392156862745098 26 | ], 27 | "ctx-lh-fusiform": [ 28 | 0.7058823529411765, 29 | 0.8627450980392157, 30 | 0.5490196078431373 31 | ], 32 | "ctx-lh-inferiorparietal": [ 33 | 0.8627450980392157, 34 | 0.23529411764705882, 35 | 0.8627450980392157 36 | ], 37 | "ctx-lh-inferiortemporal": [ 38 | 0.7058823529411765, 39 | 0.1568627450980392, 40 | 0.47058823529411764 41 | ], 42 | "ctx-lh-isthmuscingulate": [ 43 | 0.5490196078431373, 44 | 0.0784313725490196, 45 | 0.5490196078431373 46 | ], 47 | "ctx-lh-lateraloccipital": [ 48 | 0.0784313725490196, 49 | 0.11764705882352941, 50 | 0.5490196078431373 51 | ], 52 | "ctx-lh-lateralorbitofrontal": [ 53 | 0.13725490196078433, 54 | 0.29411764705882354, 55 | 0.19607843137254902 56 | ], 57 | "ctx-lh-lingual": [ 58 | 0.8823529411764706, 59 | 0.5490196078431373, 60 | 0.5490196078431373 61 | ], 62 | "ctx-lh-medialorbitofrontal": [ 63 | 0.7843137254901961, 64 | 0.13725490196078433, 65 | 0.29411764705882354 66 | ], 67 | "ctx-lh-middletemporal": [ 68 | 0.6274509803921569, 69 | 0.39215686274509803, 70 | 0.19607843137254902 71 | ], 72 | "ctx-lh-parahippocampal": [ 73 | 0.0784313725490196, 74 | 0.8627450980392157, 75 | 0.23529411764705882 76 | ], 77 | "ctx-lh-paracentral": [ 78 | 0.23529411764705882, 79 | 0.8627450980392157, 80 | 0.23529411764705882 81 | ], 82 | "ctx-lh-parsopercularis": [ 83 | 0.8627450980392157, 84 | 0.7058823529411765, 85 | 0.5490196078431373 86 | ], 87 | "ctx-lh-parsorbitalis": [ 88 | 0.0784313725490196, 89 | 0.39215686274509803, 90 | 0.19607843137254902 91 | ], 92 | "ctx-lh-parstriangularis": [ 93 | 0.8627450980392157, 94 | 0.23529411764705882, 95 | 0.0784313725490196 96 | ], 97 | "ctx-lh-pericalcarine": [ 98 | 0.47058823529411764, 99 | 0.39215686274509803, 100 | 0.23529411764705882 101 | ], 102 | "ctx-lh-postcentral": [ 103 | 0.8627450980392157, 104 | 0.0784313725490196, 105 | 0.0784313725490196 106 | ], 107 | "ctx-lh-posteriorcingulate": [ 108 | 0.8627450980392157, 109 | 0.7058823529411765, 110 | 0.8627450980392157 111 | ], 112 | "ctx-lh-precentral": [ 113 | 0.23529411764705882, 114 | 0.0784313725490196, 115 | 0.8627450980392157 116 | ], 117 | "ctx-lh-precuneus": [ 118 | 0.6274509803921569, 119 | 0.5490196078431373, 120 | 0.7058823529411765 121 | ], 122 | "ctx-lh-rostralanteriorcingulate": [ 123 | 0.3137254901960784, 124 | 0.0784313725490196, 125 | 0.5490196078431373 126 | ], 127 | "ctx-lh-rostralmiddlefrontal": [ 128 | 0.29411764705882354, 129 | 0.19607843137254902, 130 | 0.49019607843137253 131 | ], 132 | "ctx-lh-superiorfrontal": [ 133 | 0.0784313725490196, 134 | 0.8627450980392157, 135 | 0.6274509803921569 136 | ], 137 | "ctx-lh-superiorparietal": [ 138 | 0.0784313725490196, 139 | 0.7058823529411765, 140 | 0.5490196078431373 141 | ], 142 | "ctx-lh-superiortemporal": [ 143 | 0.5490196078431373, 144 | 0.8627450980392157, 145 | 0.8627450980392157 146 | ], 147 | "ctx-lh-supramarginal": [ 148 | 0.3137254901960784, 149 | 0.6274509803921569, 150 | 0.0784313725490196 151 | ], 152 | "ctx-lh-frontalpole": [ 153 | 0.39215686274509803, 154 | 0.0, 155 | 0.39215686274509803 156 | ], 157 | "ctx-lh-temporalpole": [ 158 | 0.27450980392156865, 159 | 0.27450980392156865, 160 | 0.27450980392156865 161 | ], 162 | "ctx-lh-transversetemporal": [ 163 | 0.5882352941176471, 164 | 0.5882352941176471, 165 | 0.7843137254901961 166 | ], 167 | "ctx-lh-insula": [ 168 | 1.0, 169 | 0.7529411764705882, 170 | 0.12549019607843137 171 | ], 172 | "Left-Cerebellum-Cortex": [ 173 | 0.9019607843137255, 174 | 0.5803921568627451, 175 | 0.13333333333333333 176 | ], 177 | "Left-Thalamus": [ 178 | 0.0, 179 | 0.4627450980392157, 180 | 0.054901960784313725 181 | ], 182 | "Left-Caudate": [ 183 | 0.47843137254901963, 184 | 0.7294117647058823, 185 | 0.8627450980392157 186 | ], 187 | "Left-Putamen": [ 188 | 0.9254901960784314, 189 | 0.050980392156862744, 190 | 0.6901960784313725 191 | ], 192 | "Left-Pallidum": [ 193 | 0.047058823529411764, 194 | 0.18823529411764706, 195 | 1.0 196 | ], 197 | "Left-Hippocampus": [ 198 | 0.8627450980392157, 199 | 0.8470588235294118, 200 | 0.0784313725490196 201 | ], 202 | "Left-Amygdala": [ 203 | 0.403921568627451, 204 | 1.0, 205 | 1.0 206 | ], 207 | "Left-Accumbens-area": [ 208 | 1.0, 209 | 0.6470588235294118, 210 | 0.0 211 | ], 212 | "Right-Thalamus": [ 213 | 0.0, 214 | 0.4627450980392157, 215 | 0.054901960784313725 216 | ], 217 | "Right-Caudate": [ 218 | 0.47843137254901963, 219 | 0.7294117647058823, 220 | 0.8627450980392157 221 | ], 222 | "Right-Putamen": [ 223 | 0.9254901960784314, 224 | 0.050980392156862744, 225 | 0.6901960784313725 226 | ], 227 | "Right-Pallidum": [ 228 | 0.050980392156862744, 229 | 0.18823529411764706, 230 | 1.0 231 | ], 232 | "Right-Hippocampus": [ 233 | 0.8627450980392157, 234 | 0.8470588235294118, 235 | 0.0784313725490196 236 | ], 237 | "Right-Amygdala": [ 238 | 0.403921568627451, 239 | 1.0, 240 | 1.0 241 | ], 242 | "Right-Accumbens-area": [ 243 | 1.0, 244 | 0.6470588235294118, 245 | 0.0 246 | ], 247 | "ctx-rh-bankssts": [ 248 | 0.09803921568627451, 249 | 0.39215686274509803, 250 | 0.1568627450980392 251 | ], 252 | "ctx-rh-caudalanteriorcingulate": [ 253 | 0.49019607843137253, 254 | 0.39215686274509803, 255 | 0.6274509803921569 256 | ], 257 | "ctx-rh-caudalmiddlefrontal": [ 258 | 0.39215686274509803, 259 | 0.09803921568627451, 260 | 0.0 261 | ], 262 | "ctx-rh-cuneus": [ 263 | 0.8627450980392157, 264 | 0.0784313725490196, 265 | 0.39215686274509803 266 | ], 267 | "ctx-rh-entorhinal": [ 268 | 0.8627450980392157, 269 | 0.0784313725490196, 270 | 0.0392156862745098 271 | ], 272 | "ctx-rh-fusiform": [ 273 | 0.7058823529411765, 274 | 0.8627450980392157, 275 | 0.5490196078431373 276 | ], 277 | "ctx-rh-inferiorparietal": [ 278 | 0.8627450980392157, 279 | 0.23529411764705882, 280 | 0.8627450980392157 281 | ], 282 | "ctx-rh-inferiortemporal": [ 283 | 0.7058823529411765, 284 | 0.1568627450980392, 285 | 0.47058823529411764 286 | ], 287 | "ctx-rh-isthmuscingulate": [ 288 | 0.5490196078431373, 289 | 0.0784313725490196, 290 | 0.5490196078431373 291 | ], 292 | "ctx-rh-lateraloccipital": [ 293 | 0.0784313725490196, 294 | 0.11764705882352941, 295 | 0.5490196078431373 296 | ], 297 | "ctx-rh-lateralorbitofrontal": [ 298 | 0.13725490196078433, 299 | 0.29411764705882354, 300 | 0.19607843137254902 301 | ], 302 | "ctx-rh-lingual": [ 303 | 0.8823529411764706, 304 | 0.5490196078431373, 305 | 0.5490196078431373 306 | ], 307 | "ctx-rh-medialorbitofrontal": [ 308 | 0.7843137254901961, 309 | 0.13725490196078433, 310 | 0.29411764705882354 311 | ], 312 | "ctx-rh-middletemporal": [ 313 | 0.6274509803921569, 314 | 0.39215686274509803, 315 | 0.19607843137254902 316 | ], 317 | "ctx-rh-parahippocampal": [ 318 | 0.0784313725490196, 319 | 0.8627450980392157, 320 | 0.23529411764705882 321 | ], 322 | "ctx-rh-paracentral": [ 323 | 0.23529411764705882, 324 | 0.8627450980392157, 325 | 0.23529411764705882 326 | ], 327 | "ctx-rh-parsopercularis": [ 328 | 0.8627450980392157, 329 | 0.7058823529411765, 330 | 0.5490196078431373 331 | ], 332 | "ctx-rh-parsorbitalis": [ 333 | 0.0784313725490196, 334 | 0.39215686274509803, 335 | 0.19607843137254902 336 | ], 337 | "ctx-rh-parstriangularis": [ 338 | 0.8627450980392157, 339 | 0.23529411764705882, 340 | 0.0784313725490196 341 | ], 342 | "ctx-rh-pericalcarine": [ 343 | 0.47058823529411764, 344 | 0.39215686274509803, 345 | 0.23529411764705882 346 | ], 347 | "ctx-rh-postcentral": [ 348 | 0.8627450980392157, 349 | 0.0784313725490196, 350 | 0.0784313725490196 351 | ], 352 | "ctx-rh-posteriorcingulate": [ 353 | 0.8627450980392157, 354 | 0.7058823529411765, 355 | 0.8627450980392157 356 | ], 357 | "ctx-rh-precentral": [ 358 | 0.23529411764705882, 359 | 0.0784313725490196, 360 | 0.8627450980392157 361 | ], 362 | "ctx-rh-precuneus": [ 363 | 0.6274509803921569, 364 | 0.5490196078431373, 365 | 0.7058823529411765 366 | ], 367 | "ctx-rh-rostralanteriorcingulate": [ 368 | 0.3137254901960784, 369 | 0.0784313725490196, 370 | 0.5490196078431373 371 | ], 372 | "ctx-rh-rostralmiddlefrontal": [ 373 | 0.29411764705882354, 374 | 0.19607843137254902, 375 | 0.49019607843137253 376 | ], 377 | "ctx-rh-superiorfrontal": [ 378 | 0.0784313725490196, 379 | 0.8627450980392157, 380 | 0.6274509803921569 381 | ], 382 | "ctx-rh-superiorparietal": [ 383 | 0.0784313725490196, 384 | 0.7058823529411765, 385 | 0.5490196078431373 386 | ], 387 | "ctx-rh-superiortemporal": [ 388 | 0.5490196078431373, 389 | 0.8627450980392157, 390 | 0.8627450980392157 391 | ], 392 | "ctx-rh-supramarginal": [ 393 | 0.3137254901960784, 394 | 0.6274509803921569, 395 | 0.0784313725490196 396 | ], 397 | "ctx-rh-frontalpole": [ 398 | 0.39215686274509803, 399 | 0.0, 400 | 0.39215686274509803 401 | ], 402 | "ctx-rh-temporalpole": [ 403 | 0.27450980392156865, 404 | 0.27450980392156865, 405 | 0.27450980392156865 406 | ], 407 | "ctx-rh-transversetemporal": [ 408 | 0.5882352941176471, 409 | 0.5882352941176471, 410 | 0.7843137254901961 411 | ], 412 | "ctx-rh-insula": [ 413 | 1.0, 414 | 0.7529411764705882, 415 | 0.12549019607843137 416 | ], 417 | "Right-Cerebellum-Cortex": [ 418 | 0.9019607843137255, 419 | 0.5803921568627451, 420 | 0.13333333333333333 421 | ] 422 | } -------------------------------------------------------------------------------- /scene_template.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import os 3 | import argparse 4 | import numpy as np 5 | import json 6 | import sys 7 | import bpy 8 | import mathutils 9 | import numpy as np 10 | 11 | def parse_arguments(): 12 | # Remove Blender's own arguments by splitting at "--". 13 | if "--" not in sys.argv: 14 | print("Error: Missing '--' to separate Blender args from script args.") 15 | sys.exit(1) 16 | 17 | script_args = sys.argv[sys.argv.index("--") + 1:] 18 | 19 | # Set up argparse for the script arguments. 20 | parser = argparse.ArgumentParser(description="Parse arguments for Blender script.") 21 | parser.add_argument("--subject", required=True, help="Subject identifier") 22 | parser.add_argument("--output", required=True, help="STREAM 3D Subject Output Directory") 23 | 24 | args = parser.parse_args(script_args) 25 | return args 26 | 27 | args = parse_arguments() 28 | subject, output_dir = args.subject, args.output 29 | 30 | bpy.ops.wm.save_as_mainfile(filepath=f"{output_dir}/{subject}.blend") 31 | 32 | cwd = os.path.dirname(os.path.abspath(__file__)) 33 | blender_template_path = os.path.join(cwd,"template.blend") 34 | 35 | #WORLD SETUP 36 | for node_group in ["white_matter", "streamline_geometry"]: 37 | bpy.ops.wm.append(filename=node_group, directory=os.path.join(blender_template_path, "NodeTree")) 38 | 39 | for material in ["streamlines", "wireframe", "tms_map"]: 40 | bpy.ops.wm.append(filename=material, directory=os.path.join(blender_template_path, "Material")) 41 | 42 | # Remove all default objects 43 | bpy.ops.object.select_all(action='SELECT') 44 | bpy.ops.object.delete(use_global=False) 45 | 46 | context = bpy.context 47 | scene = context.scene 48 | for c in scene.collection.children: 49 | scene.collection.children.unlink(c) 50 | 51 | # Create new collections 52 | grey_matter = bpy.data.collections.new("grey_matter") 53 | bpy.context.scene.collection.children.link(grey_matter) 54 | 55 | white_matter = bpy.data.collections.new("white_matter") 56 | bpy.context.scene.collection.children.link(white_matter) 57 | 58 | wavefront_dir = f'{output_dir}/wavefront' 59 | if not os.path.exists(wavefront_dir): 60 | raise FileNotFoundError(f"Directory not found: {wavefront_dir}") 61 | 62 | # Add dictionaries to store object files and assign shading. To include additional anatomy (such as cerebellum or brain stem) add .obj files 63 | # To the wavefront directory and add them to the following dictionaries: 64 | grey_matter_objects = {"pial"} 65 | white_matter_objects = {"white"} 66 | 67 | # Import all .obj files and organize into collections 68 | for obj_file in os.listdir(wavefront_dir): 69 | if obj_file.endswith('.obj'): 70 | obj_path = os.path.join(wavefront_dir, obj_file) 71 | bpy.ops.wm.obj_import(filepath=obj_path) 72 | obj_name = os.path.basename(obj_file).split('.')[0] 73 | obj = bpy.context.selected_objects[0] 74 | 75 | # Reset X rotation to 0 degrees 76 | obj.rotation_euler[0] = 0 77 | 78 | if obj_name in grey_matter_objects: 79 | grey_matter.objects.link(obj) 80 | bpy.context.scene.collection.objects.unlink(obj) 81 | tms_material = bpy.data.materials["tms_map"] 82 | obj.data.materials.append(tms_material) 83 | 84 | mesh = obj.data 85 | if "intensity" not in mesh.attributes: 86 | mesh.attributes.new(name="intensity", type='FLOAT', domain='POINT') 87 | 88 | elif obj_name in white_matter_objects: 89 | white_matter.objects.link(obj) 90 | bpy.context.scene.collection.objects.unlink(obj) 91 | # Add a geometry nodes modifier and set the node group to "white_matter" 92 | geo_modifier = obj.modifiers.new(name="GeometryNodes", type='NODES') 93 | geo_modifier.node_group = bpy.data.node_groups["white_matter"] 94 | 95 | bpy.data.worlds["World"].node_tree.nodes["Background"].inputs[0].default_value = (0, 0, 0, 1) 96 | 97 | # Find the pial object and compute its center of mass 98 | pial_obj = bpy.data.objects.get("pial") 99 | if not pial_obj: 100 | raise ValueError(f"Could not find pial object named 'pial'") 101 | 102 | # Get the world-space center of mass by averaging vertex coordinates 103 | vertices = [pial_obj.matrix_world @ v.co for v in pial_obj.data.vertices] 104 | com_array = np.mean(np.array([v.to_tuple() for v in vertices]), axis=0) 105 | com = mathutils.Vector(com_array) 106 | 107 | bpy.ops.object.empty_add(type='CUBE', align='WORLD', location=com, scale=(1, 1, 1)) 108 | empty = bpy.context.active_object 109 | empty.name = "rotation_control" 110 | 111 | 112 | # Add camera and set its position/rotation 113 | cam_loc = com + mathutils.Vector((350, 0, 0)) 114 | bpy.ops.object.camera_add(enter_editmode=False, align='WORLD', location=cam_loc, rotation=(np.radians(90), 0, np.radians(90))) 115 | camera = bpy.context.active_object 116 | bpy.context.scene.camera = camera 117 | 118 | 119 | # Parent camera to empty 120 | camera.select_set(True) 121 | empty.select_set(True) 122 | bpy.context.view_layer.objects.active = empty 123 | bpy.ops.object.parent_set(type='OBJECT', keep_transform=True) 124 | 125 | # Set render resolution to 4K 126 | scene.render.resolution_x = 3840 127 | scene.render.resolution_y = 2160 128 | scene.render.resolution_percentage = 100 129 | 130 | # Add camera animation 131 | empty.rotation_euler[2] = np.radians(0) 132 | empty.keyframe_insert(data_path="rotation_euler", index=2, frame=1) 133 | empty.rotation_euler[2] = np.radians(180) 134 | empty.keyframe_insert(data_path="rotation_euler", index=2, frame=240) 135 | 136 | # Load the streamlines 137 | with open(f'{output_dir}/tractography/streamline_subset.txt', 'r') as file: 138 | input_streamlines = json.load(file) 139 | 140 | streamlines = [np.array(streamline) for streamline in input_streamlines] 141 | 142 | # Get the pre-existing "streamline_geometry" geometry nodes setup 143 | streamline_nodes = bpy.data.node_groups.get("streamline_geometry") 144 | 145 | # Create a new collection for the streamlines 146 | streamline_collection = bpy.data.collections.new("Streamlines Collection") 147 | bpy.context.scene.collection.children.link(streamline_collection) 148 | 149 | # Iterate over each streamline 150 | for i, sl in enumerate(streamlines): 151 | # Create a new curve for each streamline 152 | curve = bpy.data.curves.new(name=f'streamline_{i}', type='CURVE') 153 | curve.dimensions = '3D' 154 | curve.resolution_u = 2 155 | 156 | spline = curve.splines.new('NURBS') 157 | spline.points.add(len(sl) - 1) 158 | 159 | # Assign points to the spline 160 | for j, point in enumerate(sl): 161 | spline.points[j].co = np.append(point, 1) 162 | 163 | # Create object and link it to the collection 164 | obj = bpy.data.objects.new(f'streamline_{i}', curve) 165 | streamline_collection.objects.link(obj) 166 | 167 | # Add the geometry nodes modifier and assign the 'streamline_geometry' node group 168 | modifier = obj.modifiers.new(name="Streamline Geometry", type='NODES') 169 | modifier.node_group = streamline_nodes 170 | 171 | # Save File 172 | bpy.ops.wm.save_mainfile() 173 | -------------------------------------------------------------------------------- /source_estimation_animation.py: -------------------------------------------------------------------------------- 1 | import bpy 2 | import bmesh 3 | import sys 4 | import argparse 5 | import numpy as np 6 | 7 | def parse_arguments(): 8 | # Remove Blender's arguments by splitting at "--" 9 | if "--" not in sys.argv: 10 | print("Error: Missing '--' to separate Blender args from script args.") 11 | sys.exit(1) 12 | 13 | script_args = sys.argv[sys.argv.index("--") + 1:] 14 | 15 | parser = argparse.ArgumentParser(description="Parse arguments for Blender script.") 16 | parser.add_argument("--source_estimation", required=True, help=".npy file containing source estimation timeseries data") 17 | parser.add_argument("--render-frame", type=int, help="Render a single frame") 18 | parser.add_argument("--render-anim", action="store_true", help="Render an animation") 19 | 20 | args = parser.parse_args(script_args) 21 | return args 22 | 23 | def update_intensity(scene): 24 | current_frame = scene.frame_current 25 | 26 | # Ensure frame number is within bounds 27 | if current_frame < 0 or current_frame >= n_frames: 28 | return 29 | 30 | # Update vertex intensity 31 | obj = bpy.data.objects.get("pial") 32 | if obj: 33 | mesh = obj.data 34 | intensity_rh = mesh.attributes["intensity"] 35 | intensity_rh.data.foreach_set( 36 | "value", (scalar_values_timeseries[:, current_frame]) 37 | ) 38 | mesh.update() 39 | 40 | # Parse arguments 41 | args = parse_arguments() 42 | stc_path = args.source_estimation 43 | print(f"Rendering visualization using data from: {stc_path}") 44 | 45 | # Load source estimate 46 | scalar_values_timeseries = np.load(bpy.path.abspath(stc_path)) 47 | n_frames = scalar_values_timeseries.shape[-1] 48 | 49 | # Clear and register frame change handler 50 | bpy.app.handlers.frame_change_pre.clear() 51 | bpy.app.handlers.frame_change_pre.append(update_intensity) 52 | 53 | # Perform rendering 54 | if args.render_frame is not None: 55 | bpy.context.scene.frame_set(args.render_frame) 56 | bpy.ops.render.render(write_still=True) 57 | 58 | elif args.render_anim: 59 | bpy.ops.render.render(animation=True) -------------------------------------------------------------------------------- /stream4d.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | import os 4 | import subprocess 5 | import time 6 | import random 7 | 8 | from matplotlib import pyplot as plt 9 | import matplotlib 10 | matplotlib.use('Agg') 11 | 12 | import mne 13 | import mne_connectivity 14 | import nibabel as nib 15 | import numpy as np 16 | from scipy.ndimage import gaussian_filter 17 | from scipy.sparse import csr_matrix 18 | from scipy.spatial import KDTree 19 | from scipy.stats import norm 20 | 21 | # Utility 22 | def min_max_norm(a, min=None): 23 | """ 24 | Normalizes an array to [0, 1] using min-max normalization. 25 | 26 | Parameters: 27 | a (ndarray): Array to normalize. 28 | min (float, optional): Minimum value to use instead of np.min(a). 29 | 30 | Returns: 31 | ndarray: Normalized array. 32 | """ 33 | if min is not None: 34 | return(a - min)/(np.max(a) - min) 35 | else: 36 | return(a - np.min(a))/(np.max(a) - np.min(a)) 37 | 38 | def get_sparse_connectivity(faces, num_vertices): 39 | """ 40 | Constructs a sparse vertex adjacency matrix based on triangular mesh faces. 41 | 42 | Parameters: 43 | faces (ndarray): M x 3 array of triangle vertex indices. 44 | num_vertices (int): Total number of vertices. 45 | 46 | Returns: 47 | csr_matrix: Sparse connectivity matrix (num_vertices x num_vertices). 48 | """ 49 | row, col = [], [] 50 | for face in faces: 51 | # Ensure the face has at least 2 vertices (skip otherwise) 52 | if len(face) < 2: 53 | continue 54 | 55 | # For each vertex in the face, connect it to the other vertices 56 | for i, v in enumerate(face): 57 | if v < num_vertices: # Ensure the vertex index is within bounds 58 | linked_neighbors = [neighbor for neighbor in face if neighbor != v and neighbor < num_vertices] 59 | for neighbor in linked_neighbors: 60 | row.append(v) 61 | col.append(neighbor) 62 | 63 | # Set all entries to 1 (indicating a connection) 64 | data = np.ones(len(row)) 65 | connectivity = csr_matrix((data, (row, col)), shape=(num_vertices, num_vertices)) 66 | return connectivity 67 | 68 | # Geometry 69 | def get_streamline_endpoints(streamlines): 70 | streamline_endpoints = np.zeros((len(streamlines),2,3)) 71 | for i, streamline in enumerate(streamlines): 72 | streamline_endpoints[i] = [streamline[0], streamline[-1]] 73 | return streamline_endpoints 74 | 75 | def srf_to_wavefront(freesurfer_dir, subject, wavefront_output_dir): 76 | """ 77 | Converts FreeSurfer surface geometry to OBJ format for Blender visualization. 78 | 79 | Parameters: 80 | freesurfer_dir (str): Path to FreeSurfer recon-all directory. 81 | subject (str): Subject identifier. 82 | wavefront_output_dir (str): Directory to save .obj output. 83 | 84 | Returns: 85 | dict: Contains 'vertices', 'sphere_vertices', 'faces', 'n_vertices', and 'vertex_offset'. 86 | """ 87 | os.makedirs(wavefront_output_dir, exist_ok=True) 88 | output_dict = {} 89 | 90 | for tissue in ['white', 'pial']: 91 | all_sphere_vertices = [] 92 | all_vertices = [] 93 | all_faces = [] 94 | vertex_offset = 0 95 | 96 | for hemi in ['lh', 'rh']: 97 | input_surface = os.path.join(freesurfer_dir, subject, 'surf', f'{hemi}.{tissue}') 98 | adj = {'lh':-60, 'rh':60} 99 | 100 | # Read surface geometry and CRAS metadata 101 | vertices, faces, metadata = nib.freesurfer.read_geometry(input_surface, read_metadata=True) 102 | cras_offset = metadata.get('cras', np.zeros(3)) 103 | vertices += cras_offset 104 | 105 | sphere_vertices, _ = nib.freesurfer.read_geometry(os.path.join(freesurfer_dir, subject, 'surf', f'{hemi}.sphere')) 106 | sphere_vertices[:,0] += adj[hemi] 107 | all_sphere_vertices.append(sphere_vertices) 108 | 109 | # Adjust face indices by current offset 110 | faces += vertex_offset 111 | all_vertices.append(vertices) 112 | all_faces.append(faces) 113 | 114 | if hemi=='lh': 115 | vertex_offset += vertices.shape[0] 116 | 117 | # Combine both hemispheres 118 | all_vertices = np.vstack(all_vertices) 119 | all_faces = np.vstack(all_faces) 120 | all_sphere_vertices = np.vstack(all_sphere_vertices) 121 | 122 | # Write to .obj file 123 | output_obj = os.path.join(wavefront_output_dir, f'{tissue}.obj') 124 | with open(output_obj, 'w') as obj: 125 | for v in all_vertices: 126 | obj.write(f'v {v[0]} {v[1]} {v[2]}\n') 127 | for f in all_faces: 128 | obj.write(f'f {f[0]+1} {f[1]+1} {f[2]+1}\n') 129 | 130 | # Return geometry dictionary for further use 131 | if tissue == 'pial': 132 | output_dict = {'vertices':all_vertices, 133 | 'sphere_vertices':all_sphere_vertices, 134 | 'faces':all_faces, 135 | 'n_vertices':len(all_vertices), 136 | 'vertex_offset':vertex_offset} 137 | 138 | return(output_dict) 139 | 140 | def create_connectome_parcels(freesurfer_dir, subject, output_dir): 141 | """ 142 | Converts a subject's FreeSurfer aparc+aseg.mgz parcellation to a .mif file using MRtrix's labelconvert. 143 | 144 | Parameters: 145 | freesurfer_dir (str): Path to the FreeSurfer recon-all directory. 146 | subject (str): Freesurfer sbject identifier. 147 | output_dir (str): Directory to save the converted .mif file. 148 | 149 | Returns: 150 | str: Path to the generated .mif parcellation file. 151 | """ 152 | os.system( 153 | f'labelconvert {freesurfer_dir}/{subject}/mri/aparc+aseg.mgz ' 154 | f'{os.path.dirname(os.path.realpath(__file__))}/resources/FreeSurferColorLUT.txt {os.path.dirname(os.path.realpath(__file__))}/resources/fs_default.txt ' 155 | f'{output_dir}/{subject}.mif -force' 156 | ) 157 | return f'{output_dir}/{subject}.mif' 158 | 159 | # Streamline Management 160 | def get_streamline_subset(tractography_file, output_dir, n=15000, force=False): 161 | """ 162 | Loads a random subset of streamlines for visualization or analysis. 163 | 164 | Parameters: 165 | tractography_file (str): Path to .tck streamline file. 166 | output_dir (str): Directory to save or load subset from. 167 | n (int): Number of streamlines to sample. 168 | force (bool): Whether to overwrite existing subset. 169 | 170 | Returns: 171 | list of ndarray: Subset of streamlines. 172 | """ 173 | # If no subsample has been saved or if force generation is applied, load in full tractography output and generate sample 174 | if not os.path.exists(os.path.join(output_dir, 'streamline_subset.txt')) or force: 175 | raw_streamlines = nib.streamlines.load(tractography_file) 176 | streamlines = list(raw_streamlines.streamlines) 177 | streamline_subset = random.sample(streamlines, n) 178 | 179 | output_struct = [streamline.tolist() for streamline in streamline_subset] 180 | with open(os.path.join(output_dir, 'streamline_subset.txt'), 'w') as file: 181 | json.dump(output_struct, file) 182 | 183 | del raw_streamlines 184 | 185 | else: 186 | # Read in preexisting streamline subset 187 | with open(os.path.join(output_dir, 'streamline_subset.txt'), 'r') as file: 188 | streamline_subset_raw = json.load(file) 189 | streamline_subset = [np.array(streamline) for streamline in streamline_subset_raw] 190 | 191 | return(streamline_subset) 192 | 193 | def associate_vertices_to_streamlines(vertices, streamline_endpoints, distance_threshold): 194 | """ 195 | Associates surface vertices with streamlines whose endpoints are within a given distance threshold. 196 | 197 | Parameters: 198 | vertices (ndarray): N x 3 array of vertex coordinates. 199 | streamline_endpoints (ndarray): M x 2 x 3 array of streamline start and end points. 200 | distance_threshold (float): Distance threshold for associating streamlines to vertices. 201 | 202 | Returns: 203 | list of lists: A list where each entry contains indices of vertices associated with that streamline. 204 | """ 205 | n_streamlines = streamline_endpoints.shape[0] 206 | # Reshape endpoint coordinates to: (2 * N_streamlines, 3) 207 | endpoint_coords = streamline_endpoints.reshape(-1, 3) 208 | # Query all endpoint coordinates at once 209 | tree = KDTree(vertices) 210 | all_neighbors = tree.query_ball_point(endpoint_coords, distance_threshold) 211 | # Parse and combine results from each streamline's start and endpoint 212 | vertex_to_streamlines = [ 213 | list(set(all_neighbors[2*i] + all_neighbors[2*i + 1])) # Remove duplicates 214 | for i in range(n_streamlines) 215 | ] 216 | 217 | return vertex_to_streamlines 218 | 219 | # Source Estimation Processing 220 | def interpolate_surface_values_timeseries(vertices, stc_indices, stc_values_timeseries): 221 | """ 222 | Interpolates missing scalar values at vertices over time using nearest neighbor interpolation. 223 | 224 | Parameters: 225 | vertices (ndarray): N x 3 array of surface vertex coordinates. 226 | stc_indices (ndarray): Indices of vertices with known values. 227 | stc_values_timeseries (ndarray): Known values of shape (len(stc_indices), timepoints). 228 | 229 | Returns: 230 | ndarray: Interpolated values for all vertices, shape (N, timepoints). 231 | """ 232 | n_timepoints = stc_values_timeseries.shape[1] 233 | full_scalar_values = np.zeros((vertices.shape[0], n_timepoints)) 234 | 235 | # Set known scalar values for all timepoints 236 | full_scalar_values[stc_indices, :] = stc_values_timeseries 237 | 238 | missing_indices = np.where(full_scalar_values[:, 0] == 0)[0] # assumes missing values are 0 in all timepoints 239 | 240 | # Use KDTree to find the nearest known vertex for each missing vertex 241 | tree = KDTree(vertices[stc_indices]) 242 | _, nearest_known_indices = tree.query(vertices[missing_indices]) 243 | 244 | # Assign the scalar values of the nearest known vertex to each missing vertex for each timepoint 245 | full_scalar_values[missing_indices, :] = full_scalar_values[stc_indices][nearest_known_indices, :] 246 | 247 | return full_scalar_values 248 | 249 | def smooth_values_sparse_timeseries(connectivity, scalar_values_timeseries, num_passes=10): 250 | """ 251 | Smooths scalar values on a surface over time using neighbor averaging via a sparse connectivity matrix. 252 | 253 | Parameters: 254 | connectivity (csr_matrix): Sparse vertex adjacency matrix. 255 | scalar_values_timeseries (ndarray): Scalar values at each vertex and timepoint (N x T). 256 | num_passes (int): Number of laplacian smoothing passes to apply. 257 | 258 | Returns: 259 | ndarray: Smoothed scalar values (N x T). 260 | """ 261 | smoothed_values = scalar_values_timeseries.copy() 262 | for _ in range(num_passes): 263 | neighbor_sums = connectivity.dot(smoothed_values) 264 | 265 | non_zero_neighbors = connectivity.dot((smoothed_values != 0).astype(float)) 266 | 267 | # Avoid division by zero by only averaging where there are non-zero neighbors 268 | mask = non_zero_neighbors > 0 269 | smoothed_values[mask] = neighbor_sums[mask] / non_zero_neighbors[mask] 270 | 271 | return smoothed_values 272 | 273 | def threshold_stc(source_estimate_path, surface_geometry, output_dir, stim_onset, time_range, label=''): 274 | """ 275 | Thresholds source estimates using baseline z-score correction, interpolates missing values, 276 | applies temporal and spatial smoothing, and returns the final smoothed timeseries. 277 | 278 | Parameters: 279 | source_estimate_path (str): Path to .stc file. 280 | surface_geometry (dict): Output from `srf_to_wavefront`, includes vertices, faces, etc. 281 | output_dir (str): Output directory. 282 | stim_onset (int): Index of stimulus onset timepoint. 283 | time_range (ndarray): Time indices relative to stim_onset to include in final estimate. 284 | 285 | Returns: 286 | ndarray: Smoothed surface scalar values (n_timepoints x n_vertices). 287 | """ 288 | source_estimate = mne.read_source_estimate(source_estimate_path) 289 | stc_data = source_estimate.data 290 | 291 | lh_vertno = source_estimate.lh_vertno 292 | rh_vertno = source_estimate.rh_vertno + surface_geometry['vertex_offset'] 293 | vertno = np.hstack([lh_vertno, rh_vertno]) 294 | 295 | baseline_data = stc_data[:,:(stim_onset-10)] 296 | baseline_means = np.mean(baseline_data, axis=1) 297 | baseline_data_adj = baseline_data - baseline_means[:, np.newaxis] 298 | baseline_stds = np.std(baseline_data_adj, axis=1) 299 | 300 | stc_data_adj = stc_data - baseline_means[:, np.newaxis] 301 | 302 | p_value = 0.05/len(baseline_means) 303 | z_score = norm.ppf(1 - p_value / 2) * 2 304 | thresholds = z_score * baseline_stds 305 | 306 | stc_data_thresh = np.where(stc_data_adj > (baseline_means[:, np.newaxis] + thresholds[:, np.newaxis]), stc_data_adj, 0) 307 | 308 | time_index_range = stim_onset + time_range 309 | n_frames = len(time_range) 310 | 311 | hemisphere_scalars = np.zeros((n_frames, surface_geometry['n_vertices'])) 312 | interpolated_estimate = interpolate_surface_values_timeseries(surface_geometry['sphere_vertices'], vertno, stc_data_thresh[:, time_index_range]) 313 | temporally_smoothed_estimate = gaussian_filter(interpolated_estimate, sigma=[0, 2]) 314 | smoothed_estimate = smooth_values_sparse_timeseries(surface_geometry['connectivity'], temporally_smoothed_estimate) 315 | 316 | np.save(os.path.join(output_dir, 'source_estimates', 'smoothed', f'{label}smoothed.npy'), smoothed_estimate) 317 | return(smoothed_estimate) 318 | 319 | # Streamline Activation 320 | def link_streamline_activation(scalars, vertex_associations, streamlines, output_dir, vis_thresh=True, label='', save=True): 321 | """ 322 | Propagates scalar activation values from surface vertices to associated streamlines. 323 | 324 | Parameters: 325 | scalars (ndarray): Vertex activation values (N_vertices x timepoints). 326 | vertex_associations (list of lists): Streamline indices associated with each vertex. 327 | streamlines (list of ndarray): List of streamlines. 328 | output_dir (str): Output directory to save results. 329 | label (str): Optional prefix label for saved output. 330 | 331 | Returns: 332 | ndarray: Streamline activation timeseries (N_streamlines x timepoints). 333 | """ 334 | # min-max normalize source estimation values from 0-1 335 | soft_max = np.percentile(scalars, 99.95) 336 | if vis_thresh: 337 | thresh = np.percentile(scalars[scalars > 0], 90) 338 | else: 339 | thresh = np.min(scalars[scalars > 0]) 340 | 341 | normalized_scalars = (scalars - thresh) / (soft_max - thresh) 342 | normalized_scalars = np.where(normalized_scalars > 0, normalized_scalars, 0) 343 | 344 | n_streamlines, n_timepoints = len(streamlines), scalars.shape[1] 345 | active_streamlines = np.zeros((n_streamlines, n_timepoints)) 346 | 347 | # Iterate through each streamline and assign the maximum activation value from associated vertices 348 | for str_idx, vtx_indices in enumerate(vertex_associations): 349 | if not vtx_indices: 350 | continue 351 | 352 | streamline_activation = np.max(normalized_scalars[vtx_indices, :], axis=0) 353 | active_streamlines[str_idx] = streamline_activation 354 | 355 | if save: 356 | # Save activation timeseries for Blender shading 357 | np.save(os.path.join(output_dir, 'source_estimates', 'normalized', f'{label}normalized.npy'), normalized_scalars) 358 | np.save(os.path.join(output_dir, 'tractography', f'{label}streamline_activation_timeseries.npy'), active_streamlines) 359 | 360 | return(active_streamlines) 361 | 362 | # Connectome Analysis 363 | def weighted_connectome_analysis(scalars, vertex_associations, streamlines, sift_weight_path, parcels_path, output_dir, label=''): 364 | """ 365 | Creates a weighted structural connectome based on streamline activation and anatomical weights. 366 | 367 | Parameters: 368 | scalars (ndarray): Vertex-level scalar activations over time (n_vertices x n_timepoints). 369 | vertex_associations (list of lists): Mapping from each vertex to associated streamline indices. 370 | streamlines (list): List of streamlines (each streamline is an array of 3D points). 371 | sift_weight_path (str): Path to text file with SIFT streamline weights. 372 | parcels_path (str): Path to parcellation file (e.g., an atlas) for connectome construction. 373 | label (str): Optional prefix for output filenames. 374 | 375 | Returns: 376 | None 377 | """ 378 | 379 | # Load SIFT weights if provided, otherwise default to equal weighting 380 | if sift_weight_path: 381 | with open(sift_weight_path, 'r') as weight_file: 382 | anatomical_weights = np.array(weight_file.readlines()[-1].split(' ')).astype(np.float64) 383 | else: 384 | anatomical_weights = np.ones(len(streamlines)) 385 | 386 | # Compute streamline-level activation over time from surface scalars 387 | streamline_activations = link_streamline_activation( 388 | scalars, vertex_associations, streamlines, 389 | output_dir=os.path.join(output_dir, 'connectome'), 390 | save=False, vis_thresh=None, label=label 391 | ) 392 | 393 | # Integrate activation across time for each streamline 394 | streamline_activations_integrated = np.sum(streamline_activations, axis=1) 395 | 396 | # Multiply by anatomical weights and apply nonlinear scaling 397 | streamline_activations_integrated_anat_weighted = streamline_activations_integrated**1.5 * anatomical_weights 398 | del streamline_activations # Free memory 399 | 400 | # Select only streamlines with non-zero activation for analysis 401 | streamline_mask = [sl for (sl, val) in zip(streamlines, streamline_activations_integrated) if val] 402 | 403 | # Normalize and scale weights for tck2connectome input 404 | streamline_scalars_mask = min_max_norm( 405 | streamline_activations_integrated_anat_weighted[streamline_activations_integrated_anat_weighted > 0] 406 | ) * 10 407 | 408 | weights_output_path = os.path.join(output_dir, 'connectome', f'{label}activation_integration_weights.txt') 409 | np.savetxt(weights_output_path, 410 | streamline_scalars_mask, delimiter=' ', newline=' ') 411 | 412 | # Save filtered active streamlines to .tck 413 | tractogram = nib.streamlines.Tractogram(streamline_mask, affine_to_rasmm=np.eye(4)) 414 | active_streamline_path = os.path.join(output_dir, 'connectome', f'{label}active_streamlines.tck') 415 | nib.streamlines.save(tractogram, active_streamline_path) 416 | 417 | # Generate connectome matrix using MRtrix tck2connectome 418 | parcel_output = os.path.join(output_dir, 'connectome', f'{label}parcels.csv') 419 | parcel_assignments_output = os.path.join(output_dir, 'connectome', f'{label}assignments_parcels.csv') 420 | 421 | env = os.environ.copy() 422 | env['MRTRIX_NOGUI'] = '1' 423 | subprocess.run([ 424 | 'tck2connectome', '-symmetric', '-zero_diagonal', 425 | active_streamline_path, parcels_path, parcel_output, 426 | '-scale_invnodevol', 427 | '-tck_weights_in', weights_output_path, 428 | '-out_assignments', parcel_assignments_output, 429 | '-force' 430 | ], env=env) 431 | 432 | # Load parcellation label LUT for node names and colors 433 | with open(f"{os.path.dirname(os.path.realpath(__file__))}/resources/fs_label_luts.json", "r") as f: 434 | fs_label_luts = json.load(f) 435 | labels = list(fs_label_luts.keys()) 436 | node_colors = list(fs_label_luts.values()) 437 | 438 | # Load the resulting connectome matrix 439 | connectome = np.loadtxt(f'{output_dir}/connectome/{label}parcels.csv', delimiter=',') 440 | 441 | # Determine which nodes are highly connected for styling 442 | max_conn_per_node = np.max(connectome, axis=1) 443 | label_colors = [ 444 | '#555555' if max_conn < np.percentile(connectome, 99.5) else 'white' 445 | for max_conn in max_conn_per_node 446 | ] 447 | 448 | # Normalize connectome matrix for visualization 449 | connectome_scaled = connectome * (1 / np.percentile(connectome, 99.95)) 450 | np.savetxt(os.path.join(output_dir, 'connectome', f'{label}connectome.txt'), connectome_scaled) 451 | 452 | # Compute circular layout and plot connectome 453 | node_angles = mne.viz.circular_layout(labels, labels) 454 | fig, ax = mne_connectivity.viz.plot_connectivity_circle( 455 | connectome_scaled, labels, colormap='magma', 456 | vmin=0, vmax=1, node_angles=node_angles, 457 | linewidth=3, node_colors=node_colors, 458 | colorbar=False, fontsize_names=10 459 | ) 460 | 461 | # Recolor labels based on threshold 462 | for text, color in zip(ax.texts, label_colors): 463 | text.set_color(color) 464 | 465 | # Save final connectome visualization 466 | fig.savefig(f'{output_dir}/connectome/{label}connectome.svg', dpi=300, transparent=False) 467 | plt.close(fig) 468 | 469 | def average_cortical_thickness(freesurfer_dir, subject): 470 | """ 471 | Returns the average cortical thickness of a FreeSurfer subject. 472 | 473 | Parameters: 474 | freesurfer_dir (str): Path to the FreeSurfer subjects directory. 475 | subject (str): Subject ID. 476 | 477 | Returns: 478 | float: Average cortical thickness across both hemispheres. 479 | """ 480 | surf_dir = os.path.join(freesurfer_dir, subject, 'surf') 481 | lh_thickness = nib.freesurfer.io.read_morph_data(os.path.join(surf_dir, 'lh.thickness')) 482 | rh_thickness = nib.freesurfer.io.read_morph_data(os.path.join(surf_dir, 'rh.thickness')) 483 | # Concatenate and compute the mean thickness 484 | all_thickness = np.concatenate([lh_thickness, rh_thickness]) 485 | return(np.mean(all_thickness)) 486 | 487 | # Pipeline Control 488 | def run_stream4d(freesurfer_dir, subject, tractography_path, source_estimate_path, output_dir, connectome=True, sift_weight_path="", label="", dist_threshold=None): 489 | """ 490 | Runs STREAM-4D integration pipeline: loads surface and tractography data, thresholds source estimates, 491 | links activation to streamlines, and saves outputs for visualization and connectomics. 492 | 493 | Parameters: 494 | freesurfer_dir (str): Path to FreeSurfer recon-all directory. 495 | subject (str): Subject identifier. 496 | tractography_path (str): Path to .tck tractography file. 497 | source_estimate_path (str): Path to .stc source estimate. 498 | output_dir (str): Directory to store pipeline outputs. 499 | label (str): Optional label prefix for output files. 500 | 501 | Returns: 502 | None 503 | """ 504 | start_time = time.time() 505 | print('------------------------------') 506 | print(' STREAM-4D ') 507 | print('------------------------------') 508 | 509 | print('[]: setting up directories') 510 | for subdir in ['wavefront', 'tractography', 'connectome', 'source_estimates/raw', 'source_estimates/smoothed', 'source_estimates/normalized', 'render']: 511 | os.makedirs(os.path.join(output_dir, subdir), exist_ok=True) 512 | 513 | tract_link_path = os.path.join(output_dir, "tractography", os.path.basename(tractography_path)) 514 | stc_link_path = os.path.join(output_dir, "source_estimates", "raw", os.path.basename(source_estimate_path)) 515 | os.system(f'ln -s {tractography_path} {tract_link_path}') 516 | os.system(f'ln -s {source_estimate_path} {stc_link_path}') 517 | 518 | 519 | if label: 520 | label = label + '_' 521 | 522 | print('\nLoading FreeSurfer Surface Geometry\n') 523 | surface_geometry = srf_to_wavefront(freesurfer_dir, subject, os.path.join(output_dir, 'wavefront')) 524 | surface_geometry['connectivity'] = get_sparse_connectivity(surface_geometry['faces'], surface_geometry['n_vertices']) 525 | 526 | print('Sampling Tractography Data\n') 527 | streamlines = get_streamline_subset(tractography_path, os.path.join(output_dir, 'tractography')) 528 | 529 | print('Extracting Sample Endpoints\n') 530 | streamline_endpoints = get_streamline_endpoints(streamlines) 531 | 532 | print('Thresholding Source Estimate\n') 533 | scalars = threshold_stc(source_estimate_path=source_estimate_path, surface_geometry=surface_geometry, output_dir=output_dir, stim_onset=500, time_range=np.arange(-25, 175), label=label) 534 | 535 | print('Associating Streamlines to Vertices\n') 536 | if not dist_threshold: 537 | dist_threshold = average_cortical_thickness(freesurfer_dir, subject) 538 | print(f'Computing associations with distance threshold: {dist_threshold}mm\n') 539 | 540 | print('Associating Streamlines to Vertices\n') 541 | vertex_associations = associate_vertices_to_streamlines(surface_geometry['vertices'], streamline_endpoints, dist_threshold) 542 | 543 | print('Linking Activation Timeseries\n') 544 | link_streamline_activation(scalars, vertex_associations, streamlines, output_dir, label=label) 545 | print(f'Associations Complete! Renderable output saved to {output_dir}') 546 | 547 | if connectome: 548 | print('Running Connectome Analysis\n') 549 | print('Loading Tractography Data') 550 | conn_streamlines = list(nib.streamlines.load(tractography_path).streamlines) 551 | print('Extracting Streamline Endpoints\n') 552 | conn_streamline_endpoints = get_streamline_endpoints(conn_streamlines) 553 | conn_vertex_associations = associate_vertices_to_streamlines(surface_geometry['vertices'], conn_streamline_endpoints, dist_threshold) 554 | print('Creating Connectome Parcellation\n') 555 | parcels = create_connectome_parcels(freesurfer_dir, subject, f'{output_dir}/connectome') 556 | print('Creating Structural Connectome with figures\n') 557 | weighted_connectome_analysis(scalars, conn_vertex_associations, conn_streamlines, sift_weight_path, parcels, output_dir, label) 558 | 559 | elapsed_time = time.time() - start_time 560 | print(f'\nSTREAM-4D completed in {elapsed_time / 60:.2f} minutes ({elapsed_time:.2f} seconds).') 561 | 562 | def main(): 563 | parser = argparse.ArgumentParser(description="Assign streamline activation intensity from source estimate") 564 | parser.add_argument("-t", "--tractography_path", type=str, help=".tck tractography file containing streamline data") 565 | parser.add_argument("-e", "--source_estimate_path", type=str, help=".stc source estimation path (MNE output, compatibility to improve with future releases)") 566 | parser.add_argument("-w", "--sift_weight_path", type=str, default="", help=".txt tcksift output to weight structural connectome") 567 | parser.add_argument("-f", "--freesurfer_dir", type=str, help="Path to the directory containing FreeSurfer's 'recon-all' output.") 568 | parser.add_argument("-s", "--subject", type=str, help="FreeSurfer Reconall subject") 569 | parser.add_argument("-o", "--output_dir", type=str, help="Output directory path") 570 | parser.add_argument("-l", "--label", type=str, default="", help="Optional label to prefix output files") 571 | parser.add_argument("-d", "--distance_threshold", type=float, default=None, help="Distance threshold for associating streamlines to vertices (in mm). If none, average cortical thickness will be used") 572 | parser.add_argument("--no-connectome", dest="connectome", action="store_false", help="Option to not run connectome analysis (performed by default)") 573 | args = parser.parse_args() 574 | 575 | run_stream4d(args.freesurfer_dir, args.subject, args.tractography_path, args.source_estimate_path, args.output_dir, args.connectome, args.sift_weight_path, args.label, args.distance_threshold) 576 | 577 | if __name__ == "__main__": 578 | main() -------------------------------------------------------------------------------- /template.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ComaRecoveryLab/STREAM-4D/fa7923c4b2ca5277a1de43b97ddb111f673cf8c3/template.blend --------------------------------------------------------------------------------