Exemplo n.º 1
0
    def make_4dvol_frommaps(self):
        #load maps bv,mtt,bf,sigma
        perfmap_art = nib.load(
            self.dir_manager.get_path('perf_map')).get_data()
        perfmap_port = nib.load(
            os.path.join(
                self.dir_manager.get_path('perf_map')[:-7] +
                '2.nii.gz')).get_data()

        perfmap = np.concatenate(
            (perfmap_art[..., (1, 0, 3)], perfmap_port[..., (1, 0, 3)]),
            axis=3)
        perfmap[..., (0, 3)] /= 100.

        perfmap2d = perfmap.reshape(
            (np.prod(perfmap.shape[:-1]), perfmap.shape[-1]))
        pars_subset = perfmap2d[np.where(perfmap2d[..., 0] != 0)]

        #load input tacs
        times = self.rois.get_time_list()
        new_time_steps = np.arange(times[0], times[-1] + 1, 2)

        input_tac = np.array(self.rois.get_concentrations('aorta'))
        input_tac -= input_tac[0]
        input_tac_smoothed, input_tac_splines = express.spline_interpolation(
            input_tac, times, new_time_steps)
        try:
            input_tac2 = np.array(self.rois.get_concentrations('porta'))
            input_tac2 -= input_tac2[0]
            input_tac_smoothed2, input_tac_splines2 = express.spline_interpolation(
                input_tac2, times, new_time_steps)
        except:
            input_tac2 = None
            pass

        vol4d = express.calc_tissue_tac_from_pars(input_tac_smoothed,
                                                  input_tac_smoothed2,
                                                  time_steps=new_time_steps,
                                                  time_subset=[60, 70, 80],
                                                  params=pars_subset)

        vol4d = vol4d.reshape(
            (np.prod(perfmap.shape[:-1]), vol4d_2d.shape[-1]))

        hdr = nib.load(self.dir_manager.get_path('4d')).get_header()
        mrx = hdr.get_sform()
        nii_im = nib.Nifti1Image(out_vol, mrx, hdr)
        nib.save(
            nii_im,
            os.path.join(self.dir_manager.get_path('4D')[:-4] + '2.nii.gz'))
Exemplo n.º 2
0
    def make_4dvol_frommaps(self):
        #load maps bv,mtt,bf,sigma
        perfmap_art = nib.load(self.dir_manager.get_path('perf_map')).get_data() 
        perfmap_port = nib.load(os.path.join(self.dir_manager.get_path('perf_map')[:-7]+'2.nii.gz')).get_data() 

        perfmap = np.concatenate((perfmap_art[...,(1,0,3)],perfmap_port[...,(1,0,3)]),axis=3)
        perfmap[...,(0,3)] /= 100.

        

        perfmap2d = perfmap.reshape( (np.prod(perfmap.shape[:-1]),perfmap.shape[-1]) )
        pars_subset = perfmap2d[ np.where(perfmap2d[...,0] != 0)]
        

        #load input tacs
        times = self.rois.get_time_list()
        new_time_steps = np.arange(times[0], times[-1] + 1, 2)

        input_tac = np.array(self.rois.get_concentrations('aorta'))
        input_tac -= input_tac[0]
        input_tac_smoothed, input_tac_splines = express.spline_interpolation(input_tac, times, new_time_steps)
        try:
            input_tac2 = np.array(self.rois.get_concentrations('porta'))
            input_tac2 -= input_tac2[0]
            input_tac_smoothed2, input_tac_splines2 = express.spline_interpolation(input_tac2, times, new_time_steps)
        except:
            input_tac2 = None
            pass

        



        vol4d = express.calc_tissue_tac_from_pars(input_tac_smoothed,
                                                  input_tac_smoothed2,
                                                  time_steps=new_time_steps,
                                                  time_subset=[60,70,80],
                                                  params=pars_subset)
        

        vol4d = vol4d.reshape( (np.prod(perfmap.shape[:-1]),vol4d_2d.shape[-1]) )

        hdr = nib.load(self.dir_manager.get_path('4d')).get_header()
        mrx = hdr.get_sform()
        nii_im = nib.Nifti1Image(out_vol, mrx, hdr)
        nib.save(nii_im, os.path.join(self.dir_manager.get_path('4D')[:-4]+'2.nii.gz'))
Exemplo n.º 3
0
    def get_limit(self):
        #load input tacs
        times = self.rois.get_time_list()
        new_time_steps = np.arange(times[0], times[-1] + 1, 1)

        input_tac = np.array(self.rois.get_concentrations('aorta'))
        input_tac -= input_tac[0]
        input_tac_smoothed, input_tac_splines = express.spline_interpolation(
            input_tac, times, new_time_steps)
        try:
            input_tac2 = np.array(self.rois.get_concentrations('porta'))
            input_tac2 -= input_tac2[0]
            input_tac_smoothed2, input_tac_splines2 = express.spline_interpolation(
                input_tac2, times, new_time_steps)
        except:
            input_tac2 = None
            pass

        pars_subset = express.perf_pars_gen(bvs=np.arange(0.01, 0.1, 0.05),
                                            mtts=np.arange(10, 100, 10),
                                            sigmas=np.arange(0.1, 2, 0.5),
                                            lags=(0, ))

        vol4d = express.calc_tissue_tac_from_pars(input_tac_smoothed,
                                                  input_tac_smoothed2,
                                                  time_steps=new_time_steps,
                                                  time_subset=times,
                                                  params=pars_subset)

        max_hu = np.max(vol4d, axis=0)
        print np.array(np.where(pars_subset[:, 5] < 0.1)).shape
        sp = np.array(
            np.where(pars_subset[:, 1] < 0.1) +
            np.where(pars_subset[:, 5] < 0.1))[0]
        print sp.shape
        plt.plot(times, vol4d[:, sp], 'o-', alpha=0.05, color='red')
        plt.show()
Exemplo n.º 4
0
    def get_limit(self):
        #load input tacs
        times = self.rois.get_time_list()
        new_time_steps = np.arange(times[0], times[-1] + 1, 1)

        input_tac = np.array(self.rois.get_concentrations('aorta'))
        input_tac -= input_tac[0]
        input_tac_smoothed, input_tac_splines = express.spline_interpolation(input_tac, times, new_time_steps)
        try:
            input_tac2 = np.array(self.rois.get_concentrations('porta'))
            input_tac2 -= input_tac2[0]
            input_tac_smoothed2, input_tac_splines2 = express.spline_interpolation(input_tac2, times, new_time_steps)
        except:
            input_tac2 = None
            pass

        
        pars_subset = express.perf_pars_gen(bvs=np.arange(0.01,0.1,0.05),
                                            mtts=np.arange(10,100,10),
                                            sigmas=np.arange(0.1,2,0.5),
                                            lags=(0,))



        vol4d = express.calc_tissue_tac_from_pars(input_tac_smoothed,
                                                  input_tac_smoothed2,
                                                  time_steps=new_time_steps,
                                                  time_subset=times,
                                                  params=pars_subset)
        
        max_hu = np.max(vol4d ,axis=0)
        print np.array(np.where(pars_subset[:,5]<0.1)).shape
        sp = np.array(np.where(pars_subset[:,1]<0.1)+np.where(pars_subset[:,5]<0.1))[0]
        print sp.shape
        plt.plot(times,vol4d[:,sp],'o-',alpha=0.05,color='red')
        plt.show()
Exemplo n.º 5
0
                                    mtts2=(0, ),
                                    sigmas2=(0, ),
                                    lags2=(0, ))
pancreatic_pars = np.array([[1, 0.46, 0, 20, 0, 0, 0, 0],
                            [9, 0.28, 0, 16, 0, 0, 0, 0],
                            [6, 0.41, 0, 16, 0, 0, 0, 0],
                            [11, 0.25, 0, 11, 0, 0, 0, 0],
                            [9, 0.33, 0, 23, 0, 0, 0, 0],
                            [1, 0.41, 0, 15, 0, 0, 0, 0],
                            [7, 0.29, 0, 27, 0, 0, 0, 0]])
tumor_pars = np.array([
    [10, 0.2, 0, 35, 0, 0, 0, 0],
])

pancreatic_tac = express.calc_tissue_tac_from_pars(input_tac_smoothed,
                                                   time_steps=new_time_steps,
                                                   time_subset=time_steps,
                                                   params=pancreatic_pars)
tumor_tac = express.calc_tissue_tac_from_pars(input_tac_smoothed,
                                              time_steps=new_time_steps,
                                              time_subset=time_steps,
                                              params=tumor_pars)
plt.plot(times, AORTA / 10.)
plt.plot(new_time_steps, input_tac_smoothed / 10.)
#print AORTA>100
#print np.where(AORTA>100)[0][0]
print pancreatic_tac[0]
#plt.plot(new_time_steps,pancreatic_tac,alpha=0.3)
plt.plot(time_steps, pancreatic_tac[:, 0], 'g')
#plt.plot(new_time_steps,pancreatic_tac[:,1],'b')
plt.plot(time_steps, pancreatic_tac[:, 2], 'k')
diff_tac = pancreatic_tac - tumor_tac
Exemplo n.º 6
0
                                    mtts2=(0,),
                                    sigmas2=(0,),
                                    lags2=(0,))
pancreatic_pars = np.array([[1.2,0.7,0,81,0,0,0,0],
                            [9,0.28,0,16,0,0,0,0],
                            [6,0.41,0,16,0,0,0,0],
                            [11,0.25,0,11,0,0,0,0],
                            [9,0.33,0,23,0,0,0,0],
                            [1,0.41,0,15,0,0,0,0],
                            [7,0.29,0,27,0,0,0,0]
                           ])
tumor_pars = np.array([[20,0.15,0,31,0,0,0,0],])


pancreatic_tac = express.calc_tissue_tac_from_pars(input_tac_smoothed,
                                          time_steps=new_time_steps,
                                          time_subset=time_steps,
                                          params=pancreatic_pars )
tumor_tac = express.calc_tissue_tac_from_pars(input_tac_smoothed,
                                          time_steps=new_time_steps,
                                          time_subset=time_steps,
                                          params=tumor_pars )


plt.plot(times,AORTA/10.)
#plt.plot(new_time_steps,input_tac_smoothed/10.)
#print AORTA>100
#print np.where(AORTA>100)[0][0]
print pancreatic_tac[0]
#plt.plot(new_time_steps,pancreatic_tac,alpha=0.3)
plt.plot(time_steps,pancreatic_tac[:,0],'g')
#plt.plot(new_time_steps,pancreatic_tac[:,1],'b')
Exemplo n.º 7
0
reference_tacs, reference_pars = expr.calc_tissue_tac_mrx_conv2(input_tac_smoothed,
                                                                    input_tac_smoothed2,
                                                                    time_steps=new_time_steps,
                                                                    time_subset=times,
                                                                    rc_type='lognorm',
                                                                    mtts=MTT_range_a,
                                                                    bvs=BV_range_a,
                                                                    rc_sigma=S_range_a,
                                                                    lags=[0])

#plots


reference_tacs = expr.calc_tissue_tac_from_pars(input_tac_smoothed,
                                                input_tac_smoothed2,
                                                time_steps=new_time_steps,
                                                time_subset=times,
                                                rc_type='lognorm',
                                                params = reference_pars)

plt.plot(times,input_tac2)
plt.plot(new_time_steps,input_tac_smoothed2)
plt.plot(times,input_tac)
plt.plot(new_time_steps,input_tac_smoothed)
plt.show()


for tac,pars in zip(reference_tacs, reference_pars):
	print pars
	plt.plot(times,tac,'o-',color=(pars[1],1,pars[5]),alpha=0.5)
plt.show()
Exemplo n.º 8
0
reference_tacs, reference_pars = expr.calc_tissue_tac_mrx_conv2(
    input_tac_smoothed,
    input_tac_smoothed2,
    time_steps=new_time_steps,
    time_subset=times,
    rc_type='lognorm',
    mtts=MTT_range_a,
    bvs=BV_range_a,
    rc_sigma=S_range_a,
    lags=[0])

#plots

reference_tacs = expr.calc_tissue_tac_from_pars(input_tac_smoothed,
                                                input_tac_smoothed2,
                                                time_steps=new_time_steps,
                                                time_subset=times,
                                                rc_type='lognorm',
                                                params=reference_pars)

plt.plot(times, input_tac2)
plt.plot(new_time_steps, input_tac_smoothed2)
plt.plot(times, input_tac)
plt.plot(new_time_steps, input_tac_smoothed)
plt.show()

for tac, pars in zip(reference_tacs, reference_pars):
    print pars
    plt.plot(times, tac, 'o-', color=(pars[1], 1, pars[5]), alpha=0.5)
plt.show()