Пример #1
0
def doit(filenames):
    dataman = myutils.DataManager(
        50,
        map(lambda x: x(), detailedo2Analysis.O2DataHandlers) + [
            analyzeGeneral.DataTumorTissueSingle(),
            analyzeGeneral.DataDistanceFromCenter(),
            analyzeGeneral.DataBasicVessel(),
            analyzeGeneral.DataVesselSamples(),
            analyzeGeneral.DataVesselRadial(),
            analyzeGeneral.DataVesselGlobal(),
            analyzeBloodFlow.DataTumorBloodFlow()
        ])
    ensemble = EnsembleFiles(dataman, filenames, 'po2/adaption/')
    out_prefix, out_suffix = myutils.splitcommonpresuffix(
        map(lambda s: basename(s), filenames))
    output_base_filename = splitext(out_prefix + out_suffix)[0]
    if ensemble.o2ConfigName:
        fn_measure = 'detailedo2_%s_common.h5' % ensemble.o2ConfigName
    else:
        fn_measure = 'detailedo2_common.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)

    measurementinfo = MeasurementInfo(sample_length=30.,
                                      cachelocation_callback=cachelocation,
                                      distancemap_spec='radial')

    with mpl_utils.PageWriter(output_base_filename + '.pdf',
                              fileformats=['pdf']) as pdfwriter:
        if 0:
            compare_tissue_saturation(dataman, ensemble, pdfwriter)

        if 0:
            #try:
            #  histogramGroupFinal   = f_measure['combinedHistogramsFinal']
            #  histogramGroupInitial = f_measure['combinedHistogramsInitial']
            #except KeyError:

            #histogramGroupFinal   = f_measure.recreate_group('combinedHistogramsFinal')
            histogramGroupInitial = f_measure.recreate_group(
                'combinedHistogramsInitial')
            #ComputeHistogramsOfPo2Items(dataman, ensemble.items, measurementinfo, histogramGroupFinal)
            ComputeHistogramsOfPo2Items(dataman, ensemble.items,
                                        measurementinfo, histogramGroupInitial)
            #PlotHistograms(pdfwriter, histogramGroupFinal, 'tum', 'Tumor')
            PlotHistograms(pdfwriter, histogramGroupInitial, 'all', 'Initial')
Пример #2
0
    def cachelocation(dataname, vesselgroup, tumorgroup, version):
        path = myutils.splitPath(
            posixpath.join(
                splitext(basename(vesselgroup.file.filename))[0],
                vesselgroup.name.strip(posixpath.sep))) + (dataname, )
        return (f_measure, path)

    def cachelocationEnsemble(dataname, groups):
        groupchecksum = myutils.checksum(*map(
            lambda g: str(g.file.filename + '/' + g.name), sum(groups, [])))
        path = ('%s_%s' % (dataname, groupchecksum), )
        return (f_measure, path)

    dataman = myutils.DataManager(20, [
        analyzeGeneral.DataTumorTissueSingle(),
        analyzeGeneral.DataDistanceFromCenter(),
        analyzeGeneral.DataBasicVessel(),
        analyzeGeneral.DataVesselSamples(),
        DataPressureMvdCorrelation(200., 5, 30., cachelocation,
                                   cachelocationEnsemble)
    ])

    if not options.picz:
        print '-----------computing sammples------------'
        localSamples = dataman.obtain_data('intervascular_map_correlations',
                                           thegroups)
        globalSamples = dataman.obtain_data(
            'intervascular_global_correlations', thegroups)
        print '--------------plotting ---------------'

        with mpl_utils.PageWriter(outputbasename + '_mvd-grad.pdf',
Пример #3
0
def DoIt(filenames, pattern, with_o2):
    fn_measure = basename(commonprefix(filenames))
    fn_measure = myutils.strip_from_end(fn_measure, '.h5')
    fn_measure = myutils.strip_from_end(fn_measure, '-type')

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

    if with_o2:
        fn_measure = myutils.strip_from_end(fn_measure, '_detailedpo2')

    files = [h5files.open(fn, 'a') for fn in filenames]
    f_measure = h5files.open('plotVessels_chache.h5', 'a', search=False)
    groups = list(
        itertools.chain.from_iterable(
            myutils.walkh5(f, pattern, return_h5objects=True) for f in files))
    if len(groups) <= 0:
        print 'no matching groups in hdf file(s)'
        sys.exit(0)

    if with_o2:
        name = posixpath.commonprefix(map(lambda g: g.name, groups))
        name = myutils.strip_from_start(name, '/po2/vessels').replace('/', '-')
        fn_measure += name

    with mpl_utils.PdfWriter(fn_measure + '.pdf') as pdfpages:
        rc = matplotlib.rc
        rc('font', size=8.)
        rc('axes', titlesize=10., labelsize=8.)

        if with_o2:
            import detailedo2Analysis as o2analysis
            import detailedo2Analysis.plotsForPaper
            import detailedo2
            dataman = myutils.DataManager(20, [
                o2analysis.DataDetailedPO2(),
                analyzeGeneral.DataTumorTissueSingle(),
                analyzeGeneral.DataDistanceFromCenter(),
                analyzeGeneral.DataBasicVessel(),
                analyzeGeneral.DataVesselSamples(),
                analyzeBloodFlow.DataTumorBloodFlow(),
                analyzeGeneral.DataVesselRadial(),
                analyzeGeneral.DataVesselGlobal()
            ])

            vesselgroups = list(
                detailedo2.OpenVesselAndTumorGroups(g)[0] for g in groups)
            #original_vesselgroups = list(h5files.openLink(g, 'SOURCE') for g in vesselgroups)
            if 1:
                PrintGlobalDataWithOxygen(pdfpages, groups, vesselgroups,
                                          f_measure, dataman)
                '''FormatParameters makes the network creation parameters
            that does not work, if we have an o2 file'''
                #text = FormatParameters(original_vesselgroups[0].file)
                text = [' ']
                text += detailedo2Analysis.plotsForPaper.FormatParameters(
                    groups[0])
                fig, _ = mpl_utils.MakeTextPage(text,
                                                figsize=(mpl_utils.a4size[0],
                                                         mpl_utils.a4size[0]))
                pdfpages.savefig(fig, postfix='_vesselsparams')
            if 1:
                res = getMultiScatter(300. * len(filenames), vesselgroups)
                plotMultiScatterBeauty(res, pdfpages)

        else:
            dataman = myutils.DataManager(20, [
                analyzeGeneral.DataTumorTissueSingle(),
                analyzeGeneral.DataVesselRadial(),
                analyzeGeneral.DataDistanceFromCenter(),
                analyzeBloodFlow.DataTumorBloodFlow(),
                analyzeGeneral.DataBasicVessel(),
                analyzeGeneral.DataVesselSamples(),
                analyzeGeneral.DataVesselGlobal()
            ])
            #dataman = myutils.DataManager(20, [ analyzeGeneral.DataBasicVessel(), analyzeGeneral.DataVesselSamples(), analyzeGeneral.DataVesselGlobal()])
            vesselgroups = groups

            if 0:
                res = getMultiScatter(300. * len(filenames), vesselgroups)
                plotMultiScatterBeauty(res, pdfpages)
            if 0:
                PlotRadiusHistogram2(dataman, vesselgroups, pdfpages)

            if 0 and all(map(lambda g: 'data' in g.parent, vesselgroups)):
                data = VesselData()
                for g in vesselgroups:
                    data.add(g.parent['data'])
                plot_topological_stats_avg(data, pdfpages)
            if 0:  #reproduce swine
                plot_geometric_stuff_on_RC(dataman, f_measure, filenames,
                                           options, pdfpages)
            if 1:
                PrintGlobalData(pdfpages, vesselgroups, f_measure, dataman)