Skip to content
Snippets Groups Projects
Commit 5073fdd5 authored by ac_21's avatar ac_21
Browse files

Merge branch 'leverjs' of git-bioimage.coe.drexel.edu:bioimage/hydra-image-processor into leverjs

parents b59b5a2b f7b83d58
Branches
No related tags found
No related merge requests found
Showing
with 12 additions and 176 deletions
*.mexw64 filter=lfs diff=lfs merge=lfs -text
*.mat filter=lfs diff=lfs merge=lfs -text *.mat filter=lfs diff=lfs merge=lfs -text
*.ai filter=lfs diff=lfs merge=lfs -text *.ai filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text *.png filter=lfs diff=lfs merge=lfs -text
*.mexw64 filter=lfs diff=lfs merge=lfs -text
*.mexa64 filter=lfs diff=lfs merge=lfs -text
*.pyd filter=lfs diff=lfs merge=lfs -text
*.so filter=lfs diff=lfs merge=lfs -text
No preview for this file type
No preview for this file type
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
%Skeleton for Imaris batch in Matlab
%ImarisLib.jar needs to be in the same folder.
%Imaris needs to be running when executing the following code
%CC 2018-01-03 tested with Imaris 9.1.0
%Get the image folder. Only read *.ims images.
infolder = uigetdir;
files = [infolder '/*.ims'];
listing = dir(files);
nfiles = size(listing,1);
%open files in Imaris sequentially
for i = 1:nfiles
filename = [infolder '/' listing(i).name];
filename = sprintf(filename);
vImarisApplication = StartImaris;
vImarisApplication.FileOpen(filename,'');
%get dataset in Matlab
vDataSet = vImarisApplication.GetDataSet;
%apply median filter to dataset
vImarisApplication.GetImageProcessing.MedianFilterChannel(vDataSet,0,[5 5 5]);
%create Surfaces
ip = vImarisApplication.GetImageProcessing;
vNewSurfaces = ip.DetectSurfaces(vDataSet, [], 0, 1, 0, true, 0, '');
vNewSurfaces.SetName(sprintf('New Surface'));
vImarisApplication.GetSurpassScene.AddChild(vNewSurfaces,-1);
%get Surface stats
vSurpassComponent = vImarisApplication.GetSurpassSelection;
vImarisObject = vImarisApplication.GetFactory.ToSurfaces(vSurpassComponent);
vAllStatistics = vImarisObject.GetStatistics;
vNames = cell(vAllStatistics.mNames);
vValues = vAllStatistics.mValues;
disp(unique(vNames))
%save ims file
newFilename = strcat(filename(1:end-4),'new.ims');
vImarisApplication.FileSave(newFilename,'');
pause(5);
%Clear java handles to clear up memory and prevent future errors
clear 'Imaris/IApplicationPrxHelper';
clear 'Imaris/IDataSetPrxHelper';
clear 'Imaris/IDataContainerPrxHelper';
clear 'Imaris/IDataItemPrxHelper';
clear 'Imaris/cStatisticValues';
clear 'ImarisLib';
clear 'vSurpassScene';
clear 'vDataSet';
clear 'vAllStatistics';
clear 'err';
end
%Quit Imaris Application after all is done
vImarisApplication.SetVisible(~vImarisApplication.GetVisible);
vImarisApplication.Quit;
function aImarisApplication = StartImaris
javaaddpath ImarisLib.jar;
vImarisLib = ImarisLib;
server = vImarisLib.GetServer();
id = server.GetObjectID(0);
aImarisApplication = vImarisLib.GetApplication(id);
disp(id)
end
\ No newline at end of file
function ContrastEnhancement(imarisAppID)
imarisHandle = ImarisHelper.GetAppHandle(imarisAppID);
if (isempty(imarisHandle))
error('Imaris is not open or the wrong app id!');
end
imarisDataset = imarisHandle.GetDataSet();
physicalSize = ImarisHelper.GetPhysicalSize(imarisDataset);
normSize = physicalSize./max(physicalSize);
defaultSigs = 35.*normSize;
defaultSigsStr = sprintf('[%.2f,%.2f,%.2f]',defaultSigs(1),defaultSigs(2),defaultSigs(3));
prompts = {'Enter Channel:','Enter Gaussian Sigmas:','Enter Median Neighborhood:','Inplace:(false=0,true=1)'};
dlgTitle = 'Contrast Enhancement';
numLines = 1;
defaultAns = {'1',defaultSigsStr,'[3,3,3]','0'};
answer = inputdlg(prompts,dlgTitle,numLines,defaultAns);
if (isempty(answer))
return
end
chan = str2double(answer{1});
sigsStr = regexp(answer{2},'\[(.*),(.*),(.*)\]','tokens');
sigs = abs(cellfun(@(x)(str2double(x)),sigsStr{1}));
medStr = regexp(answer{3},'\[(.*),(.*),(.*)\]','tokens');
medNeighborhood = cellfun(@(x)(str2double(x)),medStr{1});
medNeighborhood = abs(round(medNeighborhood));
inplace = str2double(answer{4})>0;
outChannel = ImarisHelper.GetNumChannels(imarisDataset) +1;
if (inplace)
outChannel = chan;
end
imarisHandle.DataSetPushUndo('Contrast Enhancement');
% TODO see if there is enough memory to just capture the entire series
% to process faster
numFrames = ImarisHelper.GetNumFrames(imarisDataset);
im = ImarisHelper.GetImageData(imarisDataset,chan,1:numFrames);
prgs = Utils.CmdlnProgress(numFrames,true,'smooth');
for t=1:numFrames
im(:,:,:,1,t) = ImProc.ContrastEnhancement(im(:,:,:,1,t),sigs,medNeighborhood);
prgs.PrintProgress(t);
end
prgs.ClearProgress(true);
imarisDataset = ImarisHelper.SetImage(imarisHandle,imarisDataset,im,outChannel,1:t);
end
src/MATLAB/gray.bmp

440 KiB

File deleted
File deleted
im = tiffReader('DAPI Olig2-514 GFAP-488 Dcx-647 Laminin-Cy3 Bcatenin-568 20x1 TopLeft');
\ No newline at end of file
src/MATLAB/seg.bmp

440 KiB

%% print out image
function showIm(image,label)
figure
imagesc(max(image,[],3))
% set(gcf,'Units','normalized');
% set(gcf,'Position',[0 0 1 1]);
colormap gray
title(label)
axis image
end
function [cTime,mTime,kernelName] = (im,)
kernelName = '';
cT = tic;
imC = HIP.(im,);
cTime = toc(cT);
mT = tic;
imM = HIP.(im,,true);
mTime = toc(mT);
end
figure
plot(0,0,'.w');
ax = gca;
hold on
for i=1:length(imChunks)
curChunk = imChunks(i);
Utils.PlotBox(ax,Utils.SwapXY_RC(curChunk.ImageStart_rc),Utils.SwapXY_RC(curChunk.ImageEnd_rc),'-b',num2str(i));
Utils.PlotBox(ax,Utils.SwapXY_RC(curChunk.ImageROIstart_rc),Utils.SwapXY_RC(curChunk.ImageROIend_rc),'--r');
Utils.PlotBox(ax,...
Utils.SwapXY_RC(curChunk.ImageStart_rc) + Utils.SwapXY_RC(curChunk.ChunkROIstart_rc) - 1,...
Utils.SwapXY_RC(curChunk.ImageStart_rc) + Utils.SwapXY_RC(curChunk.ChunkROIstart_rc) -1 + (Utils.SwapXY_RC(curChunk.ChunkROIend_rc)-Utils.SwapXY_RC(curChunk.ChunkROIstart_rc)-1),...
':g');
end
axis ij
axis equal
File deleted
No preview for this file type
No preview for this file type
...@@ -70,6 +70,7 @@ void cLoG(ImageView<PixelTypeIn> imageIn, ImageView<float> imageOut, Vec<double> ...@@ -70,6 +70,7 @@ void cLoG(ImageView<PixelTypeIn> imageIn, ImageView<float> imageOut, Vec<double>
{ {
if (!chunks[i].sendROI(imageIn, deviceImages.getCurBuffer())) if (!chunks[i].sendROI(imageIn, deviceImages.getCurBuffer()))
std::runtime_error("Error sending ROI to device!"); std::runtime_error("Error sending ROI to device!");
cudaMultiplySumBias<<<chunks[i].blocks, chunks[i].threads >> > (*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), constLoGKernelMem_x, MIN_VAL, MAX_VAL, constGausKernelMem_x, true); cudaMultiplySumBias<<<chunks[i].blocks, chunks[i].threads >> > (*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), constLoGKernelMem_x, MIN_VAL, MAX_VAL, constGausKernelMem_x, true);
deviceImages.incrementBuffer(); deviceImages.incrementBuffer();
if (sigmas.y!=0) if (sigmas.y!=0)
...@@ -91,6 +92,7 @@ void cLoG(ImageView<PixelTypeIn> imageIn, ImageView<float> imageOut, Vec<double> ...@@ -91,6 +92,7 @@ void cLoG(ImageView<PixelTypeIn> imageIn, ImageView<float> imageOut, Vec<double>
{ {
if (!chunks[i].sendROI(imageIn, deviceImages.getCurBuffer())) if (!chunks[i].sendROI(imageIn, deviceImages.getCurBuffer()))
std::runtime_error("Error sending ROI to device!"); std::runtime_error("Error sending ROI to device!");
if (sigmas.x!=0) if (sigmas.x!=0)
{ {
cudaMultiplySum << <chunks[i].blocks, chunks[i].threads >> > (*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), constGausKernelMem_x, MIN_VAL, MAX_VAL); cudaMultiplySum << <chunks[i].blocks, chunks[i].threads >> > (*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), constGausKernelMem_x, MIN_VAL, MAX_VAL);
...@@ -112,6 +114,7 @@ void cLoG(ImageView<PixelTypeIn> imageIn, ImageView<float> imageOut, Vec<double> ...@@ -112,6 +114,7 @@ void cLoG(ImageView<PixelTypeIn> imageIn, ImageView<float> imageOut, Vec<double>
{ {
if (!chunks[i].sendROI(imageIn, deviceImages.getCurBuffer())) if (!chunks[i].sendROI(imageIn, deviceImages.getCurBuffer()))
std::runtime_error("Error sending ROI to device!"); std::runtime_error("Error sending ROI to device!");
if (sigmas.x!=0) if (sigmas.x!=0)
{ {
cudaMultiplySum << <chunks[i].blocks, chunks[i].threads >> > (*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), constGausKernelMem_x, MIN_VAL, MAX_VAL); cudaMultiplySum << <chunks[i].blocks, chunks[i].threads >> > (*(deviceImages.getCurBuffer()), *(deviceImages.getNextBuffer()), constGausKernelMem_x, MIN_VAL, MAX_VAL);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment