Beispiel #1
0
def analyzeTumorShape(dataset,
                      do_curvature=True,
                      do_integrals=True,
                      do_linecomps=False,
                      contourspec=('S', 0.)):
    out = Struct()
    #generate tumorsurface
    contour_name, contour_value = contourspec
    assert contour_value in (0., 0.5)
    dataset.GetPointData().SetActiveScalars(contour_name)
    iso = vtkcommon.vtkContour(dataset, contour_value)
    # measurement
    if do_linecomps:
        lc, pts = vtkcommon.vtkGetLineComponents(iso)
        out['lines'] = lc
        out['points'] = pts
    if do_curvature:
        # curvature
        tmp = vtkcommon.vtkCurvature(iso, 9)
        out['curvature'] = np.asarray(vtkcommon.fromVtkArray(
            tmp.GetPointData().GetArray("curvature")),
                                      dtype=np.float32)
        del tmp
    if do_integrals:
        # integrate volume (area, length)
        _, _, out['iso_area'] = vtkcommon.vtkIntegrateData(iso)
        # integrated data
        cd, pd, volume = vtkcommon.vtkIntegrateData(dataset)
        cd = dict((dataset.GetCellData().GetArray(i).GetName(), cd[i])
                  for i in xrange(dataset.GetCellData().GetNumberOfArrays()))
        pd = dict((dataset.GetPointData().GetArray(i).GetName(), pd[i])
                  for i in xrange(dataset.GetPointData().GetNumberOfArrays()))
        data = cd.copy()
        data.update(pd)
        out['tumor_volume'] = (
            data[contour_name] +
            volume) * 0.5 if contour_value == 0 else data[contour_name]
        out['radius_estimate'] = math.sqrt(out.tumor_volume / math.pi)
        out['area_estimate'] = 2. * math.pi * out.radius_estimate
    return out
  size = (401, 41, 41),
  scale = 10.,  # gives 4 x 0.4 x 0.4 mm^3 length
  pgrad = PressureGradientFromFlowRate(3.3e6, 50., _paramsbf),
  r = 50.,
  ld_type = 'quad',
  direction_mode = 0,
)

basecase = namedtuple('Params', 'paramsbf, paramspo2, paramsTube')(_paramsbf, _paramspo2, _paramstube)

basecase.paramspo2['massTransferCoefficientModelNumber'] = 1
basecase.paramspo2['conductivity_coeff1'] = 7.2
basecase.paramspo2['conductivity_coeff2'] = 4.0
basecase.paramspo2['conductivity_coeff3'] = 0.0

literature_cases = Struct()

# this is supposed to reproduce the cases from nair 1989
# where o2 diffuses from a perfused pipe through a block
# of rubber.
nair_release = deepcopy(basecase)
nair_release.paramsTube['size'] = (401, 19, 19)
nair_release.paramsTube['r'] = 27*0.5   # FUUUU ... paper gives diameter, must convert to radius
nair_release.paramsTube['pgrad'] = PressureGradientFromFlowRate(3.3e6, 27.*0.5, _paramsbf)  # flow rate of 12 ul /hr
nair_release.paramspo2['tissue_po2_boundary_condition'] = 'dirichlet_yz'
nair_release.paramspo2['po2init_r0'] = 160
nair_release.paramspo2['po2init_cutoff'] = 160
nair_release.paramspo2['mmcons_m0_tum'] = 0
nair_release.paramspo2['mmcons_m0_norm'] = 0
nair_release.paramspo2['solubility_tissue'] = 1
nair_release.paramspo2['D_tissue'] = 0.94
Beispiel #3
0
 def __init__(self):
     self.data = Struct(rBV_by_iter=[],
                        radii_prob=[],
                        lengths_by_rad=[],
                        lengths_prob=[],
                        num_branches_by_rad=[])
Beispiel #4
0
import os, sys
import h5py
import os, sys
import posixpath
import numpy as np
import collections
import matplotlib
import matplotlib.pyplot as plt
import mpl_utils
import extensions

from mystruct import Struct
import myutils

dataconfigs = [
    Struct(name='kdiff_cells', rng='auto', title=r'kdiff_cells'),
    Struct(name='kdiff_obst', rng='auto', title=r'kdiff_obst'),
    Struct(name='necro', rng=(-0.1, 1.1), title=r'necro'),
    Struct(name='totalconc', rng=None, title=r'vol. ratio $\phi + m$'),
    Struct(name='conc', rng=(-0.1, 1.1), title=r'vol. ratio $\phi$'),
    Struct(name='conc_necro', rng=(-0.1, 1.1), title=r'vol. ratio $d$'),
    Struct(name='obstacle', rng=(-0.1, 1.1), title=r'obst. ratio $m$'),
    Struct(name='oxy', rng=(-0.1, 1.1), title=r'O$_2\, c$'),
    Struct(name='oxy_sources', rng=(-0.1, 1.1), title=r'$\Gamma_c$'),
    Struct(name='fieldOxy', rng=(-0.1, 1.1), title=r'O$_2$'),
    Struct(name='vel_0', rng='auto', coords='xface', title=r'$v_x$'),
    Struct(name='ls', rng='zero-centered', title=r'$\theta$'),
    Struct(name='vel', rng='zero-centered', title=r'$v_x$'),
    Struct(name='press', rng='auto', title=r'pressure $\Sigma$'),
    Struct(name='ptc', rng=(0., 1.), title=r'$\Theta_\epsilon(\theta)$'),
    Struct(name='sources',
Beispiel #5
0
def H5PrintOpt():
    return Struct(recursive=False,
                  print_full_dataset=0,
                  print_attributes=False,
                  print_eval=None)