NiftyML: PET-MR with Machine Learning

Version

Py-Versions

DOI

Licence

Tests

Coverage

Imports

Requires:

tensorflow-gpu or tensorflow
niftyml
matplotlib
numpy
tqdm
[1]:
%matplotlib notebook

import matplotlib.pyplot as plt
import numpy as np
from tqdm.keras import TqdmCallback

from niftypet import ml

Data

[2]:
# 20 PET-MR (2 channel) subjects, each 128x128x128
X = np.random.random((20, 128, 128, 128, 2))
Y = np.random.random((20, 128, 128, 128, 1))

Build & Train Model

[3]:
model = ml.dcl2021(X.shape[1:])
history = model.fit(
    X[:10], Y[:10],
    validation_split=0.1, epochs=5, batch_size=1,
    verbose=0, callbacks=[TqdmCallback()])
[4]:
plt.plot(history.history['nrmse'], label="Training")
plt.plot(history.history['val_nrmse'], label="Validation")
plt.ylabel("NRMSE")
plt.xlabel("epoch")
plt.legend();