EASY refactor: First attempt

This commit is contained in:
2024-07-27 02:58:49 -04:00
parent 5269962927
commit bce30095aa
11 changed files with 340 additions and 301 deletions

View File

@@ -357,10 +357,6 @@ init_project() {
ask "Initialize a project at $SCANS_DIR?" || return 1
[[ -d $SCANS_DIR/MasterPlateFiles ]] || mkdir -p "$SCANS_DIR/MasterPlateFiles"
DRUG_MEDIA_FILE="$SCANS_DIR/MasterPlateFiles/DrugMedia_$PROJECT.xls"
MASTER_PLATE_FILE="$SCANS_DIR/MasterPlateFiles/MasterPlate_$PROJECT.xls"
# Write skeleton files in csv
# If we have to convert to xlsx later, so be it
@@ -379,17 +375,7 @@ init_project() {
# TODO here we'll copy scan from robot but for now let's pause and wait for transfer
read -r -p "Hit <Enter> to continue: "
# Refactor some of the EASY fs code into here
# Make EASY directories
results_dir="Results$DATE-$PROJECT_SUFFIX"
mkdir "$results_dir"
dirs=('PrintResults' 'CFfigs' 'Fotos' 'Fotos/BkUp' 'matResults')
for d in "${dirs[@]}"; do
mkdir "$results_dir/$d"
done
# Copy templates
rsync -a "$EASY_TEMPLATE_DIR"/{figs,Ptmats} "$results_dir"
}
@@ -533,19 +519,57 @@ easy() {
'NoGrowth_.txt', and 'GrowthOnly_.txt' files will be generated in the 'PrintResults' folder.
EOF
script="$EASY_TEMPLATE_DIR/EASYConsole.m"
script="$EASY_DIR/EASYConsole.m"
# Copy templates
# Add EASY directory to the Matlab path
# If this does not work we can try changing the -sd argument and if that fails then pushing/popping
debug "Adding EASY directory to the Matlab path"
hash matlab &>/dev/null &&
matlab -nodisplay -nosplash -nodesktop -nojvm -batch "addpath('$EASY_TEMPLATE_DIR')"
matlab -nodisplay -nosplash -nodesktop -nojvm -batch "addpath('$EASY_DIR')"
# Ask the user to launch EASYconsole.m in MATLAB
# MATLAB doesn't support passing args to scripts se we have to use ENV VARS instead
# These are proably already set in our scope but be explicit just in case
! ((YES)) && ask "Start EASY in MATLAB? This requires a GUI." &&
SCANS_DIR="$SCANS_DIR" matlab -nosplash -sd "$SCANS_DIR" -r "run $script"
# These are proably already set in our scope but be explicit just in case so we don't have to export?
# TODO will need to play with the -sd startup option to see what works (well)
# Skip this step altogether in auto mode since it requires graphical interaction
if ! ((YES)) && ask "Start EASY in MATLAB? This requires a GUI."; then
export SCANS_DIR PROJECT_DATE EASY_DIR PROJECT_USER PROJECT_PREFIX EASY_SUFFIX EASY_RESULTS_DIR MASTER_PLATE_FILE DRUG_MEDIA_FILE
echo "Hit enter to use the default EASY results directory $SCANS_DIR/Results_${PROJECT_PREFIX}_($PROJECT_SUFFIX)"
(( YES )) || read -r -p "Or enter a custom suffix: " suffix
EASY_RESULTS_DIR="$SCANS_DIR/Results_${PROJECT_PREFIX}_${Ssuffix:-$PROJECT_SUFFIX}"
while [[ -d $EASY_RESULTS_DIR ]]; do
count=1
if [[ $count -eq 1 ]] && ask "$EASY_RESULTS_DIR already exists, increment dir name (y) or overwrite (N)?"; then
EASY_SUFFIX="${Ssuffix:-$PROJECT_SUFFIX}.$((count++))"
EASY_RESULTS_DIR="$SCANS_DIR/Results_${PROJECT_PREFIX}_${EASY_SUFFIX}"
else
EASY_SUFFIX=${suffix:-$PROJECT_SUFFIX}
fi
done
EASY_SUFFIX=${EASY_SUFFIX:-$suffix:-$PROJECT_SUFFIX}
EASY_RESULTS_DIR="$SCANS_DIR/Results_${PROJECT_PREFIX}_${EASY_SUFFIX}"
[[ -d $SCANS_DIR/MasterPlateFiles ]] || mkdir -p "$SCANS_DIR/MasterPlateFiles"
DRUG_MEDIA_FILE="$SCANS_DIR/MasterPlateFiles/DrugMedia_$PROJECT.xls"
MASTER_PLATE_FILE="$SCANS_DIR/MasterPlateFiles/MasterPlate_$PROJECT.xls"
# Make EASY dirs
debug "mkdir -p $EASY_RESULTS_DIR"
mkdir -p "$EASY_RESULTS_DIR"
dirs=('PrintResults' 'CFfigs' 'Fotos' 'Fotos/BkUp' 'matResults')
for d in "${dirs[@]}"; do
mkdir "$EASY_RESULTS_DIR/$d"
done
# Copy templates
rsync -a "$EASY_DIR"/{figs,Ptmats} "$EASY_RESULTS_DIR"
# Launch matlab
matlab -nosplash -r "run $script"
# matlab -nosplash -sd "$SCANS_DIR" -r "run $script"
fi
# Use the function return code see if we succeeded
get_easy_results "$SCANS_DIR" || return 1
@@ -1379,14 +1403,15 @@ main() {
# Templates
QHTCP_TEMPLATE_DIR="$SCRIPT_DIR/templates/qhtcp"
STUDY_TEMPLATE_DIR="$QHTCP_TEMPLATE_DIR/ExpTemplate"
EASY_TEMPLATE_DIR="$SCRIPT_DIR/templates/easy"
EASY_DIR="$SCRIPT_DIR/templates/easy"
IMAGES="${IMAGES:-"/mnt/data/ExpJobs"}"
DATE="$(date +%y_%m%d)"
DATE="$(date +%Y%m%d)" # change general date format here
# Set the automatic project directory prefix
PROJECT_PREFIX="${DATE}_$(whoami)_" # reversed these so easier to sort and parse date
san() { [[ $1 =~ [0-9][0-9]_[0-9][0-9]_[0-9][0-9]_.+_.+ ]]; } # sanitizer regex for prefix
PROJECT_USER="$(whoami)"
PROJECT_PREFIX="${DATE}_${PROJECT_USER}_" # reversed these so easier to sort and parse date
san() { [[ $1 =~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_.+_.+ ]]; } # sanitizer regex for prefix
declare -ag PROJECTS=() # this array will hold all of the projects for this run
@@ -1441,9 +1466,9 @@ main() {
# Loop over projects
for PROJECT in "${PROJECTS[@]}"; do
SCANS_DIR="$IMAGES/$PROJECT"
PROJECT_DATE="${PROJECT%"${PROJECT#??_????}"}" # e.g. 24_0723
PROJECT_SUFFIX="${PROJECT#??_????_*_}"
PROJECT_USER="${PROJECT#??_????_}"
PROJECT_DATE="${PROJECT%"${PROJECT#????????}"}" # e.g. 20240723
PROJECT_SUFFIX="${PROJECT#????????_*_}"
PROJECT_USER="${PROJECT#????????_}"
PROJECT_USER="${PROJECT_USER%%_*}"
# Run selected modules
for m in "${MODULES[@]}"; do

View File

@@ -26,7 +26,7 @@ if ~exist(masterPlateFile, 'file') || isempty(masterPlateFile)
sortedFiles=mpFiles(sortedIndices);
masterPlateFile=sortedFiles{1};
disp('Using newest MasterPlate file: ', masterPlateFile, ', skipping directory selection');
catch Me
catch ME
% This can be silent, not really an error
end
@@ -157,7 +157,7 @@ try
MP(numb).specifics= ' ';
end
excLnNum=excLnNum+385;
msg=strcat('NumberOfMP = ',num2str(numb), 'lastLineNo. = ',num2str(excLnNum))
msg=strcat('NumberOfMP = ',num2str(numb), 'lastLineNo. = ',num2str(excLnNum));
end
end
catch ME
@@ -173,7 +173,7 @@ numOfMedias=0;
% Grabbing the bare filename from the MasterPlate file to see if we can automatically
% find a matching DrugMedia file
[mpFile, mpPath]=fullfile(masterPlateFile)
[mpFile, mpPath]=fullfile(masterPlateFile);
mpFileParts=strsplit(mpFile, '_');
mpBareFileName=strjoin(parts(2:end-1), '_');
@@ -261,7 +261,7 @@ if isequal(Linked,1) % Drugs and Media are linked 1 to 1; else they are combinat
DM.mod2(numb) = {raw(excLnNum,7)};
DM.conc2(numb) = {raw(excLnNum,8)};
excLnNum=excLnNum+1;
msg=strcat('NumberOf1:1DrugMediaPlates = ',num2str(numb), ' lastLineNo. = ',num2str(excLnNum))
msg=strcat('NumberOf1:1DrugMediaPlates = ',num2str(numb), ' lastLineNo. = ',num2str(excLnNum));
end
else
clear DM
@@ -283,7 +283,7 @@ if isequal(Linked,1) % Drugs and Media are linked 1 to 1; else they are combinat
DM.conc2(numb) = {DMtbl(excLnNum,8)};
DM.conc2(numb)= table2cell(DM.conc2{numb});
excLnNum=excLnNum+1;
msg=strcat('NumberOf1:1DrugMediaPlates = ',num2str(numb), ' lastLineNo. = ',num2str(excLnNum))
msg=strcat('NumberOf1:1DrugMediaPlates = ',num2str(numb), ' lastLineNo. = ',num2str(excLnNum));
end
end
end
@@ -321,7 +321,7 @@ if isequal(Linked,0) % 0 indicates Drugs and Media are combinatorial
excLnNum=excLnNum+1;
end
end
msg=strcat('NumberOfDrugs = ',num2str(drgCnt), ' NumberOfMedias = ',num2str(medCnt) )
msg=strcat('NumberOfDrugs = ',num2str(drgCnt), ' NumberOfMedias = ',num2str(medCnt) );
end
save(mpdmFile, 'fields','MP','DM','Linked');

View File

@@ -3,18 +3,25 @@
% Updated 240724 Bryan C Roessler to improve file operations and portability
%
function varargout = EASYconsole(varargin)
global startDir
global easyDir
global easySuffix
global scansDir
global easyResultsDir
global easyResultsDirName
global fotosResultsDir
global figsResultsDir
global pointMapsResultsDir
global pointMapsFile
global printResultsDir
global matDir
global matFile
global drugMediaFile
global masterPlateFile
global mpdmFile
global userName
global srchRange
% Initialize some variables from matlab
startDir=pwd;
easyPath=which(mfilename);
[easyDir,easyFileName]=fileparts(easyPath);
easyDir=fullfile(easyDir);
@@ -27,22 +34,27 @@ function varargout = EASYconsole(varargin)
% Set scansDir intelligently (project scans directory)
% Allow users to specify a PROJECT=/mnt/data/ExpJobs/Job directory to analyze with EASY
% This better enables running the new EASY in standalone mode
if exist('PROJECT', 'env')
if exist('PROJECT', 'env') && ~isempty(getenv('PROJECT'))
scansDir=get_env('PROJECT');
disp(strcat('Using project path: ', scansDir, ' from environment variable PROJECT'));
disp('This usually indicates that we are in standalone mode');
elseif exist('SCANS_DIR', 'env')
elseif exist('SCANS_DIR', 'env') && ~isempty(getenv('SCANS_DIR'))
scansDir=get_env('SCANS_DIR');
disp(strcat('Using scans directory: ', scansDir, ' from environment variable SCANS_DIR'));
disp('This usually indicates that we are in module mode');
else
scansDir=fullfile(parentDir,'ExpJobs'); % relative to easy script dir
dirToScan=fullfile(parentDir,'ExpJobs'); % hardcoded relative to easy script dir TODO: if we change pj layout this will change
dirs=dir(fullfile(dirToScan, 'dir')); % filter for dirs only
[~, sortedIndices] = sort(datenum({dirs.date}), 'descend'); % sort by newest first
sortedDirs=dirs{sortedIndices};
scansDir=sortedDirs{1};
disp('Beginning in newest project scans directory');
disp(strcat('Using scans directory: ', scansDir, ' from hardcoded default'));
disp('This usually indicates that we are in standalone mode');
disp('This usually indicates that we are in stand-alone mode');
end
% If we don't have the EASY_SUFFIX from the module, generate it from scanDir
if exist('EASY_SUFFIX', 'env')
% If we don't have the EASY_SUFFIX from the module, generate it from scansDir
if exist('EASY_SUFFIX', 'env') && ~isempty(getenv('EASY_SUFFIX'))
easySuffix=get_env('EASY_SUFFIX');
else
[dirName, ~]=fileparts(scansDir);
@@ -69,10 +81,11 @@ function varargout = EASYconsole(varargin)
end
% Helpful variables for running in workflow mode that I'll probably have to reimplement in matlab anyways for standalone mode
if exist('EASY_DIR','env')
if exist('EASY_DIR','env') && ~isempty(getenv('EASY_DIR'))
EASY_DIR=fullfile(get_env('EASY_DIR'));
if easyDir ~= EASY_DIR % sanity check
disp("WARNING: EASY_DIR does not match this script's default EASY location");
disp("WARNING: EASY_DIR does not match this script's hardcoded EASY location");
disp("This is probably OK but if strange beahvior arises, we'll need to fix it in code");
easyDir=EASY_DIR;
end
disp(strcat('Using EASY script directory: ', easyDir, ' from environment variable EASY_DIR'));
@@ -80,12 +93,7 @@ function varargout = EASYconsole(varargin)
disp(strcat('Using EASY script directory: ', easyDir, ' from hardcoded default'));
end
% Now that we have easyDir let's add it to the path just to be safe
% TODO I have no idea if this is necessary or effective but we'll see
% I could image it would reduce some weird matlab errors?
addpath(easyDir);
if exist('EASY_RESULTS_DIR', 'env')
if exist('EASY_RESULTS_DIR', 'env') && ~isempty(getenv('EASY_RESULTS_DIR'))
easyResultsDir=fullfile(get_env('EASY_RESULTS_DIR'));
disp(strcat('Using project prefix: ', easyResultsDir, ' from environment variable EASY_RESULTS_DIR'))
else
@@ -95,21 +103,73 @@ function varargout = EASYconsole(varargin)
disp(strcat('Using project prefix: ', PROJECT_PREFIX, ' from environment variable PROJECT_PREFIX'))
end
if exist('PROJECT_USER', 'env')
if exist('PROJECT_USER', 'env') && ~isempty(getenv('PROJECT_USER'))
if get_env('PROJECT_USER') ~= userName % sanity check
disp("WARNING: PROJECT_USER does not match the current namespace");
end
end
matDir=fullfile(easyResultsDir,'matResults');
matFile=fullfile(matDir,strcat(easyResultsDirName,'.mat'));
if exist('MASTER_PLATE_FILE', 'env') && ~isempty(getenv('MASTER_PLATE_FILE'))
masterPlateFile=fullfile(get_env('MASTER_PLATE_FILE'));
disp(strcat('Using drug media file: ', masterPlateFile, ' from environment variable MASTER_PLATE_FILE'))
else
% Try to find MasterPlate_ file on our own
mp=fullfile(scansDir,'MasterPlateFiles',strcat('MasterPlate_', easySuffix,'.xlsx'));
if exist(mp, 'file'))
masterPlateFile=mp;
disp(strcat('Using drug media file: ', masterPlateFile, ' from internal logic'))
else
disp("WARNING: Have you created a MasterPlate_ file?")
end
end
% Play around with making some common variables from our input data
% resDirName=fullfile(SCANS_DIR,'Results',dateStr,'_', PROJECT_SUFFIX);
% resDir=fullfile(SCANS_DIR,resDirName);
% ExpOutmat=fullfile(matDir,strcat(datestr(now,29),newExpfile));
% ExpPath=fullfile(newExppath);
% ExpFile=fullfile(matDir,)
if exist('DRUG_MEDIA_FILE', 'env') && ~isempty(getenv('DRUG_MEDIA_FILE'))
drugMediaFile=fullfile(get_env('DRUG_MEDIA_FILE'));
disp(strcat('Using drug media file: ', drugMediaFile, ' from environment variable DRUG_MEDIA_FILE'))
else
% Try to find MasterPlate_ file on our own
dm=fullfile(scansDir,'MasterPlateFiles',strcat('DrugMedia_', easySuffix,'.xlsx'));
if exist(mp, 'file'))
drugMediaFile=dm;
disp(strcat('Using drug media file: ', drugMediaFile, ' from internal logic'))
else
disp("WARNING: Have you created a DrugMedia_ file?")
end
end
matDir=fullfile(easyResultsDir,'matResults');
if ~exist(matDir, 'dir')
mkdir(matDir);
end
matFile=fullfile(matDir,strcat(easyResultsDirName,'.mat'));
% Pulled these out of par4GblFnc8c
printResultsDir=fullfile(easyResultsDir,'PrintResults');
fotosResultsDir=fullfile(easyResultsDir,'Fotos');
figsResultsDir=fullfile(easyResultsDir,'figs');
pointMapsResultsDir=fullfile(easyResultsDir,'PTmats');
pointMapsFile=fullfile(pointMapsResultsDir,'NImParameters.mat')
oldPointMapsFile=fullfile(pointMapsResultsDir,'ImParameters.mat')
CSearchRangeFile=fullfile(fotosResultsDir,'CSearchRange.mat');
mpdmFile=fullfile(matDir,'MPDM.mat');
% This can be removed, I think it should add the previous search range?
% Might be nice feature but can remove if it causes issues
% We are using searchRangeNum to hold old CSrchRange value(s)
if exist(CSearchRangeFile, 'file')
searchRangeNum=load(CSearchRangeFile);
end
% Add easyDir to the MATLAB path
% I have not idea if this is necessary or works but theoretically should
% reduce directory scoping issues when calling scripts w/o a path
addpath(easyDir);
% Pulled this out of the opening function
% Seems better to wait until we have our ars set
if exist('scansDir','var') && ~isempty(scansDir)
set(fhconsole,'Name',strcat('EASYconsole - ',char(scansDir)));
else
set(fhconsole,'Name','EASYconsole - No Active Experiment.')
end
% GUI interface design
gui_Singleton=1;
@@ -164,15 +224,6 @@ function EASYconsole_OpeningFcn(hObject, ~, handles, varargin)
fhconsole=gcf;
set(fhconsole,'Toolbar','none');
fhconsole=gcf;
% BCR this is set in the global function so I think we're good here
% easyResultsDirName=strcat('Results',todayStr,newExpfilePref);
if exist('easyResultsDir','var') && ~isempty(easyResultsDir)
set(fhconsole,'Name',strcat('EASYconsole- ',char(easyResultsDir)));
else
set(fhconsole,'Name','EASYconsole -Exp. Analysis NOT selected.')
end
end
@@ -200,7 +251,6 @@ end
% New Experiment Button Interface
function NewExpDat_Callback(~, ~, ~)
global SWnewExp
global matDir
global matFile
global easyResultsDir
@@ -213,8 +263,6 @@ function NewExpDat_Callback(~, ~, ~)
try
questdlg('\fontsize{20} NAME the file and NAVIGATE to the directory with the image folders.','File Creation','OK', struct('Default','OK','Interpreter','tex'));
[inputFile,inputPath]=uiputfile('.mat');
SWnewExp=1;
inputFileName=strrep(inputFile,'.mat','');
easyResultsDirName=strcat('Results_',todayStr,'_',userName,'_',inputFileName);
@@ -263,8 +311,7 @@ function NewExpDat_Callback(~, ~, ~)
sbdg= cell(1,scanMax);
save((fullfile(easyResultsDir,'Fotos','Nbdg')),'sbdg');
catch ME
% returnStartDir
disp('Error Creating a New Experiment')
disp(strcat('ERROR: ', ME.message))
end
% set the title for fhconsole depending on existence
@@ -278,39 +325,50 @@ end
% Load a previous experiment
function LoadDatFile_Callback(~, ~, ~)
global SWnewExp
global matDir
global matFile
global easyResultsDir
global easyPath
global fhconsole
%global ImParMat
try
questdlg('\fontsize{20} Load file from ExpJobs/YourJob/YourResults/matResults','File Creation','OK', struct('Default','OK','Interpreter','tex'));
[inputFile,inputPath]=uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off');
SWnewExp=0;
matDir=fullfile(inputPath);
matFile=fullfile(inputPath,inputFile);
load(matFile);
easyResultsDir=fullfile(matDir,'..');
scansDir=fullfile(matDir,'..', '..');
point
% TODO this is pretty hacky and needs something more explicit
if isfolder(fullfile(matDir, '..','..','1')) % If Inovation Vrobot Then
if exist(fullfile(easyResultsDir,'PTmats','NImParameters.mat'), 'file')
load(fullfile(easyResultsDir,'PTmats','NImParameters.mat'));
else
load(fullfile(easyPath,'NImParameters.mat'));
try
exist(pointMapsFile, 'file')
load(pointMapsFile);
catch
try
load(fullfile(easyPath,'NImParameters.mat')); % hardcoded default
catch
disp("Could not load the NImParameters.mat file")
end
end
else % If Epson 10Plate Scans Then>
if exist(fullfile(easyResultsDir,'PTmats','ImParameters.mat'), 'file')
load(fullfile(easyResultsDir,'PTmats','ImParameters.mat'));
if exist(fullfile(pointMapsResultsDir,'ImParameters.mat'), 'file')
load(fullfile(pointMapsResultsDir,'ImParameters.mat'));
else
load(fullfile(easyPath,'ImParameters.mat'));
try
load(fullfile(easyPath,'ImParameters.mat'));
catch
disp("Could not load the ImParameters.mat file")
end
end
end
mkdir(fullfile(matDir,'BkUp'));
bkupDir=fullfile(matDir,'BkUp');
if ~exist(bkupDir, 'dir')
mkkdir(bkupDir);
end
% Create supporting dirs
dirs={'PrintResults', 'figs', 'CFfigs', 'PTmats', 'Fotos'}
@@ -333,8 +391,8 @@ function LoadDatFile_Callback(~, ~, ~)
end
end
%% CALLBACKS %%
% callback for the 'Run' in the dropdown menu
% Callbacks
% 'Run' in the dropdown menu
function run_Callback(~, ~, ~)
end
@@ -378,8 +436,7 @@ end
function runDMPexcel_Callback(~, ~, ~)
try
% DMPexcel2mat_2024winLinix %DMPexcel2mat_2023winLinix
DMPexcel2mat % TODO Can't find above so using what I have available
DMPexcel2mat
catch
EASYconsole
end
@@ -387,7 +444,7 @@ end
function runResults_DBcombo_Callback(~, ~, ~)
try
DgenResults240430 %similar but semicolons removed to restore so cmdLine display info.
DgenResults %similar but semicolons removed to restore so cmdLine display info.
%Dgen241010qhtcp %par4global -convert 1x1cell of 384cells to be like previous 1x384 cells CFparameter
catch ME
disp(strcat('Error in DgenResults240430: ', ME.message))

View File

@@ -1,5 +1,5 @@
%% CALLED WHEN ACCESSING 'CurveFit Display' %%
function [scLst, row, col] = NCdisplayGui(eDir) %(ExpPath)
function [scLst, row, col] = NCdisplayGui(scansDir)
xPos=0.05;
btnWid=0.10;
btnHt=0.05;
@@ -49,7 +49,7 @@ function [scLst, row, col] = NCdisplayGui(eDir) %(ExpPath)
end
% Read in numeric folder names
nlist=dir(fullfile(eDir,'*')); %(ExpPath,'*'));
nlist=dir(fullfile(scansDir,'*'));
nnn=0;
for n=1:size(nlist,1)
if (~isempty(str2num(nlist(n).name)))
@@ -344,28 +344,28 @@ btnNumber=7;
yPos=0.85-(btnNumber-1)*(btnHt+spacing);
btnPos=[xPos yPos-spacing btnWid btnHt];
try
CSrchRange=ImParMat(12);
CSrchRng=ImParMat(12)
srchRange=ImParMat(12);
searchRangeNum=ImParMat(12)
catch %Legacy default value was 18 before being made a user input variable (ImParMat(12)). A preferable value now might be 12 or 14.
CSrchRange=18;
srchRange=18;
ImParMat(12)=18
CSrchRng=ImParMat(12)
searchRangeNum=ImParMat(12)
end
%{
if size(scLst)>1
CSrchRange=ImParMat(12);
srchRange=ImParMat(12);
else
try
CSrchRange=CSearchRange(str2double(scLst))
srchRange=CSearchRange(str2double(scLst))
catch
CSrchRange=ImParMat(12);
srchRange=ImParMat(12);
end
end
%}
hSearchRange = uicontrol(...
'Style', 'edit',...
'String',CSrchRange,...
'String',srchRange,...
'Units','normalized',...
'Position', btnPos,...
'callback',{@CsearchRange});
@@ -376,7 +376,7 @@ hSearchRange = uicontrol(...
errordlg('You must enter a numeric value between 1 and 18 12->18 recommended. (ImParMat(12)))','Bad Input','modal')
return
end
CSrchRng=user_entry
searchRangeNum=user_entry
end
@@ -455,18 +455,4 @@ hedit = uicontrol(...
end
end
%}
%global SWsingleSc
%global SWgrowthArea
%global selScan
%global scan
%global scLst
%global ImParMat
%global CSearchRange
%global CSrchRng
%global defImParMat
%global fhImRun
%global fhconsole
%global resDir
%global ExpOutmat
%global numRows;
%global numCols;

View File

@@ -1,6 +1,6 @@
%% CALLED BY par4GblFnc8c.m %%
function [par4scanselIntensStd,par4scanselTimesStd,par4scanTimesELr,par4scanIntensELr,par4scanCFparameters,par4scanCFdate,outC,outCstd]= ...
NCfitImCFparforFailGbl2(parMat,times, values, timeOffsets, fileSuffix, AUCfinalTime, ~, spotAreas, outputDirectory, ~,~, sols, ~) %,scan)
NCfitImCFparforFailGbl2(parMat,times, values, timeOffsets, fileSuffix, AUCfinalTime, ~, spotAreas, printResultsDir, ~,~, sols, ~) %,scan)
% Preallocation for parfor loop
st(1,1:size(times,2))=1111;
@@ -223,7 +223,7 @@ function [par4scanselIntensStd,par4scanselTimesStd,par4scanTimesELr,par4scanInte
fileExt='.txt';
filePrefix='FitResultsComplete_';
fileNamePlate=[filePrefix fileSuffix fileExt];
fileName=fullfile(outputDirectory, fileNamePlate); %[outputDirectory fileNamePlate];
fileName=fullfile(printResultsDir, fileNamePlate); %[printResultsDir fileNamePlate];
fid=fopen(fileName,'w');
fprintf(fid, 'Fit Results Complete\n');
%fprintf(fid, 'Num.\tAUC\tMSR\tK\tr\tl\tR-squared\tK-lower\tK-upper\tr-lower\tr-upper\tl-upper\tl-lower\tArea\tLastInten\tSpineMaxRateTimePt\tLastFitTimePt\n');

View File

@@ -1,13 +1,10 @@
%% CALLED WHEN ACCESSING 'CurveFit Display' %%
global expDir
global scLst
global ExpPath
global scan
eDir=ExpPath;
hf=figure;
% Parameter Entry
[scLst, row, col]=NCdisplayGui(eDir); %(ExpPath); %Ncode 122111replaced removed ,numOfPrtTimes)
[scLst, row, col]=NCdisplayGui(scansDir);
close(hf)
selSpot=(row-1)*24 + col;
for iPlate=1:length(scLst)

View File

@@ -1,29 +1,35 @@
%% CALLED BY par4Gbl_Main8c.m %%
function NImParamRadiusGui(expDir)
% TODO Should some of these vars be pulled out higher so they are easier to change?
%
function NImParamRadiusGui(scansDir)
global SWsingleSc
global SWgrowthArea
%global selScan
global scan
global scLst
global ImParMat
%global CSearchRange
global CSrchRng
global searchRangeNum
global defImParMat
global fhImRun
global fhconsole
global resDir
global ExpOutmat
global numRows;
global numCols;
global easyResultsDir
global fotosResultsDir
global pointMapsResultsDir
global pointMapsFile
global matFile
global numRows
global numCols
global scanSize
global scanMax
defImParMat=[1, 1, 15, 34, 24, 1,0,0,1,14,1,18]; %Ncode ImRobot adaptation
% Ncode ImRobot adaptation
% TODO this code block and variables needs explanation
defImParMat=[1,1,15,34,24,1,0,0,1,14,1,18];
if ImParMat(3)==0 || ImParMat(4)==0 ||ImParMat(5)==0 || ImParMat(10)==0 ||ImParMat(11)==0
ImParMat=defImParMat;
end
if size(ImParMat,2)<12
ImParMat(12)=18; %Default before user input CsearchRange value
ImParMat(12)=18; % default before user input CsearchRange value
msg='Data made before SearchRange user entry added (ImParMat(12). 18 was the set value and the current default.)';
end
% ImParMat=defImParMat; %Activate for INITIAL USE only
@@ -31,15 +37,17 @@ function NImParamRadiusGui(expDir)
destPerMP=1;
selScan=1;
SWgrowthArea=1;
if exist(fullfile(resDir,'PTmats','NImParameters.mat'))
load(fullfile(resDir,'PTmats','NImParameters'));
if exist(pointMapsFile)
load(pointMapsFile);
else
load NImParameters
load(fullfile(PTmats,'NImParameters')) % hardcoded default
disp('WARNING: Using hardcoded NImParameters.mat')
end
ImParMat;
%if ~exist('CSearchRange','var') || isempty(CSearchRange)
if ~isequal(exist(fullfile(resDir,'Fotos','CSearchRange.mat')),0)
load(fullfile(resDir,'Fotos','CSearchRange'))
ImParMat
% if ~exist('searchRangeNum','var') || isempty(searchRangeNum)
if exist(CSearchRangeFile), 'file')
load(CSearchRangeFile);
CSearchRange;
end
@@ -54,9 +62,9 @@ function NImParamRadiusGui(expDir)
yPos=0.85-(btnNumber-1)*(btnHt+spacing);
btnPos=[xPos yPos-spacing btnWid btnHt];
fhImParm=gcf;
if exist('resDir','var')&& ~isempty(resDir)
if exist('easyResultsDir','var')&& ~isempty(easyResultsDir)
set(fhImParm,'NumberTitle','off')
set(fhImParm,'Name',strcat('ImageAnalysis- ',char(resDir)))
set(fhImParm,'Name',strcat('ImageAnalysis- ',char(easyResultsDir)))
else
set(fhImParm,'NumberTitle','off')
set(fhImParm,'Name','EASYconsole -Exp. Analysis NOT selected.')
@@ -110,32 +118,30 @@ function NImParamRadiusGui(expDir)
yPos=0.85-(btnNumber-1)*(btnHt+spacing);
btnPos=[xPos yPos-spacing btnWid btnHt];
try
CSrchRange=ImParMat(12);
CSrchRng=ImParMat(12);
catch %Legacy default value was 18 before being made a user input variable (ImParMat(12)). A preferable value now might be 12 or 14.
CSrchRange=18;
srchRange=ImParMat(12);
catch % Legacy default value was 18 before being made a user input variable (ImParMat(12)). A preferable value now might be 12 or 14.
srchRange=18;
ImParMat(12)=18;
CSrchRng=ImParMat(12);
end
hSearchRange=uicontrol(...
'Style', 'edit',...
'String',CSrchRange,...
'Value',searchRangeNum,...
'Units','normalized',...
'Position', btnPos,...
'callback',{@CsearchRange});
'callback',{@searchRangeCallback});
function CsearchRange(source,~)
function searchRangeCallback(source,~)
user_entry=str2double(get(source,'string'));
if (isnan(user_entry)||(user_entry<1)||(user_entry>50)) %originally 18; 19_0729 increased
errordlg('You must enter a numeric value between 1 and 18 12->18 recommended. (ImParMat(12)))','Bad Input','modal')
return
end
CSrchRng=user_entry;
searchRangeNum=user_entry;
end
% Ncode 12_0120 for reading in numeric folder names
nlist=dir(fullfile(expDir,'*'));
nlist=dir(fullfile(scansDir,'*'));
nnn=0;
for n=1:size(nlist,1)
if (~isempty(str2num(nlist(n).name)))
@@ -158,8 +164,7 @@ function NImParamRadiusGui(expDir)
'callback',{@load_listbox}); %'uiresume(gcbf)'); 'Position', [5 100 60 20])
function load_listbox(source,~)
%global CSrchRng
%global CSrearchRange
global
userIndx=(get(source,'value'));
userStr=(get(source,'string'));
%scLstIndx=str2num(char(strrep(userStr(userIndx), 'Scan', '')))
@@ -167,11 +172,11 @@ function NImParamRadiusGui(expDir)
user_entry=userStr(userIndx);
scLst=user_entry;
if size(scLst,1)>1
%CSrchRng=num2str(ImParMat(12))
% searchRangeNum=num2str(ImParMat(12))
set(hSearchRange,'string',num2str(ImParMat(12)))
else
try
CSrchRng=CSearchRange(str2double(scLst));
searchRangeNum=CSearchRange(str2double(scLst));
set(hSearchRange,'string',CSearchRange(str2double(scLst)))
catch
% CSrchRng=num2str(ImParMat(12))
@@ -231,16 +236,10 @@ function NImParamRadiusGui(expDir)
end
ImParMat;
CSearchRange;
try
save('NImParameters','ImParMat')
% save('CSearchRange','CSearchRange')
catch
save(fullfile('\','NImParameters'),'ImParMat')
% save(fullfile('\','CSearchRange'),'CSearchRange')
end
save((fullfile(resDir,'PTmats','NImParameters')), 'ImParMat');
save((fullfile(resDir,'Fotos','CSearchRange')),'CSearchRange');
searchRangeNum;
save(pointMapsFile, 'ImParMat');
save(CSearchRangeFile,'searchRangeNum');
close
return

View File

@@ -1,10 +1,12 @@
%% CALLED BY par4GblFnc8c.m %%
function [Tmpsbdg2, scanIntens, F_spots, bmtp, optomizedPos, TmpexpScanIntens2, TmpFexpScanSpots2, TmpFexpScanBMtp2, TmpanlZoneRefs2,areaOfIntensAboveBG]= ...
NIscanIntensBGpar4GblFnc(Fflg, tifFileLst, ImParMat,PTmapPos,optCirMask,diaExt,doCircle,cirPixA,numRows,numCols,ImHeigth,ImWidth,cirMask, ...
tptLength,selScan,Empsc,~, ~, ~, ~,resDir, Tmpsbdg1)
tptLength,selScan,Empsc,~, ~, ~, ~,easyResultsDir, Tmpsbdg1)
global ExpOutmat
global matFile
global CSrchRng
global figsResultsDir
global fotosResultsDir
searchIntens=[]; intensMax=[]; detMaxPos=[]; scIntens=[]; areaOfIntensAboveBG=[]; BkgrdMat=[];
@@ -33,7 +35,8 @@ function [Tmpsbdg2, scanIntens, F_spots, bmtp, optomizedPos, TmpexpScanIntens2,
PTmapOnesDbl(PTrefPtR:(PTrefPtR+(diaExt-1)),PTrefPtC:(PTrefPtC+(diaExt-1)))=optCirMask;
end
end
end %if Fflg==1
end
% Zeroth Initial Search Parameters
rRangeUpper=-12;
rRangeLower=12;
@@ -73,11 +76,12 @@ function [Tmpsbdg2, scanIntens, F_spots, bmtp, optomizedPos, TmpexpScanIntens2,
intensPrev=zeros(24,16);
cent=cell(24,16);
BGTav=zeros(numRows,numCols);
BGthres(1:numRows,1:numCols)=95; %70;before incr.to95 to accommodate dark media %50forEpson;%Initialize for first tPt run *****************************************************<<
if length(tifFileLst) >2
%******Determine a good Plate Image from all the timepoints to use for Registration
%Plate Intensity curve over time points
%clear plateImage
% 7 0;before incr.to95 to accommodate dark media %50forEpson;%Initialize for first tPt run
BGthres(1:numRows,1:numCols)=95;
if length(tifFileLst)>2
% Determine a good Plate Image from all the timepoints to use for Registration
% Plate Intensity curve over time points
% clear plateImage
plateImage={};
%{
% Version compatability fixes
@@ -517,8 +521,8 @@ function [Tmpsbdg2, scanIntens, F_spots, bmtp, optomizedPos, TmpexpScanIntens2,
% NIgenBkGrdDataPar4Fnc(ImParMat, tifFileLst, lastDetMaxPos, numRows, numCols, fullsc, tPt, BGthres, doCircle, cirPixA, diaExt, cirMask, BGTav)
% Called by NIscanIntensBG.m
% global resDir
global ExpOutmat
% global easyResultsDir
global matFile
% global pixsAboveBG
MPnum=ImParMat(1);
destPerMP=ImParMat(2);
@@ -1146,24 +1150,23 @@ function [Tmpsbdg2, scanIntens, F_spots, bmtp, optomizedPos, TmpexpScanIntens2,
title(strcat('Scan',num2str(selScan),'timePt-',num2str(tPt)));
clf(hfscanIm,'reset');
set(hfIm,'NumberTitle','off')
set(hfIm,'Name', char(ExpOutmat)) % strcat('EASYconsole- ',char(resDir)))
set(hfIm,'Name', char(matFile)) % strcat('EASYconsole- ',char(easyResultsDir)))
if Fflg==1
resDir; % for debugging
fullfile(resDir,'Fotos',strcat('Scan',num2str(selScan),'_timePt-',num2str(tPt)))
hgsave(fullfile(resDir,'Fotos',strcat('Scan',num2str(selScan),'_timePt-',num2str(tPt)))); %F 14_0626
fullfile(fotosResultsDir,strcat('Scan',num2str(selScan),'_timePt-',num2str(tPt)))
hgsave(fullfile(fotosResultsDir,strcat('Scan',num2str(selScan),'_timePt-',num2str(tPt)))); %F 14_0626
else
hgsave(fullfile(resDir,'figs',strcat('Scan',num2str(selScan),'_timePt-',num2str(tPt))));
hgsave(fullfile(figsResultsDir,strcat('Scan',num2str(selScan),'_timePt-',num2str(tPt))));
end
else
selScan;
%tifFile
% tifFile
end
BkgrdMat=totBkgrd; % BkgrdMat(:,:,tPt)=totBkgrd; %debug parfor effort
areaOfIntensAboveBG(:,:,tPt)=pixsAboveBG; % actual area of growth for each timepoint (used for printout of grArea ?not used in previous analysis)
scanIntens(:,:,tPt)=intens-BkgrdMat;
% capture first and last background values
% Capture first and last background values
if tPt==1
bdg(:,:,1)=bmm;
bdg(:,:,3)=rwm;

View File

@@ -3,7 +3,7 @@ function[p4L4,...
TmpexpScanIntens4,TmpFexpScanSpots4,TmpFexpScanBMtp4,TmpanlZoneRefs4,Tmpsbdg4]= ...
p4loop8c(parMat,tptLength,numScans,selScanNumLst,SWsingleSc,Fflg,PTmapPos,optCirMask,diaExt,doCircle,cirPixA,cirMask,width, ...
TmpexpScanIntens00,TmpFexpScanSpots00,TmpFexpScanBMtp00,TmpanlZoneRefs00,~,tifFileLstP4,pathname,ImParMat, ...
numRows,numCols,scLst,resDir,expDir, p4L00,TmpexpScanIntens4,TmpFexpScanSpots4,TmpFexpScanBMtp4,TmpanlZoneRefs4, Tmpsbdg00, Tmpsbdg4)
numRows,numCols,scLst,easyResultsDir,scansDir, p4L00,TmpexpScanIntens4,TmpFexpScanSpots4,TmpFexpScanBMtp4,TmpanlZoneRefs4, Tmpsbdg00, Tmpsbdg4)
p4L0=p4L00;
TmpexpScanIntens0=TmpexpScanIntens00;
TmpFexpScanSpots0=TmpFexpScanSpots00;
@@ -15,7 +15,7 @@ Tmpsbdg0= Tmpsbdg00;
if SWsingleSc==1
parforArg=0;
else
parforArg= inf;
parforArg=inf;
end
% for (scCount=1:numScans)
@@ -25,7 +25,7 @@ parfor (scCount=1:numScans,parforArg)
[p4L3,TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneRefs3,Tmpsbdg3]= ...
par4GblFnc8c(parMat,tptLength,numScans,selScanNumLst,SWsingleSc,Fflg,PTmapPos,optCirMask,diaExt,doCircle,cirPixA,cirMask,width, ...
TmpexpScanIntens0,TmpFexpScanSpots0,TmpFexpScanBMtp0,TmpanlZoneRefs0,scCount,tifFileLstP4,pathname,ImParMat, ...
numRows,numCols, scLst,resDir,expDir, p4L0,Tmpsbdg0);
numRows,numCols, scLst,easyResultsDir,scansDir, p4L0,Tmpsbdg0);
p4L4(:,scCount)=p4L3; % (:,scCount);
TmpexpScanIntens4(scCount)=TmpexpScanIntens3;

View File

@@ -2,11 +2,13 @@
function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneRefs3,Tmpsbdg3]= ...
par4GblFnc8c(parMat,tptLength,~,selScanNumLst,~,Fflg,PTmapPos,optCirMask,diaExt,doCircle,cirPixA,cirMask,~,...
TmpexpScanIntens,TmpFexpScanSpots,TmpFexpScanBMtp,TmpanlZoneRefs,scCount,tifFileLstP4,~,ImParMat, ...
numRows,numCols,scLst,resDir,expDir,~, Tmpsbdg)
numRows,numCols,scLst,easyResultsDir,scansDir,~, Tmpsbdg)
global printResultsDir
selScan=selScanNumLst(scCount);
tptLength0=length(tifFileLstP4{scCount});
%tptLength=numFiles;
% tptLength=numFiles;
tifFileLst={tifFileLstP4(scCount)};
% Extract the Imaging time stamps from selected tif files
@@ -21,13 +23,13 @@ function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneR
scLst;
scLst(scCount)
char(scLst(scCount))
char(fullfile(expDir,char(scLst(scCount))))
expDir;
char(fullfile(scansDir,char(scLst(scCount))))
scansDir;
swCatch=0;
nndx=nndx+1;
tifFile=char(fullfile(expDir,char(scLst(scCount)), tifFileLstP4{scCount}(tPt)));
tifFile=char(fullfile(scansDir,char(scLst(scCount)), tifFileLstP4{scCount}(tPt)));
try
info=imfinfo(tifFile); %('D:\jwrDevel\DevelCurveFittingJWR\ImageScans\Scan2\020hr002.tif')
info=imfinfo(tifFile); % D:\jwrDevel\DevelCurveFittingJWR\ImageScans\Scan2\020hr002.tif
catch ME
% Note: During parallel operation Matlab will not open file (fid)
% etc. Therefore error message text will not be written.The only way
@@ -35,30 +37,31 @@ function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneR
% the ..Main8c script outside the parfor loop and print to file from
% there. Consequently for now it only prints error to file when one
% edits p4loop8c.m from 'parfor' to ordinary 'for' loop
fFail=((fullfile(resDir,'PrintResults','ImageFileReadFailure.txt')));
fFail=((fullfile(printResultsDir,'ImageFileReadFailure.txt')));
fid=fopen(fFail,'a'); %create,open and append
%fprintf(fid,'%s \n',char(tifFile))
% fprintf(fid,'%s \n',char(tifFile))
fclose(fid)
nndx=nndx-1;
swCatch=1;
rep=getReport(ME, 'basic');
rep=strcat('Read info failure for-',tifFile,' -', rep);
%fprintf(fid,'%s \n',rep) %See Note:
% fprintf(fid,'%s \n',rep) %See Note:
end
tptLength=nndx;
scTmNumeric=1; %initialize for parfor
if swCatch==0
scTmNumeric(nndx)=datenum(info.FileModDate);
e(nndx,:)={tifFile, scTmNumeric(nndx)};
%newtifFileLst(nndx)=tifFileLst(tPt);
% newtifFileLst(nndx)=tifFileLst(tPt);
end
end
% clear tifFileLst;
% Clear tifFileLst;
tifFileLst=cell(nndx,1);
f={sortrows(e,2)};
tifFileLst=f{1,1}(:,1);
areaOfIntensAboveBG=zeros(24,16,length(tifFileLst));
% Calculate Time series for each Plate of Selected Scan
lastPlateOnScan=1; %Ncode
tSeriesv=[]; t0Seriesv=[];
@@ -69,7 +72,7 @@ function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneR
t0Seriesv=((scTmNumv-scTmNumv(1))*24);
end
% added to jump over and fill data for invalid Sscan(plate runs
% Added to jump over and fill data for invalid Sscan(plate runs
if tptLength>=3
% Create blank scan
ImHeigth=2075;
@@ -83,7 +86,7 @@ function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneR
% Execute Image conversion into Intensity Data
[Tmpsbdg2, scanIntens, ~, ~, ~, TmpexpScanIntens2, TmpFexpScanSpots2, TmpFexpScanBMtp2, TmpanlZoneRefs2,areaOfIntensAboveBG]= ...
NIscanIntensBGpar4GblFnc(Fflg,tifFileLst, ImParMat, PTmapPos,optCirMask,diaExt,doCircle,cirPixA,numRows,numCols,ImHeigth,ImWidth,cirMask, ...
tptLength,selScan,Empsc,TmpexpScanIntens,TmpFexpScanSpots,TmpFexpScanBMtp,TmpanlZoneRefs,resDir, Tmpsbdg);
tptLength,selScan,Empsc,TmpexpScanIntens,TmpFexpScanSpots,TmpFexpScanBMtp,TmpanlZoneRefs,easyResultsDir, Tmpsbdg);
TmpexpScanIntens3=TmpexpScanIntens2;
TmpFexpScanSpots3=TmpFexpScanSpots2;
@@ -100,25 +103,23 @@ function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneR
% NIcheck: Check for bad scans at time points (swapped plates etc.)
% Set up cell arrays for storing each plate in each Scan ..(scan,plate)
SWprint=0;
if SWprint==1
wkDir=pwd;
cd (fullfile(resDir,'PrintResults'));
end
% Construct Legacy ...Intens.txt file
if SWprint==1
filename=(strcat('Plate',num2str(selScan),'_Intens.txt'));
filename=fullfile(easyResultsDir,'PrintResults',(strcat('Plate',num2str(selScan),'_Intens.txt')));
fid=fopen(filename,'w');
end
if length(size(plate))==2 %Only two dims if only one image
if length(size(plate))==2 % only two dims if only one image
numOfImages=1;
else
numOfImages=size(plate,3);
end
CFscanIntens=zeros(384,numOfImages);
locIndx=0; pl=1;
for n=1:numCols %Ncode changed to 16 for Vert
for m=1:numRows %Ncode change to 24 for Vert
for n=1:numCols % Ncode changed to 16 for Vert
for m=1:numRows % Ncode change to 24 for Vert
locIndx=locIndx+1;
for k=1:numOfImages
if SWprint==1
@@ -148,10 +149,10 @@ function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneR
% for p=1:lastPlateOnScan
if SWprint==1
if SWgrowthArea==1
filename=(strcat('Plate',num2str(selScan),'_Areas.txt'));
filename=fullfile(printResultsDir,(strcat('Plate',num2str(selScan),'_Areas.txt')));
else
filename=(strcat('ALTgrowthA_Scan',num2str(selScan),'_Plate',num2str(1),'_Areas.txt'));
filename=(strcat('ALTgrowthA_Plate',num2str(selScan),'_Plate','_Areas.txt'));
filename=fullfile(printResultsDir,(strcat('ALTgrowthA_Scan',num2str(selScan),'_Plate',num2str(1),'_Areas.txt')));
filename=fullfile(printResultsDir,(strcat('ALTgrowthA_Plate',num2str(selScan),'_Plate','_Areas.txt')));
end
fid=fopen(filename,'w');
end
@@ -170,11 +171,7 @@ function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneR
if SWprint==1
fclose(fid);
end
if SWprint==1
cd(wkDir);
fclose('all');
% fclose('all'); % TODO do we need this?
end
% AutoImCF curveFit kickoff setup
@@ -186,7 +183,6 @@ function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneR
suffix=strcat('Scan', num2str(selScan),'_Plate', num2str(1)); % char(QspLst(n));
AUCfinalTime=96;
arrayFormat=384;
currDirResults=fullfile(resDir,'PrintResults');
% Version compatability fixes
%{
@@ -225,10 +221,10 @@ function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneR
% CFscanIntens
% Call CurveFit routine
% NCfitImCF(times, CFscanIntens, offsets, suffix, AUCfinalTime, arrayFormat, scanAreas, currDirResults, autoImCFlag, selScan,sols) %,scan)%, scPltList) outputDirectory;
% [scanTmp2]=NCfitImCFparforFailGbl(times, CFscanIntens, offsets, suffix, AUCfinalTime, arrayFormat, scanAreas, currDirResults, autoImCFlag, selScan, sols, scanTmp); %,scan)%, scPltList) outputDirectory;
% NCfitImCF(times, CFscanIntens, offsets, suffix, AUCfinalTime, arrayFormat, scanAreas, printResultsDir, autoImCFlag, selScan,sols) %,scan)%, scPltList) outputDirectory;
% [scanTmp2]=NCfitImCFparforFailGbl(times, CFscanIntens, offsets, suffix, AUCfinalTime, arrayFormat, scanAreas, printResultsDir, autoImCFlag, selScan, sols, scanTmp); %,scan)%, scPltList) outputDirectory;
[par4scanselIntensStd,par4scanselTimesStd,par4scanTimesELr,par4scanIntensELr,par4scanCFparameters,par4scanCFdate,outC2,outCstd2]= ...
NCfitImCFparforFailGbl2(parMat,times, CFscanIntens, offsets, suffix, AUCfinalTime, arrayFormat, scanAreas, currDirResults, autoImCFlag, selScan, sols); %,scan)%, scPltList) outputDirectory;
NCfitImCFparforFailGbl2(parMat,times, CFscanIntens, offsets, suffix, AUCfinalTime, arrayFormat, scanAreas, printResultsDir, autoImCFlag, selScan, sols); %,scan)%, scPltList) outputDirectory;
else %fill with default values when an invalid plate scan occurs
CFscanIntens=zeros(16,24);
Ag=zeros(1,384);

View File

@@ -1,43 +1,22 @@
%% CALLED BY EASYconsole.m %%
w=pwd;
%function NImStartupImCF02par4Gbl
Fflg=1; %0;
fclose('all'); %close all open files
clear('plate2', 'scanIntens','Scanfiles','pathname','tifFileLstP4')
%global SWsingleSc
global SWgrowthArea
global scLst
global ImParMat
%global CSearchRange
%global CSrchRng
global expDir
global SWnewExp
global openExpfile
global openExppath
global newExpfile
global newExppath
global ExpOutmat
global scansDir
global matFile
global fhconsole
global ExpPath
global resDir
global wCodeDir
global easyResultsDir
global pointMapsResultsDir
global fotosResultsDir
global matDir
global ImWidth
global ImHeigth
global numRows;
global numCols;
%global SWprintLeg
global numRows
global numCols
global scan
%global scanSize
global scanMax
global tptLength
%global scanPar4x
%global sols
%global CFmeth
numRows=24; % for Single Vertical
numCols=16; % for Single Vertical
@@ -48,22 +27,31 @@ radius=14;
ImParMat(10)=radius;
ImParMat(11)=doCircle;
% TODO what is this for?
Fflg=1;
% Don't think we need this
% fclose('all'); % close all open files
% Unset some vars just in case they are already set
clear('scanIntens','Scanfiles','pathname','tifFileLstP4')
try
clf(fhconsole,'reset')
catch ME
end
close
EASYconsole
try
load(ExpOutmat)
copyfile(ExpOutmat,(fullfile(matDir,'BkUp',strcat((num2str(datenum(now))),'.mat'))))
catch
end
% No idea why we're doing this so commenting out
% close
% EASYconsole
if exist(matFile, 'file')
bkUpMatFile=fullfile(matDir,'BkUp',matFile)
copyfile(matFile,(fullfile(matDir,'BkUp',matFile)))
end
try
load(fullfile(resDir,'Fotos','Nbdg')) %Modified to load from 'Fotos' 20_0819
load(fullfile(easyResultsDir,'Fotos','Nbdg')) %Modified to load from 'Fotos' 20_0819
catch
% Reloacated from 'PTmats' to prevent potential overwrite when PTmats is
% copied into new job when the PT template is about the same. We also
@@ -74,35 +62,34 @@ catch
% A copy of Ndbg.mat is placed also saved to the 'PTmats' directory
% after each run to allow previous version of EASY to access data made
% by EASY versions after 20_0819.
load(fullfile(resDir,'PTmats','Nbdg')) %Left in to accomodate loads of work before 20_0819
load(fullfile(easyResultsDir,'PTmats','Nbdg')) %Left in to accomodate loads of work before 20_0819
end
% Load Fotos stored data
try
load(fullfile(resDir,'Fotos','Coordinates'))
load(fullfile(easyResultsDir,'Fotos','Coordinates'))
catch
end
try
load(fullfile(resDir,'Fotos','BGatTpts'))
load(fullfile(easyResultsDir,'Fotos','BGatTpts'))
catch
end
try
load(fullfile(resDir,'Fotos','anlZones'))
load(fullfile(easyResultsDir,'Fotos','anlZones'))
catch
end
% autoImCF
try
load(fullfile(resDir,'PTmats','NCFparms'))
load(fullfile(easyResultsDir,'PTmats','NCFparms'))
catch ME
load parameters
end
% Get Print Times
PrintTimes=[];
expDir=fullfile(ExpPath);
scLst={};
% Parameter Entry
NImParamRadiusGui(expDir) % Ncode 122111replaced removed ,numOfPrtTimes)
NImParamRadiusGui(scansDir) % Ncode 122111replaced removed ,numOfPrtTimes)
width=24;
widthEx=width-1; % width extention from reference point
dither=ImParMat(6);
@@ -131,25 +118,16 @@ else
end
SWgrowthArea=ImParMat(9);
load(fullfile(resDir,'PTmats','NPTmapSearch'))
load(fullfile(pointMapsResultsDir,'NPTmapSearch'))
PTmapPos=detPos;
selScanNumLst=[];
Scanfiles=[];
pathname=[];
% TODO BCR this probably doesn't need to be here but I'm leaving it for now
if ispc
cd(char(strcat(expDir,scLst(1))))
elseif (isunix || ismac)
cd(fullfile(expDir,cell2mat(scLst(1))));
end
Scanfiles=[];
pathname=[];
for ii=1:length(scLst)
if (SWsingleSc == 1)
[Scanfiles, pathname]=uigetfile('*.bmp', 'Select files','MultiSelect','on');% change '*hr*.bmp' 12/20/2011
% TODO proably need to make this more explicit with paths
[Scanfiles, pathname]=uigetfile('*.bmp', 'Select files','MultiSelect','on'); % change '*hr*.bmp' 12/20/2011
if ischar(Scanfiles)
scd=imread(char(Scanfiles));
tptLength=1;
@@ -159,32 +137,30 @@ for ii=1:length(scLst)
end
ImHeigth=size(scd,1);
ImWidth=size(scd,2);
sc=scd(1:ImHeigth,1:ImWidth); %?Not used RefOnly
sc=scd(1:ImHeigth,1:ImWidth);
end
cd(w);
numFiles=size(Scanfiles,2);
% Initialize tifFilesLst for parfor loop
dir(fullfile(expDir, char(scLst(ii)), '*.bmp'));
dir(fullfile(scansDir, char(scLst(ii)), '*.bmp'));
numFiles=length(tifFileLst4MultiT);
tptLength=numFiles;
tifFileLstP4{ii}={tifFileLst4MultiT.name};
end
for jj=1:numScans %startScan:numScans
for jj=1:numScans % startScan:numScans
selScan=str2double(char(scLst(jj)));
selScanNumLst(jj)=selScan;
end
selScanNumLst2=selScanNumLst; %function passthrough, passback to par4gbl_Main 20_0205
selScanNumLst2=selScanNumLst; % function passthrough, passback to par4gbl_Main 20_0205
% PREALLOCATION
% Preallocation
scCount=[];
TmpexpScanIntens00=cell(1); %cell(1,scanMax);
TmpFexpScanSpots00=cell(1); %cell(1,scanMax);
TmpFexpScanBMtp00=cell(1); %cell(1,scanMax);
TmpanlZoneRefs00=cell(1); %cell(1,scanMax);
TmpexpScanIntens00=cell(1); % cell(1,scanMax);
TmpFexpScanSpots00=cell(1); % cell(1,scanMax);
TmpFexpScanBMtp00=cell(1); % cell(1,scanMax);
TmpanlZoneRefs00=cell(1); % cell(1,scanMax);
Tmpsbdg00=cell(1);
TmpexpScanIntens4=cell(1,numScans);
TmpFexpScanSpots4=cell(1,numScans);
@@ -206,11 +182,11 @@ CFscanIntens=zeros(16,24);
[p4L4,TmpexpScanIntens5,TmpFexpScanSpots5,TmpFexpScanBMtp5,TmpanlZoneRefs5,Tmpsbdg5]= ...
p4loop8c(parMat,tptLength,numScans,selScanNumLst,SWsingleSc,Fflg,PTmapPos,optCirMask,diaExt,doCircle,cirPixA,cirMask,width, ...
TmpexpScanIntens00,TmpFexpScanSpots00,TmpFexpScanBMtp00,TmpanlZoneRefs00,scCount,tifFileLstP4,pathname,ImParMat, ...
numRows,numCols,scLst,resDir,expDir, p4L00,TmpexpScanIntens4,TmpFexpScanSpots4,TmpFexpScanBMtp4,TmpanlZoneRefs4, ...
numRows,numCols,scLst,easyResultsDir,scansDir, p4L00,TmpexpScanIntens4,TmpFexpScanSpots4,TmpFexpScanBMtp4,TmpanlZoneRefs4, ...
Tmpsbdg00,Tmpsbdg4);
for scanCnt=1:numScans
selScan=p4L4{16,scanCnt}; %determine the actual scan in the scanCnt parfor distributed "id"
selScan=p4L4{16,scanCnt}; % determine the actual scan in the scanCnt parfor distributed "id"
scan(selScan).plate(1).tSeries=cell2mat(p4L4(1,scanCnt));
scan(selScan).plate(1).t0Series=cell2mat(p4L4(2,scanCnt));
scan(selScan).plate(1).printTm=cell2mat(p4L4(3,scanCnt));
@@ -222,7 +198,7 @@ for scanCnt=1:numScans
scan(selScan).plate(1).selTimes=p4L4(9,scanCnt);
scan(selScan).plate(1).filterTimes=p4L4(10,scanCnt);
scan(selScan).plate(1).normIntens=p4L4(11,scanCnt);
%scan(selScan).plate(1).CFparameters=p4L4(12,scanCnt); %Need to convert to a matrix form like Old versions
% scan(selScan).plate(1).CFparameters=p4L4(12,scanCnt); %Need to convert to a matrix form like Old versions
CFparm(1:384)=p4L4{12,scanCnt}(1:384);
scan(selScan).plate(1).CFparameters=CFparm;
scan(selScan).plate(1).CFdate=p4L4(13,scanCnt);
@@ -241,31 +217,31 @@ for scanCnt=1:numScans
end
end
%SAVE DATA in .mat files
save(ExpOutmat,'scan');
% save((fullfile(resDir,'PTmats','Nbdg')), 'sbdg'); %legacy location can probably get rid of in time
save((fullfile(resDir,'Fotos','Nbdg')), 'sbdg');
save((fullfile(resDir,'Fotos','Coordinates')),'FexpScanSpots') %Saves frames at each tPt
save((fullfile(resDir,'Fotos','BGatTpts')),'FexpScanBMtp')
save((fullfile(resDir,'Fotos','anlZones')),'anlZoneRefs')%Saves anl Positions at each tPt
% Save data in .mat files
save(matFile,'scan');
% save((fullfile(easyResultsDir,'PTmats','Nbdg')), 'sbdg'); %legacy location can probably get rid of in time
save((fullfile(easyResultsDir,'Fotos','Nbdg')), 'sbdg');
save((fullfile(easyResultsDir,'Fotos','Coordinates')),'FexpScanSpots') %Saves frames at each tPt
save((fullfile(easyResultsDir,'Fotos','BGatTpts')),'FexpScanBMtp')
save((fullfile(easyResultsDir,'Fotos','anlZones')),'anlZoneRefs')%Saves anl Positions at each tPt
%Print FitResults *******************************************************
% Print FitResults
fileExt='.txt';
filePrefix='FitResults_';
for scanCnt=1:numScans
selScan=p4L4{16,scanCnt}; %determine the actual scan in the scanCnt parfor distributed "id"
selScan=p4L4{16,scanCnt}; % determine the actual scan in the scanCnt parfor distributed "id"
fileSuffix=strcat('Scan', num2str(selScan),'_Plate', num2str(1));
fileNamePlate=[filePrefix fileSuffix fileExt];
fileName=fullfile(resDir,'PrintResults', fileNamePlate); %[outputDirectory fileNamePlate];
fileName=fullfile(easyResultsDir,'PrintResults', fileNamePlate); % [outputDirectory fileNamePlate];
%This,fprint for loop,is an very old legacy feature which slows processing. Could be
%removed but allows easy observation of how a run is progressing and can be
%used as a diagnostic tool.
% This,fprint for loop,is an very old legacy feature which slows processing. Could be
% removed but allows easy observation of how a run is progressing and can be
% used as a diagnostic tool.
outCprint=p4L4;
fid=fopen(fileName,'w');
fprintf(fid, 'Num.\tAUC\tMSR\tK\tr\tl\tR-squared\tK-lower\tK-upper\tr-lower\tr-upper\tl-upper\tl-lower\tArea\tLastInten\tSpineMaxRateTimePt\tLastFitTimePt\n');
for n=1:384 %startCount:numCultures
for n=1:384 % startCount:numCultures
fprintf(fid,'%d\t',n);
fprintf(fid, '%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\n',...
outCprint{14,scanCnt}(n,1),outCprint{14,scanCnt}(n,2),outCprint{14,scanCnt}(n,3),outCprint{14,scanCnt}(n,4),...