Skip to content

Commit

Permalink
Added many fixes for SuperSeggerViewerGui for multichannel imaging
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Wiggins committed Jun 18, 2018
1 parent a4f36ed commit b6cb8b2
Show file tree
Hide file tree
Showing 22 changed files with 1,507 additions and 712 deletions.
5 changes: 5 additions & 0 deletions Internal/intImRead.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
end
end


if numel(size(im)) > 2
disp('Images are in color - attempting to convert to monochromatic.');
im = convertToMonochromatic(im);
end
end


4 changes: 2 additions & 2 deletions batch/BatchSuperSeggerOpti.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ function BatchSuperSeggerOpti(dirname_,skip,clean_flag,res,startEnd,showWarnings
cleanup = onCleanup( @()( delete( h ) ) );
end

%parfor(j = 1:num_xy,workers)
for j = 1:num_xy
parfor(j = 1:num_xy,workers)
%for j = 1:num_xy

dirname_xy = dirname_list{j};
intProcessXY( dirname_xy, skip, nc, num_c, clean_flag, ...
Expand Down
25 changes: 10 additions & 15 deletions batch/trackOptiAlignPad.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
crop_box = cell(1, num_xy);

% parallelized alignment for each xy
for jj=1:num_xy
%parfor(jj=1:num_xy, workers)
%for jj=1:num_xy
parfor(jj=1:num_xy, workers)
crop_box{jj} = intFrameAlignXY( SHOW_FLAG, nt, nz, nc, nxy(jj), ...
dirname_, targetd, nameInfo, precision, CONST);
end
Expand Down Expand Up @@ -182,11 +182,6 @@
end
im = intImRead(in_name);

if numel(size(im)) > 2
disp('Images are in color - attempting to convert to monochromatic.');
im = convertToMonochromatic(im);
end

if (ic == nc(1)) && (iz == nnz2 | iz == -1)
% align phase image at half the z axis
if ~initFlag % first time through, or high error
Expand Down Expand Up @@ -236,11 +231,11 @@

figure(ic)
clf;
if mod(ic,2) == 0
imshow( cat( 3, backer, backer0+fluor, backer0));
else
imshow( cat( 3, backer+fluor, backer0, backer0));

if ~isfield (CONST.view,'fluorColor')
CONST.view.fluorColor = {'g','r','b'};
end
comp( {backer}, {fluor,CONST.view.fluorColor{ic-1}} );
end
drawnow;
end
Expand Down Expand Up @@ -322,11 +317,11 @@

figure(ic)
clf;
if mod(ic,2) == 0
imshow( cat( 3, backer, backer0+fluor, backer0));
else
imshow( cat( 3, backer+fluor, backer0, backer0));

if ~isfield (CONST.view,'fluorColor')
CONST.view.fluorColor = {'g','r','b'};
end
comp( {backer}, {fluor,CONST.view.fluorColor{ic-1}} );
end
drawnow;
hold on;
Expand Down
10 changes: 5 additions & 5 deletions batch/trackOptiCropMulti.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

if ~isempty(dirname)

file_filter = '*.tif';
file_filter = '*.tif*';
dirname = fixDir(dirname);

contents=dir([dirname,file_filter]);
Expand Down Expand Up @@ -72,10 +72,10 @@
% displays the first and last image on top of each other
nameInfo.npos(:,1) = [nt(1); nc(1); nnxy; nz(1)];

im1 = imread( [dirname, MakeFileName(nameInfo) ]);
im1 = intImRead( [dirname, MakeFileName(nameInfo) ]);

nameInfo.npos(:,1) = [nt(end); nc(1); nnxy; nz(1)];
imEnd = imread( [dirname, MakeFileName(nameInfo) ]);
imEnd = intImRead( [dirname, MakeFileName(nameInfo) ]);
figure(1);
clf;

Expand Down Expand Up @@ -120,9 +120,9 @@

disp( in_name );

im = imread( in_name );
im = intImRead( in_name );
out_name = [targetd, MakeFileName(nameInfo)];
imwrite( im(yy,xx), out_name, 'TIFF' );
intImWrite( im(yy,xx), out_name );
end

end
Expand Down
17 changes: 15 additions & 2 deletions batch/trackOptiSkipMerge.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ function intSkipPar(i,dirname_xy,nameInfo,nt,nc,nz,skip,num_c,num_z)
nameInfo_tmp.npos(4,1) = 1;
name = MakeFileName(nameInfo_tmp);


% do the min merge of z phase
phase = imread( [dirname_xy,'phase',filesep,name] );
phase = intImRead( [dirname_xy,'phase',filesep,name] );
for k = 2:num_z
nameInfo_tmp.npos(4,1) = nz(k);
name = MakeFileName(nameInfo_tmp);
Expand All @@ -155,9 +156,15 @@ function intSkipPar(i,dirname_xy,nameInfo,nt,nc,nz,skip,num_c,num_z)
dataname_ref = [dirname_xy,'seg', filesep,name_ref,'_err.mat'];
data = load(dataname_ref);



% loads the data reference for the min merge of z phase, sets tha name and
% nameInfo, and the fluorescence field from the image to be merged.
if mod(i-1,skip)

imRange = nan( [2, num_c ] );
imRange(:,1) = intRange( phase(:) );

data.phase = phase;
data.basename = name;
nameInfo_tmp = nameInfo;
Expand All @@ -169,9 +176,15 @@ function intSkipPar(i,dirname_xy,nameInfo,nt,nc,nz,skip,num_c,num_z)
name = MakeFileName( nameInfo_tmp );
fluorImage = imread( [dirname_xy,'fluor',num2str(nc(k)-1),filesep,name]);
data.(['fluor',num2str(nc(k)-1)]) = fluorImage;
end

imRange(:,k) = intRange( fluorImage(:) );
end

data.imRange = imRange;

end


save(dataname2,'-STRUCT','data');

end
19 changes: 19 additions & 0 deletions cell/trackOptiClist.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
% Get the track file names...
contents=dir([dirname '*_err.mat']);

imRangeGlobal = [];

if isempty( contents )
clist.data = [];
Expand Down Expand Up @@ -91,6 +92,20 @@


data_c = loaderInternal([dirname,contents(i).name]);

% get info on max and min values of each channel over all timesteps
if isfield( data_c, 'imRange' )
if isempty( imRangeGlobal )
imRangeGlobal = data_c.imRange;
else

for kk = 1:size( imRangeGlobal, 2 )
imRangeGlobal(1,kk) = min( [data_c.imRange(1,kk),imRangeGlobal(1,kk)] );
imRangeGlobal(2,kk) = max( [data_c.imRange(2,kk),imRangeGlobal(2,kk)] );
end
end
end

if ~isempty( data_c.CellA)
% record the number of cell neighbors
if CONST.trackOpti.NEIGHBOR_FLAG && ...
Expand Down Expand Up @@ -265,6 +280,10 @@

clist = gateTool( clist, 'add3Dt' );

% add channel max and min
clist.imRangeGlobal = imRangeGlobal;


%add3dtime stuff
len_time_ind = grabClistIndex(clist, 'Long axis (L)', 1);

Expand Down
10 changes: 9 additions & 1 deletion segmentation/doSeg.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
phase = mean( phaseCat, 3);
end

imRange = nan( [2, num_c ] );

if ~mod(i-1,skip)

if CONST.superSeggerOpti.segmenting_fluorescence
Expand All @@ -93,6 +95,8 @@
phase = max(phase(:)) - phase;
end

imRange(:,1) = intRange( phase(:) );

% do the segmentation here
[data, ~] = CONST.seg.segFun( phase, CONST, header, dataname, crop_box);
if ~isempty( crop_box )
Expand All @@ -107,8 +111,12 @@
nameInfo_tmp.npos(4,1) = 1;
name = MakeFileName( nameInfo_tmp );
fluor_tmp = intImRead( [dirname_xy,'fluor',num2str(nc(k)-1),filesep,name] );
data.(['fluor',num2str(nc(k)-1)])=fluor_tmp;
data.(['fluor',num2str(nc(k)-1)])=fluor_tmp;

imRange(:,k) = intRange( fluor_tmp(:) );
end

data.imRange = imRange;

save(dataname,'-STRUCT','data'); % Save data structure into the seg file.
end
Expand Down
2 changes: 1 addition & 1 deletion segmentation/superSeggerOpti.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@

% remove bright halos from the mask
mask_halos = (magicPhase>CUT_INT);
mask_bg = logical((mask_colonies_-mask_halos)>0);
mask_bg = logical((mask_colonies-mask_halos)>0);

% removes micro-colonies with background level outline intensity - not bright enough

Expand Down
Loading

0 comments on commit b6cb8b2

Please sign in to comment.