コード例 #1
0
def Normalization(reconspace, backprojector, sinogram):
    sinseg = sinogram.get_segment_by_sinogram(0)
    filler = np.ones(np.shape(stirextra.to_numpy(sinseg)))
    fillStirSpace(sinseg, filler)
    sinogram.set_segment(sinseg)

    backprojector.back_project(reconspace, sinogram)
    npReconSpace = stirextra.to_numpy(reconspace)
    pyvpx.numpy2vpx(npReconSpace, 'NormMap.vpx')
    return reconspace
コード例 #2
0
    countIt = iIt + 1

    plt.figure(), plt.axis('off'), plt.title(
        'Guess after {0} iteration(s)'.format(iIt + 1)), plt.imshow(
            guess,
            interpolation=None,
            vmin=0,
            vmax=np.max(image2D),
            cmap=plt.cm.Greys_r), plt.savefig(
                figSaveDir +
                'Fig{}_finalImage.png'.format(numFigures, trueShiftAmplitude)
            ), plt.close()
    numFigures += 1
    image2DTMP = np.zeros((1, ) + np.shape(guess))
    image2DTMP[0, :, :] = guess
    pyvpx.numpy2vpx(image2DTMP,
                    figSaveDir + 'guess_Iteration{}.vpx'.format(iIt))

plt.figure(), plt.axis('off'), plt.subplot(
    1, 2, 1), plt.title('Original Image'), plt.imshow(image2D,
                                                      interpolation=None,
                                                      vmin=0,
                                                      vmax=np.max(image2D),
                                                      cmap=plt.cm.Greys_r)
plt.subplot(1, 2, 2), plt.title('Reconstructed Image'), plt.imshow(
    guess,
    interpolation=None,
    vmin=0,
    vmax=np.max(image2D),
    cmap=plt.cm.Greys_r), plt.savefig(
        figSaveDir +
        'Fig{}_originalAndRecon.png'.format(numFigures, trueShiftAmplitude)
コード例 #3
0
# Target volumes
largeTarget = guess[125:185, 100:170]
smallTarget = guess[115:175, 150:220]

plt.figure(), plt.axis('off'), plt.title(
    'Target volume (large lesion)'), plt.imshow(
        largeTarget,
        interpolation=None,
        vmin=0,
        vmax=np.max(largeTarget),
        cmap=plt.cm.Greys_r), plt.savefig(
            figSaveDir + 'QFig{}_largeTarget'.format(numFigures)), plt.close()
numFigures += 1
image2DTMP = np.zeros((1, ) + np.shape(largeTarget))
image2DTMP[0, :, :] = largeTarget
pyvpx.numpy2vpx(image2DTMP, figSaveDir + 'largeTarget.vpx')

plt.figure(), plt.axis('off'), plt.title(
    'Target volume (snall lesion)'), plt.imshow(
        smallTarget,
        interpolation=None,
        vmin=0,
        vmax=np.max(smallTarget),
        cmap=plt.cm.Greys_r), plt.savefig(
            figSaveDir + 'QFig{}_smallTarget'.format(numFigures)), plt.close()
numFigures += 1
image2DTMP = np.zeros((1, ) + np.shape(smallTarget))
image2DTMP[0, :, :] = smallTarget
pyvpx.numpy2vpx(image2DTMP, figSaveDir + 'smallTarget.vpx')

# SUV max
コード例 #4
0
import numpy as np
import matplotlib.pyplot as plt
import ManonsFunctions as mf
import pyvpx

nGates = 5
experiment = 'Sinus2D/'

filePath = "E:/Manon/Resultaten_Experimenten/" + experiment + "Gating/"

gatedImagesReg = []
for iGate in range(1, nGates+1):
    gatedImagesReg.append(mf.load_itk(filePath + "Coregistered_gates/Gate{}.mhd".format(iGate, iGate)))
meanImageRegistered = np.mean(gatedImagesReg, axis = 0)

pyvpx.numpy2vpx(meanImageRegistered, filePath + "MeanRegistered.vpx")
mf.writeMhdFile(meanImageRegistered, filePath + "MeanRegistered.mhd")
    for j in range(np.shape(sinoMu)[1]):
        expSinoMu[i, j] = math.exp(-sinoMu[i, j])

# Plot phantom and store as vpx image
plt.figure(), plt.axis('off'), plt.title('Original image'), plt.imshow(
    image2D,
    interpolation=None,
    vmin=0,
    vmax=np.max(image2D),
    cmap=plt.cm.Greys_r), plt.savefig(
        figSaveDir + 'Fig{}_phantom.png'.format(numFigures)), plt.close()
numFigures += 1

image2DTMP = np.zeros((1, ) + np.shape(image2D))
image2DTMP[0, :, :] = image2D
pyvpx.numpy2vpx(image2DTMP, figSaveDir + 'OriginalImage.vpx')

#_________________________ADD MOTION_______________________________
# Create surrogate signal and add motion to the phantom
phantomList, surSignal, shiftList, shiftXList = mf.move_Phantom(
    motion, nFrames, trueShiftAmplitude, trueSlope, trueSlopeX, image2D,
    stationary, modelBroken)
originalImage = phantomList[0]

# Plot surrogate signal and internal motion
# y-axis
plt.figure(), plt.axis('off')
plt.plot(range(nFrames), surSignal, label='Surrogate signal'), plt.title(
    'Motion (y-axis)'), plt.xlabel('Time frame'), plt.ylabel('Shift')
plt.plot(range(nFrames), shiftList, label='True motion y-axis')
plt.legend(
#_________________________MAKE PHANTOM_______________________________
image2D = mf.make_Phantom(phantom, noiseLevel)
plt.figure(), plt.title('Original image'), plt.imshow(
    image2D,
    interpolation=None,
    vmin=0,
    vmax=np.max(image2D),
    cmap=plt.cm.Greys_r), plt.savefig(
        figSaveDir +
        'Fig{}_TrueShift{}_phantom.png'.format(numFigures, trueShiftAmplitude)
    ), plt.close()
numFigures += 1
image2DTMP = np.zeros((1, ) + np.shape(image2D))
image2DTMP[0, :, :] = image2D
pyvpx.numpy2vpx(image2DTMP, figSaveDir + 'image2D.vpx')

#_________________________ADD MOTION_______________________________
phantomList, surSignal, shiftList = mf.move_Phantom(motion, nFrames,
                                                    trueShiftAmplitude,
                                                    trueSlope, image2D,
                                                    stationary)
originalImage = phantomList[0]

imageTMP = np.zeros((1, ) + np.shape(image2D))
imageTMP[0, :, :] = phantomList[0]
pyvpx.numpy2vpx(imageTMP, figSaveDir + 'image.vpx')

for iFrame in range(nFrames):
    plt.subplot(2, nFrames / 2 + 1, iFrame + 1), plt.title(
        'Time frame {0}'.format(iFrame)), plt.imshow(