def test(): """Test voxelization module""" import ClearMap.Analysis.Voxelization as self reload(self) import ClearMap.Analysis.VoxelizationCode as vox import numpy points = numpy.random.rand(200,3) * 10; #use cython code vi = vox.voxelizeSphere(points, 20,20,20, 5,5,5); import ClearMap.Visualization.Plot as Plot Plot.plotTiling(vi) #use voxelize vi = self.voxelize(points, dataSize = (20,20,20), size = (5,5,5)); Plot.plotTiling(vi) #weighted voxelization points = numpy.random.rand(10,3) * 10; weights = numpy.random.rand(10); #use voxelize vi = self.voxelize(points, dataSize = (20,20,20), size = (5,5,5)); viw = self.voxelize(points, dataSize = (20,20,20), size = (5,5,5), weights = weights); Plot.plotTiling(vi) Plot.plotTiling(viw)
def plotImportPreview(importResult): """Plots the prestiched preview file to check orientations and coarse alignment Arguments: importResult (str): the base directory of the image data or the import xml file Returns: object: plot axes """ return cplt.plotTiling(readImportPreview(importResult))
def plotImportPreview(importResult): """Plots the prestiched preview file to check orientations and coarse alignment Arguments: importResult (str): the base directory of the image data or the import xml file Returns: object: plot axes """ return cplt.plotTiling(readImportPreview(importResult));
def test(): """Test the statistics array""" import ClearMap.Analysis.Statistics as self reload(self) import numpy, os import matplotlib.pyplot as plt #x = stats.norm.rvs(loc=5,scale=1,size=1500) #y = stats.norm.rvs(loc=-5,scale=1,size=1500) s = numpy.ones((5, 4, 20)) s[:, 0:3, :] = -1 x = numpy.random.rand(4, 4, 20) y = numpy.random.rand(5, 4, 20) + s # print stats.ttest_ind(x,y, axis = 0, equal_var = False); pvals, psign = self.tTestVoxelization(x, y, signed=True) print pvals pvalscol = self.colorPValues(pvals, psign, positive=[255, 0, 0], negative=[0, 255, 0]) import ClearMap.Visualization.Plot as plt_cm plot = plt_cm.plotTiling(pvalscol) plt.show() # test points basedir = '/home/vzickus/repos/ClearMap-Debug/ClearMap' import ClearMap.Settings as settings pf = os.path.join(basedir, 'Test/Synthetic/cells_transformed_to_reference.csv') pf = numpy.loadtxt(pf, delimiter=',') pg = (pf, pf) pc = self.countPointsGroupInRegions(pg) pvals, tvals = self.tTestPointsInRegions(pg, pg, signed=True)
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif') import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z=(0, 26)) import ClearMap.ImageProcessing.BackgroundRemoval as bgr dataBGR = bgr.removeBackground(data.astype('float'), size=(3, 3), verbose=True) from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG dataDoG = filterDoG(dataBGR, size=(8, 8, 4), verbose=True) from ClearMap.ImageProcessing.MaximaDetection import findExtendedMaxima dataMax = findExtendedMaxima(dataDoG, hMax=None, verbose=True, threshold=10) from ClearMap.ImageProcessing.MaximaDetection import findCenterOfMaxima cells = findCenterOfMaxima(data, dataMax) plt.plotOverlayPoints(data, cells, z=(10, 16))
import ClearMap.IO.IO as io import os import ClearMap.Visualization.Plot as plt import ClearMap.Analysis.Label as lbl import numpy as np sampleName = 'LowNIC' #execfile('/d2/studies/ClearMap/IA_iDISCO/' + sampleName + '/parameter_file_' + sampleName + '.py') execfile( '/d2/studies/ClearMap/Alex_Acute_iDISCO/3RB_HighNIC/parameter_file_template_3RB.py' ) baseDirectory = '/d2/studies/ClearMap/Alex_Acute_iDISCO/NIC_HeatMaps/FiguresForPaper/' region = 'MSC' points = io.readPoints(TransformedCellsFile) data = plt.overlayPoints(AnnotationFile, points.astype(int), pointColor=None) io.writeData( os.path.join(BaseDirectory, sampleName + '_Annotations_Points_Overlay_newAtlas2.tif'), data) data = data[:, :, :, 1:] io.writeData( os.path.join(BaseDirectory, sampleName + '_Points_Transformed_newAtlas2.tif'), data) label = io.readData(AnnotationFile) label = label.astype('int32') labelids = np.unique(label) outside = np.zeros(label.shape, dtype=bool) """
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif') import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z=(0, 26)) plt.plotTiling(data, x=(0, 70), y=(0, 50), z=(10, 16))
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, "Test/Data/ImageAnalysis/cfos-substack.tif") import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z=(0, 26)) import ClearMap.ImageProcessing.BackgroundRemoval as bgr dataBGR = bgr.removeBackground(data.astype("float"), size=(3, 3), verbose=True) from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG dataDoG = filterDoG(dataBGR, size=(8, 8, 4), verbose=True) from ClearMap.ImageProcessing.MaximaDetection import findExtendedMaxima dataMax = findExtendedMaxima(dataDoG, hMax=None, verbose=True, threshold=10) from ClearMap.ImageProcessing.MaximaDetection import findCenterOfMaxima cells = findCenterOfMaxima(data, dataMax) plt.plotOverlayPoints(data, cells, z=(10, 16))
io.writeData(os.path.join(resultDir, fName + '_CellShapes.tif'), 255 * dataShape.astype('int32') / dataShape.max()) #cintensity = findIntensity(imgD, points); #points, intensities = thresholdPoints(points,cintensity, threshold = (5,20), row = (1,1)); points, cellSizesPost = thresholdPoints(points, cellSizesPre, threshold=pointsThresh, row=threshType) #pdb.set_trace() #io.writeData(os.path.join(homeDir, 'Results/OverlayWatershed.tif'), overlay_Img); overlay_Img = plt.fredOverlayPoints(cfos_fn, points, pointColor=[200, 0, 0]) io.writeData(os.path.join(resultDir, fName + '_PointsOriginalImg.tif'), overlay_Img) overlay_Img = plt.overlayPoints(imgD, points, pointColor=[200, 0, 0]) io.writeData(os.path.join(resultDir, fName + '_PointsFilterDoG.tif'), overlay_Img) #Convert points from 3d to 2d points = numpy.delete(points, 2, axis=1) io.writePoints(points_fn, points) ##############################################################333 imgR = io.readData(auto_fn)
# -*- coding: utf-8 -*- """ Created on Sat Dec 19 04:29:29 2015 @author: ckirst """ import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif') import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z=(0, 30)) plt.plotTiling(data, inverse=True, z=(10, 16)) #import ClearMap.ImageProcessing.ImageStatistics as stat #stat.calculateStatistics(filename, method = 'mean', verbose = True) import ClearMap.ImageProcessing.BackgroundRemoval as bgr dataBGR = bgr.removeBackground(data.astype('float'), size=(10, 10), verbose=True) plt.plotTiling(dataBGR, inverse=True, z=(10, 16)) from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG dataDoG = filterDoG(dataBGR, size=(8, 8, 4), verbose=True) plt.plotTiling(dataDoG, inverse=True, z=(10, 16)) import os
#row = (0,0) : peak intensity from the raw data #row = (1,1) : peak intensity from the DoG filtered data #row = (2,2) : peak intensity from the background subtracted data #row = (3,3) : voxel size from the watershed points, intensities = thresholdPoints(points, intensities, threshold=3000, row=(0, 0)) io.writePoints(FilteredCellsFile, (points, intensities)) ## Check Cell detection (For the testing phase only, remove when running on the full size dataset) ####################### import ClearMap.Visualization.Plot as plt pointSource = os.path.join(BaseDirectory, FilteredCellsFile[0]) data = plt.overlayPoints(cFosFile, pointSource, pointColor=None, **cFosFileRange) io.writeData(os.path.join(BaseDirectory, 'cells_check.tif'), data) # Transform point coordinates ############################# points = io.readPoints(CorrectionResamplingPointsParameter["pointSource"]) points = resamplePoints(**CorrectionResamplingPointsParameter) points = transformPoints( points, transformDirectory=CorrectionAlignmentParameter["resultDirectory"], indices=False, resultDirectory=None) CorrectionResamplingPointsInverseParameter["pointSource"] = points points = resamplePointsInverse(**CorrectionResamplingPointsInverseParameter) RegistrationResamplingPointParameter["pointSource"] = points
cellSizesPre = findCellSize(dataShape, maxlabel=points.shape[0]) io.writeData(os.path.join(homeDir, 'Results/CellShapes.tif'), 20 * dataShape.astype('int32')) #cintensity = findIntensity(imgD, points); #points, intensities = thresholdPoints(points,cintensity, threshold = (5,20), row = (1,1)); points, cellSizesPost = thresholdPoints(points, cellSizesPre, threshold=(5, 100), row=(3, 3)) #pdb.set_trace() #io.writeData(os.path.join(homeDir, 'Results/OverlayWatershed.tif'), overlay_Img); overlay_Img = plt.fredOverlayPoints(input_fn, points, pointColor=[200, 0, 0]) io.writeData(os.path.join(homeDir, 'Results/PointsOriginalImg.tif'), overlay_Img) overlay_Img = plt.fredOverlayPoints(os.path.join(homeDir, 'Results/FilterDoG.tif'), points, pointColor=[200, 0, 0]) io.writeData(os.path.join(homeDir, 'Results/PointsFilterDoG.tif'), overlay_Img) ################################################################################################# #Convert points from 3d to 2d points = numpy.delete(points, 2, axis=1) io.writePoints(points_fn, points) #Resampled Img imgR = io.readData(auto_fn)
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif') import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z=(0, 26)) import ClearMap.ImageProcessing.BackgroundRemoval as bgr dataBGR = bgr.removeBackground(data.astype('float'), size=(10, 10), verbose=True) from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG dataDoG = filterDoG(dataBGR, size=(8, 8, 4), verbose=True) plt.plotTiling(dataDoG, inverse=True, z=(10, 16))
# -*- coding: utf-8 -*- """ Created on Sat Dec 19 04:29:29 2015 @author: ckirst """ import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif'); import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z = (0,30)); plt.plotTiling(data, inverse = True, z = (10,16)); #import ClearMap.ImageProcessing.ImageStatistics as stat #stat.calculateStatistics(filename, method = 'mean', verbose = True) import ClearMap.ImageProcessing.BackgroundRemoval as bgr dataBGR = bgr.removeBackground(data.astype('float'), size=(10,10), verbose = True); plt.plotTiling(dataBGR, inverse = True, z = (10,16)); from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG dataDoG = filterDoG(dataBGR, size=(8,8,4), verbose = True); plt.plotTiling(dataDoG, inverse = True, z = (10,16));
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif') import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z=(0, 26)) import ClearMap.ImageProcessing.BackgroundRemoval as bgr dataBGR = bgr.removeBackground(data.astype('float'), size=(3, 3), verbose=True) from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG dataDoG = filterDoG(dataBGR, size=(8, 8, 4), verbose=True) from ClearMap.ImageProcessing.MaximaDetection import findExtendedMaxima dataMax = findExtendedMaxima(dataDoG, hMax=None, verbose=True, threshold=10) from ClearMap.ImageProcessing.MaximaDetection import findCenterOfMaxima cells = findCenterOfMaxima(data, dataMax) from ClearMap.ImageProcessing.CellSizeDetection import detectCellShape dataShape = detectCellShape(dataDoG, cells, threshold=15) plt.plotOverlayLabel(dataDoG / dataDoG.max(), dataShape, z=(10, 16))
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif'); import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z = (0,26)); plt.plotTiling(data, x= (0,70), y = (0,50), z = (10,16));
import ClearMap.Settings as settings import ClearMap.Visualization.Plot as plt import ClearMap.ImageProcessing.BackgroundRemoval as bgr import matplotlib as mplt BaseDirectory = '/d2/studies/ClearMap/IA_iDISCO/IA1_RB/' filename = os.path.join(BaseDirectory, 'IA1_RB_cfos_stack.ome.tif') data = io.readData(filename, z=(600, 650)) # size restriction fileRange = 'x = (1050, 1350), y = (550,850), z = (25,34)' """ note that the Z coordinate in fileRange variable are relative to the planes imported in the data variable. So in this case, you would be imaging planes 675-684. """ plt.plotTiling(data, inverse=True, x=(1250, 1350), y=(550, 650), z=(25, 34)) # # background subtraction dataBGR = bgr.removeBackground(data.astype('float'), size=(5, 5), verbose=False, save=None) dataBGR_write = plt.plotTiling(dataBGR, inverse=True, x=(1250, 1350), y=(550, 650), z=(25, 34)) dataBGR_write = plt.overlayPoints(dataBGR, fileRange) mplt.pyplot.savefig(os.path.join(BaseDirectory, 'dataBGR_write.tif')) io.writeData(os.path.join(BaseDirectory, 'background_8.tif'), dataBGR_write) io.writeData(os.path.join(BaseDirectory, 'cells_check.tif'), data)
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif'); import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z = (0,26)); plt.plotTiling(data);
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif'); import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z = (0,26)); import ClearMap.ImageProcessing.BackgroundRemoval as bgr dataBGR = bgr.removeBackground(data.astype('float'), size=(3,3), verbose = True); from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG dataDoG = filterDoG(dataBGR, size=(8,8,4), verbose = True); from ClearMap.ImageProcessing.MaximaDetection import findExtendedMaxima dataMax = findExtendedMaxima(dataDoG, hMax = None, verbose = True, threshold = 10); from ClearMap.ImageProcessing.MaximaDetection import findCenterOfMaxima cells = findCenterOfMaxima(data, dataMax); from ClearMap.ImageProcessing.CellSizeDetection import detectCellShape dataShape = detectCellShape(dataDoG, cells, threshold = 15); plt.plotOverlayLabel(dataDoG / dataDoG.max(), dataShape, z = (10,16))
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif'); import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z = (0,26)); import ClearMap.ImageProcessing.BackgroundRemoval as bgr dataBGR = bgr.removeBackground(data.astype('float'), size=(3,3), verbose = True); from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG dataDoG = filterDoG(dataBGR, size=(8,8,4), verbose = True); from ClearMap.ImageProcessing.MaximaDetection import findExtendedMaxima dataMax = findExtendedMaxima(dataDoG, hMax = None, verbose = True, threshold = 10); plt.plotOverlayLabel(dataDoG / dataDoG.max(), dataMax.astype('int'), z = (10,16), x = (50,100), y = (50,100))
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif'); import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z = (0,26)); import ClearMap.ImageProcessing.BackgroundRemoval as bgr dataBGR = bgr.removeBackground(data.astype('float'), size=(3,3), verbose = True); plt.plotTiling(dataBGR, inverse = True, z = (10,16));
import os import ClearMap.Settings as settings filename = os.path.join(settings.ClearMapPath, 'Test/Data/ImageAnalysis/cfos-substack.tif') import ClearMap.Visualization.Plot as plt import ClearMap.IO as io data = io.readData(filename, z=(0, 26)) import ClearMap.ImageProcessing.BackgroundRemoval as bgr dataBGR = bgr.removeBackground(data.astype('float'), size=(3, 3), verbose=True) from ClearMap.ImageProcessing.Filter.DoGFilter import filterDoG dataDoG = filterDoG(dataBGR, size=(8, 8, 4), verbose=True) from ClearMap.ImageProcessing.MaximaDetection import findExtendedMaxima dataMax = findExtendedMaxima(dataDoG, hMax=None, verbose=True, threshold=10) plt.plotOverlayLabel(dataDoG / dataDoG.max(), dataMax.astype('int'), z=(10, 16))