def plotShapeMetrics(resultfile, pdfpages): ld = resultfile.obtain_data('ld') # get data as time series data = collections.defaultdict(list) for groupname in resultfile.groupnames: metrics = resultfile.obtain_data('shape_metrics', groupname) for k, v in metrics.iteritems(): data[k].append(v) data['time'].append(resultfile.obtain_data('time', groupname)) # plot it for groupname in resultfile.groupnames[-1:]: metrics = resultfile.obtain_data('shape_metrics', groupname) curv, curv_weights = resultfile.obtain_data('curvature_samples', groupname) #pprint.pprint(metrics) fig, axes = pyplot.subplots(2, 2, figsize=(8, 6)) text = [] text += [ 'time : {}'.format(f2s(resultfile.obtain_data('time', groupname))) ] text += [ 'surface tension : {}'.format( f2s( float(resultfile.f['parameters/tumor']. attrs['surface_tension']))) ] text += ['sphericity : {}'.format(f2s(metrics['sphericity']))] text += ['approx. radius : {}'.format(f2s(metrics['radius']))] text = '\n'.join(text) axes[0, 0].text(0.1, 0.1, text, fontsize=14) mpl_utils.remove_frame(axes[0, 0]) h, bins = np.histogram(curv, bins=10, weights=curv_weights, normed=True) bins = 0.5 * (bins[1:] + bins[:-1]) axes[0, 1].bar(bins, h, width=bins[1] - bins[0]) axes[0, 1].set(title=ur'$\kappa$', xlabel=ur'[1/\u03BCm]', ylabel='N') axes[1, 0].plot(data['time'], data['radius'], marker='x') axes[1, 0].set(xlabel='$t$', ylabel=r'$r_{tum}$') v, y0 = linearFit(data['time'], data['radius']) x = np.asarray([0., data['time'][-1] * 1.1]) y = y0 + v * x axes[1, 0].plot(x, y, label=ur'v = %s [\u03BCm/h]' % f2s(v)) axes[1, 0].legend() axes[1, 1].set_visible(False) fig.subplots_adjust(left=0.10, right=0.95, top=0.95, bottom=0.10, wspace=0.2, hspace=0.2) pdfpages.savefig(fig)
def plot3dRendering(resultfile, pdfpages, showVessels=False, showTumor=True): arr = resultfile.obtain_data('3drendering', resultfile.groupnames[-1], showVessels, showTumor) fig, ax = pyplot.subplots(1, 1, figsize=(8, 7)) fig.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1, wspace=0., hspace=0.) ax.imshow(arr, interpolation='none') mpl_utils.remove_frame(ax) pdfpages.savefig(fig)
origin='lower', interpolation='nearest', vmin=0., vmax=maxMVD) plt1 = ax1.imshow(grad, extent=extents, origin='lower', interpolation='nearest', vmin=0., vmax=maxGrad) ax0.contour(mask, levels=[0.], extent=extents, linewidths=0.25, colors='w') ax1.contour(mask, levels=[0.], extent=extents, linewidths=0.25, colors='w') mpl_utils.remove_frame(ax0, ax1) ax0.set(title='MVD (' + filename + ')') ax1.set(title='Grad') divider = mpl_utils.make_axes_locatable(ax0) cax = divider.append_axes("right", size="5%", pad=0.05) fig.colorbar(plt0, cax=cax) divider = mpl_utils.make_axes_locatable(ax1) cax = divider.append_axes("right", size="5%", pad=0.05) fig.colorbar(plt1, cax=cax) #pyplot.tight_layout() pdfwriter.savefig(fig)