def ProduceData(fitParameters, filename):
    from krebs.analyzeGeneral import DataBasicVessel, DataVesselSamples, DataVesselGlobal
    from krebs.detailedo2Analysis import DataDetailedPO2
    import krebs.detailedo2Analysis.singleVesselCases as singleVesselCases

    paramspo2Override = dict(
        massTransferCoefficientModelNumber=1,
        conductivity_coeff1=fitParameters[0],
        conductivity_coeff2=fitParameters[1],
        conductivity_coeff3=fitParameters[2],
    )

    f = h5files.open(filename, 'a')

    krebsutils.set_num_threads(2)
    dataman = myutils.DataManager(20, [
        DataDetailedPO2(),
        DataBasicVessel(),
        DataVesselSamples(),
        DataVesselGlobal()
    ])

    for k, params in fitCases:
        params = deepcopy(params)
        params.paramspo2.update(paramspo2Override)
        singleVesselCases.GenerateSingleCapillaryWPo2(dataman, f, k, 16,
                                                      params)
    return f
Exemplo n.º 2
0
    plotAnalyzeConvergence(dataman, pdfwriter, plotties)

    plotties[0].AddStatsPage(pdfwriter)

    plotAnalyzeIterativeConvergence(dataman, pdfwriter, plotties)
    
  pyplot.close('all')





if __name__ == '__main__':
  krebsutils.set_num_threads(2)
  dataman = myutils.DataManager(20, [DataDetailedPO2(),DataBasicVessel(), DataVesselSamples(), DataVesselGlobal()])

  fn = 'vessel-single-all.h5'
  #os.unlink(fn)
  f = h5files.open(fn,'a')
  
  GenerateSingleCapillaryWPo2(dataman, f, 'nair_uptake', 14, singleVesselParameterSets.nair_uptake)
  plot_single_capillary(dataman, f['nair_uptake'], useInsets = True)

  GenerateSingleCapillaryWPo2(dataman, f, 'nair_release', 14, singleVesselParameterSets.nair_release)
  plot_single_capillary(dataman, f['nair_release'], useInsets = True)

  grouplist = []
  for name in [ 'moschandreou_case%02i' % i for i in xrange(6) ]:
    params = getattr(singleVesselParameterSets, name)
    r = params.paramsTube['r']
Exemplo n.º 3
0
        plotAnalyzeConvergence(dataman, pdfwriter, plotties)

        plotties[0].AddStatsPage(pdfwriter)

        plotAnalyzeIterativeConvergence(dataman, pdfwriter, plotties)

    pyplot.close('all')


if __name__ == '__main__':
    krebsutils.set_num_threads(2)
    dataman = myutils.DataManager(20, [
        DataDetailedPO2(),
        DataBasicVessel(),
        DataVesselSamples(),
        DataVesselGlobal()
    ])

    fn = 'vessel-single-all.h5'
    #os.unlink(fn)
    f = h5files.open(fn, 'a')

    GenerateSingleCapillaryWPo2(dataman, f, 'nair_uptake', 14,
                                singleVesselParameterSets.nair_uptake)
    plot_single_capillary(dataman, f['nair_uptake'], useInsets=True)

    GenerateSingleCapillaryWPo2(dataman, f, 'nair_release', 14,
                                singleVesselParameterSets.nair_release)
    plot_single_capillary(dataman, f['nair_release'], useInsets=True)

    grouplist = []
Exemplo n.º 4
0
def doit(filenames, pattern):
    dataman = myutils.DataManager(20, [
        DataTumorTissueSingle(),
        DataDistanceFromCenter(),
        DataBasicVessel(),
        DataVesselSamples(),
        DataVesselRadial(),
        DataVesselGlobal(),
        DataTumorBloodFlow()
    ])

    ensemble = EnsembleFiles(dataman, filenames, pattern)
    if ensemble.has_tumor:
        print 'paths: ', map(lambda (_t0, path, _t1): path,
                             ensemble.tumor_snapshots)
    else:
        print 'paths: ', set(map(lambda e: e.path, ensemble.items))

    prefix, suffix = myutils.splitcommonpresuffix(
        map(lambda s: basename(s), filenames))
    outputbasename, _ = splitext(prefix + suffix)
    fn_measure = outputbasename + '-radial-cache.h5'
    f_measure = h5files.open(fn_measure, 'a')

    def cachelocation(g):
        path = posixpath.join(
            'FileCS_' + myutils.checksum(basename(g.file.filename)),
            g.name.strip(posixpath.sep))
        return (f_measure, path)

    #name = ensemble.items[0].path.split('/')[-1]
    measurementinfo = dict(sample_length=30.,
                           cachelocation_callback=cachelocation,
                           distancemap_spec='radial')

    print 'getting radial curves'
    stuff = []
    stuff2 = []
    for items, path, time in ensemble.tumor_snapshots:
        bins_spec, curves = CollectAllRadialData(dataman, items,
                                                 measurementinfo)
        tumorradius = GetAverageApproximateTumorRadius(dataman, ensemble,
                                                       items)
        stuff.append((time, tumorradius, curves))
        stuff2.append((time, tumorradius, curves, path))

    #output_filename+= '_'+name
    with mpl_utils.PdfWriter(outputbasename + '-radial.pdf') as pdfwriter:
        PlotRadialCurves(pdfwriter, bins_spec, stuff, measurementinfo,
                         ensemble.world_size)

    with h5py.File(outputbasename + '-radial.h5', 'w') as f:
        f.attrs['COMMONPREFIX'] = os.path.commonprefix(
            map(lambda s: basename(s), filenames))
        f.create_dataset('files', data=filenames)
        f.create_dataset('groups',
                         data=np.asarray(set(
                             map(lambda item: item.path, ensemble.items)),
                                         dtype=np.str))
        for i, (time, tumorradius, curves, path) in enumerate(stuff2):
            g = f.create_group(path.strip('/').replace('/', '-'))
            g.attrs['TUMORRADIUS'] = tumorradius
            g.attrs['TIME'] = time
            for name, curve in curves.iteritems():
                curve = myutils.MeanValueArray.fromSummation(
                    map(lambda x: x.avg, curve))
                g.create_dataset(name + '/avg', data=np.asarray(curve.avg))
                g.create_dataset(name + '/std', data=np.asarray(curve.std))
                g.create_dataset(name + '/mask', data=~curve.avg.mask)
                g.create_dataset(name + '/std_mean',
                                 data=np.asarray(curve.std_mean))
            g.create_dataset('bins', data=bins_spec.arange())