Skip to content
Snippets Groups Projects
Commit 81fcbea0 authored by ac_fx's avatar ac_fx
Browse files

ssf clip channels

parent 28b50b1b
No related branches found
No related tags found
No related merge requests found
...@@ -128,8 +128,8 @@ end ...@@ -128,8 +128,8 @@ end
if exist('strDB','var') && ~isempty(strDB) if exist('strDB','var') && ~isempty(strDB)
elec_cmd = [elec_cmd ' --leverFile=' strDB ' ']; elec_cmd = [elec_cmd ' --leverFile=' strDB ' '];
end end
cmd = [elec_cmd ' --port=' num2str(port) ' --title="figure ' num2str(fignum) '"' ' &'] cmd = ['export PATH=' px ' ; ' elec_cmd ' --port=' num2str(port) ' --title="figure ' num2str(fignum) '"' ' &']
system(cmd,'PATH',px); system(cmd);
end end
function launch_electron_windows(port,fignum,workdir, leverpath, strDB) function launch_electron_windows(port,fignum,workdir, leverpath, strDB)
......
function imq = draw_ssf_kymo(strKymoFile) function imq = draw_ssf_kymo(strKymoFile, targetChannels, clipLimits,nKeep)
targetChannels = 1;
imKymo = SSF.loadImage(strKymoFile,targetChannels); imKymo = SSF.loadImage(strKymoFile,targetChannels);
if nKeep>0
imKymo(imKymo<0) = 0;
end
if nKeep<0
imKymo(imKymo>0) = 0;
imKymo = abs(imKymo);
end
imp = imKymo; [~,imp,imn] = LoG.separateLoG(imKymo);
imp(imp<0)=0;
imp = max(imp,[],1);
imp = SSF.quantize8(imp);
imn = imKymo;
imn(imn>0)=0;
imn=abs(imn);
imn = max(imn,[],1);
imn = SSF.quantize8(imn);
imq(:,:,1) = squeeze(imp);
imq(:,:,2) = squeeze(imn);
imq(:,:,3) = 0*imp;
imp = squeeze(max(imp,[],1));
imn = squeeze(max(imn,[],1));
imProject = max(imp,imn);
imProject(imn>imp) = imProject(imn>imp) .* -1;
imq = SSF.quantize8(imProject,clipLimits);
return
% load('agne_72_8bpp.mat') % load('agne_72_8bpp.mat')
ROOT = '/g/leverjs/Olivier/Agne/march_2023_20x';
flist = dir(fullfile(ROOT,'*.LEVER')); flist = dir(fullfile(ROOT,'*.LEVER'));
% className = {}; className = {};
% for ff=1:length(flist) for ff=1:length(flist)
% cn = regexp(flist(ff).name,'(\d+-\d+-\d+)_.*(\d\d)_ori*','tokens'); cn = regexp(flist(ff).name,'(\d+-\d+-\d+)_.*(\d\d)_ori*','tokens');
% cn = [cn{1}{1} '_' cn{1}{2}]; cn = [cn{1}{1} '_' cn{1}{2}];
% className{ff} = classMap(cn); className{ff} = classMap(cn);
% end end
% targetClass = {'AKT1_E17K','WT','PIK3CA_E545K'} % targetClass = {'AKT1_E17K','WT','PIK3CA_E545K'}
% idx = find(cellfun(@(x) ~isempty(find(strcmp(targetClass,x))),className)); % idx = find(cellfun(@(x) ~isempty(find(strcmp(targetClass,x))),className));
% A=d(idx,idx); % A=d(idx,idx);
......
% map [-1,1] kymographs to color space [0,255]
%
function clipLimits = getClipLimits(flist,targetChannelNumbers,clipRange,nKeep)
if ~exist('clipRange','var')
clipRange= [2.5,97.5];
end
p = ljsStartParallel();
kymoPixels = {};
parfor ff=1:length(flist)
kp = {};
for c = 1:length(targetChannelNumbers)
strDB_ff = fullfile(flist(ff).folder,flist(ff).name);
im_ff = SSF.loadImage(strDB_ff,targetChannelNumbers(c));
if nKeep>0
im_ff(im_ff<0)=0;
end
if nKeep<0
im_ff(im_ff>0)=0;
im_ff = abs(im_ff);
end
kp{c} = im_ff(find(im_ff));
kymoPixels{ff} = kp;
end
end
kymoPixels = vertcat(kymoPixels{:});
clipLimits = [];
for c = 1:size(kymoPixels,2)
% anything other than [0,1] gets set to the corresponding percentile
idx = find(clipRange);
if ~isempty(idx)
px = kymoPixels{:,c};
clipLimits(c,idx) = [prctile(px,clipRange(idx))];
end
clipLimits(c,find(clipRange==0)) = 0;
end
4;
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
% AKT_CHANNEL = 2; % AKT_CHANNEL = 2;
% H2B_CHANNEL = 3; % H2B_CHANNEL = 3;
% targetChannels = [ERK_CHANNEL,AKT_CHANNEL]; % targetChannels = [ERK_CHANNEL,AKT_CHANNEL];
function d=go_ssf_ncd(kROOT,targetChannels) function d=go_ssf_ncd(kROOT,targetChannels,clipRange, nKeep)
tStart = tic(); tStart = tic();
...@@ -14,16 +14,7 @@ kymoPixels = {}; ...@@ -14,16 +14,7 @@ kymoPixels = {};
p = ljsStartParallel(); p = ljsStartParallel();
% %
parfor ff=1:length(flist) clipLimits = SSF.getClipLimits(flist,targetChannels,clipRange,nKeep);
strDB_ff = fullfile(flist(ff).folder,flist(ff).name);
im_ff = SSF.loadImage(strDB_ff,targetChannels);
kp = im_ff(find(im_ff));
kymoPixels{ff} = kp;
end
kymoPixels = vertcat(kymoPixels{:});
% erkClipLimits = [prctile(kymoPixels,2.5),prctile(kymoPixels,97.5)]
erkClipLimits = [0,prctile(kymoPixels,99)];
% erkClipLimits = [-1,1];
% %
cmdList = NCD.dParallelCommandList(ones(length(flist)),p.NumWorkers); cmdList = NCD.dParallelCommandList(ones(length(flist)),p.NumWorkers);
...@@ -43,8 +34,8 @@ parfor i=1:H ...@@ -43,8 +34,8 @@ parfor i=1:H
end end
strDB_ff = fullfile(flist(ff).folder, flist(ff).name); strDB_ff = fullfile(flist(ff).folder, flist(ff).name);
if ~strcmp(strDB_ff,str_ff_prev) if ~strcmp(strDB_ff,str_ff_prev)
im_ff = SSF.loadImage(strDB_ff,targetChannels); im_ff = SSF.loadImage(strDB_ff, targetChannels, clipRange, nKeep);
im_ff = SSF.quantize8(im_ff,erkClipLimits); im_ff = SSF.quantize8(im_ff,clipLimits);
str_ff_prev = strDB_ff; str_ff_prev = strDB_ff;
end end
...@@ -53,8 +44,8 @@ parfor i=1:H ...@@ -53,8 +44,8 @@ parfor i=1:H
dxx(i,j) = d1; dxx(i,j) = d1;
else else
strDB_gg = fullfile(flist(gg).folder,flist(gg).name); strDB_gg = fullfile(flist(gg).folder,flist(gg).name);
im_gg = SSF.loadImage(strDB_gg,targetChannels); im_gg = SSF.loadImage(strDB_gg,targetChannels, clipRange, nKeep);
im_gg = SSF.quantize8(im_gg,erkClipLimits); im_gg = SSF.quantize8(im_gg,clipLimits);
d1 = SSF.ncd_ssf_volume(im_ff,im_gg); d1 = SSF.ncd_ssf_volume(im_ff,im_gg);
d2 = SSF.ncd_ssf_volume(im_gg,im_ff); d2 = SSF.ncd_ssf_volume(im_gg,im_ff);
......
function im = loadImage(strDB,channelList) function im = loadImage(strDB, channelList, clipRange, nKeep)
if ~exist('bDouble','var') if ~exist('bDouble','var')
bDouble = false; bDouble = false;
...@@ -9,3 +9,16 @@ time = 1; % kymo is single time point ...@@ -9,3 +9,16 @@ time = 1; % kymo is single time point
for c=1:length(channelList) for c=1:length(channelList)
im(:,:,:,c) = leversc.loadImage(strDB,time,channelList(c)); im(:,:,:,c) = leversc.loadImage(strDB,time,channelList(c));
end end
% HACK ACK HACK
im = im(:,:,:,:);
if ~exist('clipRange','var')
return;
end
if nKeep > 0
im(im<0) = 0;
end
if nKeep < 0
im(im>0) = 0;
im = abs(im);
end
...@@ -24,7 +24,9 @@ end ...@@ -24,7 +24,9 @@ end
imSSF = zeros(szim(1),szim(2)); imSSF = zeros(szim(1),szim(2));
for i=1:length(cellList) for i=1:length(cellList)
if is3D(CONSTANTS) if is3D(CONSTANTS)
cx = centroidMap(cellList(i).cellID); % cx = centroidMap(cellList(i).cellID);
cx = round(cellList(i).centroid);
cx = [cx(2),cx(1)]; % [y,x]
else else
cx = round(cellList(i).centroid); cx = round(cellList(i).centroid);
cx = [cx(2),cx(1)]; % [y,x] cx = [cx(2),cx(1)]; % [y,x]
...@@ -46,7 +48,9 @@ for i=1:length(cellList) ...@@ -46,7 +48,9 @@ for i=1:length(cellList)
ratio = min(ratio,1); ratio = min(ratio,1);
ratio = max(ratio,-1); ratio = max(ratio,-1);
if abs(imSSF(cx(1),cx(2))) < abs(ratio)
imSSF(cx(1),cx(2)) = ratio; imSSF(cx(1),cx(2)) = ratio;
end
end end
......
...@@ -6,7 +6,7 @@ szIm = Helpers.volumeSize(CONSTANTS); ...@@ -6,7 +6,7 @@ szIm = Helpers.volumeSize(CONSTANTS);
if bDownscale if bDownscale
szIm(1:2) = round(szIm(1:2) ./ 2); szIm(1:2) = round(szIm(1:2) ./ 2);
end end
im_v_kymo = zeros([szIm(2),szIm(1),szIm(5)]); im_v_kymo = zeros([szIm(1),szIm(2),szIm(5)]);
for time = 1:CONSTANTS.imageData.NumberOfFrames for time = 1:CONSTANTS.imageData.NumberOfFrames
cmd = ['select srcCell.centroid as src_centroid,srcCell.time src_time, srcCell.maxRadius as src_maxRadius, '... cmd = ['select srcCell.centroid as src_centroid,srcCell.time src_time, srcCell.maxRadius as src_maxRadius, '...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment