Commit caceb8ac authored by ac_21's avatar ac_21

ilastik import script

parent 076a4ea9
% function importFolder(infolder,outfolder,expname)
ilastikFolder='/z/Raw/Shipper';
outfolder='/z/leverjs/ctc2020/2d';
expname='DIC-C2DH-HeLa_training_01_ix';
infolder='/z/Raw/2d_DIC-C2DH-HeLa_training/DIC-C2DH-HeLa/01';
flist=dir(fullfile(infolder,'*.tif'));
im=[];
imd1=[];
if exist(fullfile(infolder,'t000.tif'),'file')
tFormat='%03d';
else
if exist(fullfile(infolder,'t0000.tif'),'file')
tFormat='%04d';
else
fprintf(2,'importFolder : %s : could not read tif format! no t000 or t0000\n',infolder);
return;
end
end
for t=1:length(flist)
fname=['t' num2str(t-1,tFormat) '.tif'];
info=imfinfo(fullfile(infolder,fname));
if 1==t
try
imd1=MicroscopeData.Original.ReadMetadata(infolder,fname);
catch
imd1.PixelPhysicalSize=[1,1,1];
end
imd1.NumberOfChannels=2;
end
im(:,:,1,1,t)=imread(fullfile(infolder,fname));
% now let's get the ilastik image
fnameIlastik=['t' num2str(t,tFormat) '_Probabilities Stage 2.tiff'];
fnameIlastik=fullfile(ilastikFolder,fnameIlastik);
if exist(fnameIlastik,'file')
imIlastik=imread(fnameIlastik);
im(:,:,1,2,t)=imIlastik(:,:,2);
end
end
im=mat2gray(im);
imd1.DatasetName=expname;
writeH5(im,imd1,expname,outfolder);
function writeH5(im,imd1,expName,outfolder)
% make sure leverjsUtilities project is on your path!
% e.g. path(path,'pathTo\git\utilities\src\MATLAB')
imd=MicroscopeData.MakeMetadataFromImage(im);
imd.DatasetName=expName;
imd.PixelPhysicalSize=imd1.PixelPhysicalSize;
if (size(imd.Dimensions,2)~=3)
imd.Dimensions=[imd.Dimensions 1];
end
MicroscopeData.WriterH5(im,'imageData',imd,'path',outfolder);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment