Skip to content
Snippets Groups Projects
Commit 87f2fb95 authored by Eric Wait's avatar Eric Wait
Browse files

Cleaning up unused files

parent 2aa9e8e3
No related branches found
No related tags found
No related merge requests found
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.
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
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment