Exemplo n.º 1
0
def _cropParallel(arg):
    """Cropping helper function to use for parallel cropping of image slices"""

    fileSource = arg[0]
    fileSink = arg[1]
    x = arg[2]
    y = arg[3]
    ii = arg[4]
    nn = arg[5]

    if ii is not None:
        pw = ProcessWriter(ii)
        pw.write("cropData: corpping image %d / %d" % (ii, nn))
        # pw.write('%s -> %s' % (fileSource, fileSink));

    data = io.readData(fileSource, x=x, y=y)
    io.writeData(fileSink, data)
Exemplo n.º 2
0
def _resampleXYParallel(arg):
    """Resampling helper function to use for parallel resampling of image slices"""
    
    fileSource = arg[0];
    fileSink = arg[1];
    dataSizeSink = arg[2];
    interpolation = arg[3];
    ii = arg[4];
    nn = arg[5];
    verbose = arg[6];
    
    pw = ProcessWriter(ii);
    if verbose:
        pw.write("resampleData: resampling in XY: image %d / %d" % (ii, nn))
    
    data = numpy.squeeze(io.readData(fileSource, z = ii));
    resampleXY(data, sink = fileSink, dataSizeSink = dataSizeSink, interpolation = interpolation, out = pw, verbose = verbose);
Exemplo n.º 3
0
def _resampleXYParallel(arg):
    """Resampling helper function to use for parallel resampling of image slices"""
    
    fileSource = arg[0];
    fileSink = arg[1];
    dataSizeSink = arg[2];
    interpolation = arg[3];
    ii = arg[4];
    nn = arg[5];
    verbose = arg[6];
    
    pw = ProcessWriter(ii);
    if verbose:
        pw.write("resampleData: resampling in XY: image %d / %d" % (ii, nn))
    
    data = numpy.squeeze(io.readData(fileSource, z = ii));
    resampleXY(data, sink = fileSink, dataSizeSink = dataSizeSink, interpolation = interpolation, out = pw, verbose = verbose);
def _processSubStack(dsr):
    """Helper to process stack in parallel"""

    sf  = dsr[0];
    pp  = dsr[1];
    sub = dsr[2];
    verbose = dsr[3];

    timer = Timer();
    pw = ProcessWriter(sub["stackId"]);
    
    if verbose:
        pw.write("processing substack " + str(sub["stackId"]) + "/" + str(sub["nStacks"]));
        pw.write("file          = " + sub["source"]);
        pw.write("segmentation  = " + str(sf));
        pw.write("ranges: x,y,z = " + str(sub["x"]) +  "," + str(sub["y"]) + "," + str(sub["z"])); 
    
    img = io.readData(sub["source"], x = sub["x"], y = sub["y"], z = sub["z"]);
    
    if verbose:
        pw.write(timer.elapsedTime(head = 'Reading data of size ' + str(img.shape)));
    
    timer.reset();
    seg = sf(img, subStack = sub, out = pw, **pp);    

    if verbose:    
        pw.write(timer.elapsedTime(head = 'Processing substack of size ' + str(img.shape)));
    
    return seg;
Exemplo n.º 5
0
def _processSubStack(dsr):
    """Helper to process stack in parallel"""

    sf  = dsr[0];
    pp  = dsr[1];
    sub = dsr[2];
    verbose = dsr[3];

    timer = Timer();
    pw = ProcessWriter(sub["stackId"]);
    
    if verbose:
        pw.write("processing substack " + str(sub["stackId"]) + "/" + str(sub["nStacks"]));
        pw.write("file          = " + sub["source"]);
        pw.write("segmentation  = " + str(sf));
        pw.write("ranges: x,y,z = " + str(sub["x"]) +  "," + str(sub["y"]) + "," + str(sub["z"])); 
    
    img = io.readData(sub["source"], x = sub["x"], y = sub["y"], z = sub["z"]);
    
    if verbose:
        pw.write(timer.elapsedTime(head = 'Reading data of size ' + str(img.shape)));
    
    timer.reset();
    seg = sf(img, subStack = sub, out = pw, **pp);    

    if verbose:    
        pw.write(timer.elapsedTime(head = 'Processing substack of size ' + str(img.shape)));
    
    return seg;