Exemplo n.º 1
0
 def IntensityFrame2(self):
     buf, att = im7.readim7(self.s)
     frame1 = buf.get_frame(1)
     bfunc = np.vectorize(lambda a, b: a if a>=b else 0)
     binarize_frame1 = bfunc(frame1, mahotas.thresholding.otsu(frame1))
     buf.delete()
     att.delete()
     return str(np.mean(binarize_frame1)) 
Exemplo n.º 2
0
#Copyright (C) 2010 Fabricio Silva

"""
"""

import sys
sys.path.append('..')
import numpy as np
trace = True
flags = [True, True, True, True]

if trace:
    import matplotlib.pyplot as plt
    # Figure1 : vx, 2:vy, 3:vz
    f1 = plt.figure(1)
    ax = f1.add_subplot(111)
    
nx, ny = 118, 78
d = {'interpolation':'nearest', 'vmin':-10, 'vmax':10, 'origin':'upper'}
# libim7
if flags[0]:
    import libim7 as im7
    buf1, att1 = im7.readim7('PTV_B00013.VC7')
    dx = {}#'extent':(buf1.x[0],buf1.x[-1],buf1.y[0],buf1.y[-1])}
    dx.update(d)
    if trace:
        ax.quiver(buf1.x, buf1.y, buf1.vx, buf1.vy, np.sqrt(buf1.vx**2+buf1.vy**2), 
                  scale=1.5)
if trace:
    plt.show()
Exemplo n.º 3
0
@author: rahmann
"""

import glob
import numpy as np
from os import path
from libim7 import readim7

im7_folder = "E:\\DaVisProjects\\DaVis10_IJ_Sept2019\\IJ\\0p30\\5Passes_5x5 Gaussian smoothing filter\\MaskOutImage\\" + \
                   "AddCameraAttributes\\AddAttributes\\CompressExpand\\Mult\\MART_(iterations=1000,smooth=0.5,1000,sparse=0)\\Data\\S00001\\"

im7_files = glob.glob(im7_folder + "*.im7")

for n, im7_file in enumerate(im7_files):
    buf, att = readim7(im7_file)

    if n == 0:
        # Number of voxels in X, Y, Z
        nx = buf.nx
        ny = buf.ny
        nz = len(im7_files)
        volume = np.zeros((nx, ny, nz))

    volume[:, :, n] = buf.blocks.T[:, :, 0]

# Millimeters per voxel from calibration
scale_x = float(att['_SCALE_X'].rsplit(' ')[0])
scale_y = float(att['_SCALE_Y'].rsplit(' ')[0])
scale_z = float(att['_SCALE_Z'].rsplit(' ')[0])
Exemplo n.º 4
0
    # Figure1 : vx, 2:vy, 3:vz
    f1 = plt.figure(1)
    ax0 = f1.add_subplot(211)
    ax1 = f1.add_subplot(212)
    lAxs = (ax0, ax1)
    
d = {
    'interpolation':'nearest', 
#    'vmin':-10, 'vmax':10, 
    'origin':'upper', 
    'aspect':'auto'}

lBuf = []
for ind, ext in enumerate(lExt[::-1]):
    fname = __file__.replace(".py", ext)
    buf1, att1 = im7.readim7(fname)
    lBuf.append(buf1)
    dx = {'extent':(buf1.x[0],buf1.x[-1],buf1.y[0],buf1.y[-1])}
    dx.update(d)
    if trace:
        im = lAxs[ind].imshow(buf1.get_frame(0), **dx)
        lAxs[ind].text(.02, .02, fname, transform=lAxs[ind].transAxes)
        lAxs[ind].set_xlabel(buf1.scaleX.description.replace('\n',' ')+buf1.scaleX.unit)
        lAxs[ind].set_ylabel(buf1.scaleY.description.replace('\n',' ')+buf1.scaleY.unit)
        cb = plt.colorbar(im, ax = lAxs[ind])
        cb.set_label(buf1.scaleI.description.replace('\n',' ')+buf1.scaleI.unit)
if trace:
    plt.savefig(__file__.replace('.py', '.pdf'))
    plt.close('all')
    #plt.show()
Exemplo n.º 5
0
    f1 = plt.figure(1)
    ax0 = f1.add_subplot(211)
    ax1 = f1.add_subplot(212)
    lAxs = (ax0, ax1)

d = {
    'interpolation': 'nearest',
    #    'vmin':-10, 'vmax':10,
    'origin': 'upper',
    'aspect': 'auto'
}

lBuf = []
for ind, ext in enumerate(lExt[::-1]):
    fname = __file__.replace(".py", ext)
    buf1, att1 = im7.readim7(fname)
    lBuf.append(buf1)
    dx = {'extent': (buf1.x[0], buf1.x[-1], buf1.y[0], buf1.y[-1])}
    dx.update(d)
    if trace:
        im = lAxs[ind].imshow(buf1.get_frame(0), **dx)
        lAxs[ind].text(.02, .02, fname, transform=lAxs[ind].transAxes)
        lAxs[ind].set_xlabel(
            buf1.scaleX.description.replace('\n', ' ') + buf1.scaleX.unit)
        lAxs[ind].set_ylabel(
            buf1.scaleY.description.replace('\n', ' ') + buf1.scaleY.unit)
        cb = plt.colorbar(im, ax=lAxs[ind])
        cb.set_label(
            buf1.scaleI.description.replace('\n', ' ') + buf1.scaleI.unit)
if trace:
    plt.savefig(__file__.replace('.py', '.pdf'))
Exemplo n.º 6
0
    # Figure1 : vx, 2:vy, 3:vz
    f1 = plt.figure(1)
    f2 = plt.figure(2)
    f3 = plt.figure(3)
    f1.suptitle('$V_x$')
    f2.suptitle('$V_y$')
    f3.suptitle('$V_z$')
    Ax = [f.add_subplot(221) for f in (f1, f2, f3)]
    share = lambda ind: {'sharex': Ax[ind - 1], 'sharey': Ax[ind - 1]}

nx, ny = 118, 78
d = {'interpolation': 'nearest', 'vmin': -10, 'vmax': 10, 'origin': 'lower'}
# libim7
if flags[0]:
    import libim7 as im7
    buf1, att1 = im7.readim7('SOV2_01_100_davis.VC7')
    dx = {'extent': (buf1.x[0], buf1.x[-1], buf1.y[0], buf1.y[-1])}
    dx.update(d)
    if trace:
        Ax[0].imshow(buf1.vx.T, **dx)
        Ax[1].imshow(buf1.vy.T, **dx)
        Ax[2].imshow(buf1.vz.T, **dx)
        Ax[0].text(.02, .02, 'VC7', transform=Ax[0].transAxes)

# txt: comma to dot
if flags[1]:
    f = file('SOV2_01_100_davis.txt', 'r')
    f.readline()
    string = f.read()
    f.close()
    string = string.replace(',', '.')
Exemplo n.º 7
0
    # Figure1 : vx, 2:vy, 3:vz
    f1 = plt.figure(1)
    f2 = plt.figure(2)
    f3 = plt.figure(3)
    f1.suptitle('$V_x$')
    f2.suptitle('$V_y$')
    f3.suptitle('$V_z$')
    Ax = [f.add_subplot(221) for f in (f1,f2,f3)]
    share = lambda ind: {'sharex': Ax[ind-1], 'sharey':Ax[ind-1]}
    
nx, ny = 118, 78
d = {'interpolation':'nearest', 'vmin':-10, 'vmax':10, 'origin':'lower'}
# libim7
if flags[0]:
    import libim7 as im7
    buf1, att1 = im7.readim7('SOV2_01_100_davis.VC7')
    dx = {'extent':(buf1.x[0],buf1.x[-1],buf1.y[0],buf1.y[-1])}
    dx.update(d)
    if trace:
        Ax[0].imshow(buf1.vx.T, **dx)
        Ax[1].imshow(buf1.vy.T, **dx)
        Ax[2].imshow(buf1.vz.T, **dx)
        Ax[0].text(.02, .02, 'VC7', transform=Ax[0].transAxes)

# txt: comma to dot
if flags[1]:
    f = file('SOV2_01_100_davis.txt', 'r')
    f.readline(); string = f.read(); f.close(); string = string.replace(',', '.')
    buf2 = np.fromstring(string, sep='\t').reshape((ny,nx,5))
    x, y = buf2[:,:,0][0,:], buf2[:,:,1][:,0]
    dx = {'extent':(x[0],x[-1],y[0],y[-1])}
Exemplo n.º 8
0
 def __init__(self, path):
   self.path = path.split("/")
   self.s = path 
   if path:
     self.buffer, self.attr = im7.readim7(self.s)
Exemplo n.º 9
0
"""
"""

import sys
sys.path.append('../libim7')
import numpy as np
trace = False
flags = [True, True, True, True]

if trace:
    import matplotlib.pyplot as plt
    # Figure1 : vx, 2:vy, 3:vz
    f1 = plt.figure(1)
    ax = f1.add_subplot(111)
    
nx, ny = 118, 78
d = {'interpolation':'nearest', 'vmin':-10, 'vmax':10, 'origin':'upper'}
# libim7
if flags[0]:
    import libim7 as im7
    buf1, att1 = im7.readim7('PTV_B00013.VC7')
    dx = {}#'extent':(buf1.x[0],buf1.x[-1],buf1.y[0],buf1.y[-1])}
    dx.update(d)
    if trace:
        ax.quiver(buf1.x, buf1.y, buf1.vx, buf1.vy, np.sqrt(buf1.vx**2+buf1.vy**2), 
                  scale=1.5)
if trace:
    plt.savefig(__file__.replace('.py', '.pdf'))
    plt.show()