def test_srtm_zhou2003_voxelwise(self):
     results_img = SRTM_Zhou2003.volume_wrapper(
         ti=self.ti,
         refRegionMaskFile=self.refRegionMaskFile,
         startActivity=self.startActivity,
         weights=self.weights,
         fwhm=self.fwhm)
     '''
Beispiel #2
0
    def test_srtm_zhou2003_fit(self):
        self.model = SRTM_Zhou2003(self.t, self.dt, self.TAC, self.refTAC,
                                   self.startActivity)

        print('\nFitting SRTM_Zhou2003 with %s start activity' %
              self.startActivity)
        self.model.fit()

        print('True BP = %.6f; estimated BP = %.6f' % (self.BP, self.model.BP))
        print('True R1 = %.6f; estimated R1 = %.6f' % (self.R1, self.model.R1))
        self.assertAlmostEqual(self.BP, self.model.BP, delta=1e-4)
        self.assertAlmostEqual(self.R1, self.model.R1, delta=1e-2)
Beispiel #3
0
    def test_srtm_zhou2003_fit(self, BP, R1, startActivity):
        self.t, self.dt, self.TAC, self.refTAC = generate_fakeTAC_SRTM(BP, R1)
        self.model = SRTM_Zhou2003(self.t,
                                   self.dt,
                                   self.TAC,
                                   self.refTAC,
                                   startActivity=startActivity)

        print('\nFitting SRTM_Zhou2003 with %s start activity' % startActivity)
        self.model.fit()

        print('True BP = %.6f; estimated BP = %.6f; percent error = %.1E' % \
              (BP, self.model.results['BP'],
               100*abs(BP-self.model.results['BP'])/BP))
        print('True R1 = %.6f; estimated R1 = %.6f; percent error = %.1E' % \
              (R1, self.model.results['R1'],
               100*abs(R1-self.model.results['R1'])/R1))
        self.assertAlmostEqual(BP, self.model.results['BP'], delta=5e-3)
        self.assertAlmostEqual(R1, self.model.results['R1'], delta=5e-2)
# In[7]:

# Initialize SRTM Lammerstma 1996 model
mdl_lammertsma = SRTM_Lammertsma1996(t,
                                     dt,
                                     TAC_matrix,
                                     refTAC,
                                     time_unit='min')

# fit model
mdl_lammertsma.fit()

# In[8]:

# Initialize SRTM Zhou 2003 model
mdl_zhou = SRTM_Zhou2003(t, dt, TAC_matrix, refTAC, time_unit='min')

mdl_zhou.fit()

# In[9]:

# we now take advantage of the spatial constraint capabilities of Zhou model

# Initialize SRTM Zhou 2003 model
mdl_zhou_spatial_constraint = SRTM_Zhou2003(t,
                                            dt,
                                            TAC_matrix,
                                            refTAC,
                                            time_unit='min')

# we first reorganize the TAC data in a 4-D matrix and apply Gaussian smoothing to
Beispiel #5
0
# get model results
mdl_lammertsma.results

# In[91]:

mdl_gunn = SRTM_Gunn1997(t, dt, TAC, refTAC, time_unit='min')

mdl_gunn.fit()

mdl_gunn.results

# In[307]:

# Initialize SRTM Zhou 2003 model
mdl_zhou = SRTM_Zhou2003(t, dt, TAC, refTAC, time_unit='min')

mdl_zhou.fit()

mdl_zhou.results

# In[296]:

# Generate noisy simulations by adding normal noise -- I don't think this is a good way
pct_noise = np.array([0, 5, 10, 15, 20, 25, 30])

TAC_matrix = TAC + np.random.normal(0, np.outer(TAC, pct_noise / 100).T)

# In[297]:

fig, ax = plt.subplots()
Beispiel #6
0
local_install_path = 'H:\gitrepos\kineticmodel'
data_path = local_install_path + '/data/nru/'
# loading real volumetric data
inputTac_filename = os.path.join(data_path, 'input.mni305.2mm.sm6.nii.gz')
cerebMask_filename = os.path.join(data_path, 'cereb.mni305.2mm.nii.gz')
tim_filename = os.path.join(data_path, 'info_tim.csv')

inputTac = nib.load(inputTac_filename)
cerebMask = nib.load(cerebMask_filename)

# using Zhou's algorithm to run it
# Note: The srtm Lammertsmaa implementation is very slow in the volume and hence not shown here
results_img = SRTM_Zhou2003.volume_wrapper(
    timeSeriesImgFile=inputTac_filename,
    frameTimingCsvFile=tim_filename,
    refRegionMaskFile=cerebMask_filename,
    time_unit='s',
    startActivity='flat',
    fwhm=(2 * np.sqrt(2 * np.log(2))) * 5)

# In[2]:

results_img.keys()
BP_img = results_img['BP']

import matplotlib.pyplot as plt
get_ipython().magic('matplotlib inline')
plt.imshow(BP_img[:, :, 20])

# In[3]:
ax.set_title('Real PET data');
ax.legend();


# In[5]:

# Initialize SRTM Lammerstma 1996 model
mdl_lammertsma = SRTM_Lammertsma1996(t, dt, TAC, refTAC, time_unit='s')

# fit model
mdl_lammertsma.fit();

# get model results
mdl_lammertsma.results


# In[6]:

# Initialize SRTM Zhou 2003 model
mdl_zhou = SRTM_Zhou2003(t, dt, TAC, refTAC, time_unit='s')

mdl_zhou.fit();

mdl_zhou.results


# In[ ]: