3DCNN & MRIs
Steps
- Context (python, nibabel, Tensorflow)
-
- Data exploration.
- Preprocessing Input.
- Model.
- Training.
- Results.
- Q&A
Load data
import numpy as np
import pandas as pd
data = np.load("voxels_tagged.npy")
data.shape
[1108, 125001]
Pre-processing
(Separate classes)
class1 = frame[(frame['class']== 1)]
print("Total class 1:", len(class1))
class2 = frame[(frame['class']== 0)]
print("Total class 0:", len(class2))
Total class 1: 550
Total class 0: 558
Average brains
from sklearn.preprocessing import normalize
average_brain1 = normalize(class1).mean(0)
average_brain2 = normalize(class2).mean(0)
avg_vol1 = average_brain1.reshape(50,50,50)
print(avg_vol1.shape)
avg_vol2 = average_brain2.reshape(50,50,50)
print(avg_vol2.shape)
(50, 50, 50)
(50, 50, 50)
Comparing images
def compare_images(img1, img2): diff = img1 - img2 # elementwise for scipy arrays m_norm = sum(abs(diff)) # Manhattan norm z_norm = norm(diff.ravel(), 0) # Zero norm return (m_norm, z_norm, diff)
deck
By gabriel munoz
deck
- 150