Skip to content
Snippets Groups Projects
Commit 3ca45227 authored by ac_fx's avatar ac_fx
Browse files

refactor! everything moves

parent 8328b7be
No related branches found
No related tags found
No related merge requests found
Showing
with 87 additions and 7 deletions
File moved
File moved
File moved
% ctc2lever
% import ctc format tiff folder into .LEVER
function h5File=ctc2lever(filename,outpath,expName)
h5File=[];
if ~exist('gtFile','var')
gtFile=[];
end
if ~exist('expName','var')
expName=[];
end
[~,~,ext]=fileparts(filename);
h5File=importFolder(filename,outpath,expName);
Import.leverImport([],outpath,h5File);
4;
function h5File=importFolder(folder,outfolder,expName)
h5File=[];
parts=strsplit(folder,filesep);
if isempty(expName)
expName=[parts{end-1} '_challenge_' parts{end}];
end
h5File=fullfile(outfolder,[expName '.h5']);
if exist(h5File,'file')
return
end
fprintf(1,'importing folder %s -> %s\n',folder, h5File);
flist=dir(fullfile(folder,'*.tif'));
im=[];
imd1=[];
for t=1:length(flist)
fname=['t' num2str(t-1,'%03d') '.tif'];
if ~exist(fullfile(folder,fname),'file')
fname=['t' num2str(t-1,'%04d') '.tif'];
end
info=imfinfo(fullfile(folder,fname));
if 1==t
try
imd1=MicroscopeData.Original.ReadMetadata(folder,fname);
catch
imd1.PixelPhysicalSize=[1,1,1];
end
end
for z=1:length(info)
im(:,:,z)=imread(fullfile(folder,fname),z);
end
if 1==t
imd=MicroscopeData.MakeMetadataFromImage(im);
imd.DatasetName=expName;
imd.NumberOfFrames = length(flist);
imd.PixelPhysicalSize=imd1.PixelPhysicalSize;
if (size(imd.Dimensions,2)~=3)
imd.Dimensions=[imd.Dimensions 1];
end
Import.prepareH5(h5File,imd);
end
% ACK - mat2gray here??!?
im=mat2gray(im);
Import.appendH5Frame(h5File,im,t);
end
File moved
File moved
File moved
File moved
File moved
File moved
File moved
% importExport.m
% mcc -m importExport.m -a D:\Andy\git\leverjs\matlab\sqlite-jdbc-3.21.0.jar -a ./assignment
function bExport=importExport(filename,outpath,config, gtFile)
function [bExport,h5File]=importExport(filename,outpath,config, gtFile,expName)
tic
h5File=[];
if ~exist('gtFile','var')
gtFile=[];
end
if ~exist('expName','var')
expName=[];
end
[~,~,ext]=fileparts(filename);
......@@ -13,7 +17,7 @@ if strcmp(ext,'.LEVER')
bExport=export(filename,outpath,config,gtFile);
elseif exist(filename,'dir')
bExport=false;
importFolder(filename,outpath);
h5File=importFolder(filename,outpath,expName);
else
fprintf(2,'error - argument unknown (tif or .lever): %s\n',filename);
end
......@@ -26,14 +30,18 @@ else
end
4;
function importFolder(folder,outfolder)
function h5File=importFolder(folder,outfolder,expName)
h5File=[];
parts=strsplit(folder,filesep);
expname=[parts{end-1} '_challenge_' parts{end}];
if exist(fullfile(outfolder,[expname '.h5']),'file')
if isempty(expName)
expName=[parts{end-1} '_challenge_' parts{end}];
end
h5File=fullfile(outfolder,[expName '.h5']);
if exist(h5File,'file')
return
end
h5File=fullfile(outfolder,[expname '.h5']);
fprintf(1,'importing folder %s -> %s\n',folder, h5File);
flist=dir(fullfile(folder,'*.tif'));
......@@ -61,7 +69,8 @@ for t=1:length(flist)
end
if 1==t
imd=MicroscopeData.MakeMetadataFromImage(im);
imd.DatasetName=expname;
imd.DatasetName=expName;
imd.NumberOfFrames = length(flist);
imd.PixelPhysicalSize=imd1.PixelPhysicalSize;
if (size(imd.Dimensions,2)~=3)
imd.Dimensions=[imd.Dimensions 1];
......
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment