Exemple #1
0
def runCellCoordinateTransformation(parameter):
    """Transform points by resampling applying the elastix transformation and then re-resample again"""
    
    im = parameter.Resampling.DataFiles;
    if im is None:    
        im = parameter.DataSource.ImageFile;
        
    cf = parameter.ImageProcessing.CellCoordinateFile;
    pa = parameter.Alignment;
    pr = parameter.Resampling;
    
    # downscale points to referenece image size
    points = resamplePoints(cf, im, resolutionData = pr.ResolutionData, resolutionReference = pr.ResolutionReference, orientation = pr.Orientation);
    
    # transform points
    points = points[:,[1,0,2]]; # account for (y,x, z) array representaton here
    points = transformPoints(points, alignmentdirectory = pa.AlignmentDirectory, transformparameterfile = None, read = True, tmpfile = None, outdirectory = None, indices = False);
    points = points[:,[1,0,2]]; # account for (y,x, z) array representaton here
    
    # upscale ppints back to original size
    points = resamplePointsInverse(points, im, resolutionData = pr.ResolutionData, resolutionReference = pr.ResolutionReference, orientation = pr.Orientation);
    
    tf = parameter.ImageProcessing.CellTransformedCoordinateFile;
    if tf is None:
        return points;
    else:
        io.writePoints(tf, points);
        return tf;
Exemple #2
0
def runCellCoordinateTransformation(parameter):
    """Transform points by resampling applying the elastix transformation and then re-resample again"""

    im = parameter.Resampling.DataFiles
    if im is None:
        im = parameter.DataSource.ImageFile

    cf = parameter.ImageProcessing.CellCoordinateFile
    pa = parameter.Alignment
    pr = parameter.Resampling

    # downscale points to referenece image size
    points = resamplePoints(cf,
                            im,
                            resolutionData=pr.ResolutionData,
                            resolutionReference=pr.ResolutionReference,
                            orientation=pr.Orientation)

    # transform points
    points = points[:, [1, 0, 2]]
    # account for (y,x, z) array representaton here
    points = transformPoints(points,
                             alignmentdirectory=pa.AlignmentDirectory,
                             transformparameterfile=None,
                             read=True,
                             tmpfile=None,
                             outdirectory=None,
                             indices=False)
    points = points[:, [1, 0, 2]]
    # account for (y,x, z) array representaton here

    # upscale ppints back to original size
    points = resamplePointsInverse(points,
                                   im,
                                   resolutionData=pr.ResolutionData,
                                   resolutionReference=pr.ResolutionReference,
                                   orientation=pr.Orientation)

    tf = parameter.ImageProcessing.CellTransformedCoordinateFile
    if tf is None:
        return points
    else:
        io.writePoints(tf, points)
        return tf
respoints = resamplePoints(points, dataSize, shiftPoints = True, **resamplingParameter);
print("Reshaped centers shape: (%d, %d)" % respoints.shape)

if verbose:
    dataraw = io.readData(os.path.join(baseDirectory, 'Data/Synthetic/test_iDISCO_\d{3}.tif'));
    datares = io.readData(os.path.join(baseDirectory, 'Synthetic/test_iDISCO_resample.tif'));
    print("Shape raw: " + str(dataraw.shape))
    print("Shape res: " + str(datares.shape))
    
    plot.plotOverlayPoints(dataraw*0.01, points);
    plot.plotOverlayPoints(datares*0.01, respoints);


#check inverse:
resipoints = resamplePointsInverse(respoints, dataSize, **resamplingParameter);
diff = points - resipoints;
print (diff.max(), diff.min());




##############################################################################
# Test Transform Points on Corners
############################################################################## 

import numpy

import iDISCO.Alignment.Elastix as elx;

verbose = True;
respoints = resamplePoints(points, dataSize, shiftPoints = True, **resamplingParameter);
print "Reshaped centers shape: (%d, %d)" % respoints.shape

if verbose:
    dataraw = io.readData(os.path.join(baseDirectory, 'Data/Synthetic/test_iDISCO_\d{3}.tif'));
    datares = io.readData(os.path.join(baseDirectory, 'Synthetic/test_iDISCO_resample.tif'));
    print "Shape raw: " + str(dataraw.shape)
    print "Shape res: " + str(datares.shape)
    
    plot.plotOverlayPoints(dataraw*0.01, points);
    plot.plotOverlayPoints(datares*0.01, respoints);


#check inverse:
resipoints = resamplePointsInverse(respoints, dataSize, **resamplingParameter);
diff = points - resipoints;
print (diff.max(), diff.min());




##############################################################################
# Test Transform Points on Corners
############################################################################## 

import numpy

import iDISCO.Alignment.Elastix as elx;

verbose = True;