Open cgohil8 opened 1 year ago
To create nifti files for the eye balls:
#!/bin/bash
# Create left eye sphere
fslmaths $FSLDIR/data/standard/MNI152_T1_2mm -mul 0 -add 1 -roi 62 1 91 1 16 1 0 1 point -odt float
fslmaths point -kernel sphere 9 -fmean lefteye -odt float
# Right mask
fslswapdim lefteye.nii.gz -x y z righteye.nii.gz
# Normalise mask to 1s
fslmaths lefteye.nii.gz -div lefteye.nii.gz lefteye_norm.nii.gz
fslmaths righteye.nii.gz -div righteye.nii.gz righteye_norm.nii.gz
# Resample eye ball nii files to 8 mm resolution
flirt -in lefteye_norm.nii.gz -ref MNI152_T1_8mm_brain.nii.gz -out lefteye_norm.nii.gz -applyisoxfm 8
flirt -in righteye_norm.nii.gz -ref MNI152_T1_8mm_brain.nii.gz -out righteye_norm.nii.gz -applyisoxfm 8
Add them to existing parcellation files with:
import numpy as np
import nibabel as nib
parcellation_file = "Glasser52_binary_space-MNI152NLin6_res-8x8x8.nii.gz"
# Load parcellation
parc = nib.load(parcellation_file)
parc_data = parc.get_fdata()
# Load eyes
left_eye = nib.load("lefteye_norm.nii.gz")
left_eye_data = left_eye.get_fdata()
right_eye = nib.load("righteye_norm.nii.gz")
right_eye_data = right_eye.get_fdata()
# Add the parcel dimension
left_eye_data = left_eye_data[..., np.newaxis]
right_eye_data = right_eye_data[..., np.newaxis]
# Make voxel values binary
left_eye_data[left_eye_data > 0] = 1
right_eye_data[right_eye_data > 0] = 1
# Concatenate eye and parc arrays
new_parc_data = np.concatenate([parc_data, left_eye_data, right_eye_data], axis=3)
# Save new parcellation
new_parc = nib.Nifti1Image(new_parc_data, parc.affine, parc.header)
nib.save(new_parc, parcellation_file.replace(".nii.gz", "_with-eyes.nii.gz"))
Plot the parcellation with
from osl.source_recon import parcellation
parcellation.plot_parcellation(
"Glasser52_binary_space-MNI152NLin6_res-8x8x8_with-eyes.nii.gz",
output_file="parcellation_with_eyes.png",
)
This is the output:
Reopened this issue because there was a problem with the parcellation files that included eye balls.
The issue is the voxels covering the eyeballs are not included when we setup the voxel grid (in head space) during the forward modelling. We only create a voxel grid inside the inner skull:
https://github.com/OHBA-analysis/osl/blob/main/osl/source_recon/rhino/forward_model.py#L194
Would be good to have the option of using parcellation files that include eye balls.