DMPexcel2mat.m refactor
This commit is contained in:
@@ -6,7 +6,7 @@ global drugMediaFile
|
||||
global matDir
|
||||
|
||||
% If we already have mpdmFile, don't recreate
|
||||
if exist(mpdmFile, 'file') && ~isempty(mpdmFile)
|
||||
if (exist(mpdmFile, 'file') && ~isempty(mpdmFile))
|
||||
disp(strcat('The Drug Media/MasterPlate Annotation File: ', mpdmFile, ' exists, skipping DMPexcel2mat.m'));
|
||||
return
|
||||
end
|
||||
@@ -16,9 +16,11 @@ if ~exist(masterPlateFile, 'file') || isempty(masterPlateFile)
|
||||
if exist(fullfile(matDir), 'dir')
|
||||
% Try to find the masterPlateFile automatically (newest created first)
|
||||
try
|
||||
files=dir(matDir)
|
||||
files=dir(matDir);
|
||||
mpFiles={files(strncmp(files.name, 'MasterPlate_', 12)).name};
|
||||
isempty(mpFiles) && throw(MException('MATLAB:dir', 'No MasterPlate_ files in the default MasterPlate directory'));
|
||||
if isempty(mpFiles)
|
||||
throw(MException('MATLAB:dir', 'No MasterPlate_ files in the default MasterPlate directory'));
|
||||
end
|
||||
% this sorts by date (newest first)
|
||||
[~, sortedIndices]=sort(datenum({files(strncmp(mpFiles.name, 'MasterPlate_', 12)).date}), 'descend');
|
||||
sortedFiles=mpFiles(sortedIndices);
|
||||
@@ -37,7 +39,9 @@ if ~exist(masterPlateFile, 'file') || isempty(masterPlateFile)
|
||||
dirToScan=uigetdir();
|
||||
files=dir(dirToScan);
|
||||
mpFiles={files(strncmp(files.name, 'MasterPlate_', 12)).name};
|
||||
isempty(mpFiles) && throw(MException('MATLAB:dir', 'No MasterPlate_ files in directory'))
|
||||
if isempty(mpFiles)
|
||||
throw(MException('MATLAB:dir', 'No MasterPlate_ files in directory'))
|
||||
end
|
||||
% this sorts by date (newest first)
|
||||
[~, sortedIndices]=sort(datenum({files(strncmp(mpFiles.name, 'MasterPlate_', 12)).date}), 'descend');
|
||||
sortedFiles=mpFiles{sortedIndices};
|
||||
@@ -60,7 +64,9 @@ if ~exist(masterPlateFile, 'file') || isempty(masterPlateFile)
|
||||
dirToScan=uigetdir();
|
||||
files=dir(dirToScan);
|
||||
mpFiles={files(strncmp(files.name, 'MasterPlate_', 12)).name};
|
||||
isempty(mpFiles) && throw (MException('MATLAB:dir', 'No MasterPlate_ files in directory'))
|
||||
if isempty(mpFiles)
|
||||
throw (MException('MATLAB:dir', 'No MasterPlate_ files in directory'));
|
||||
end
|
||||
% this sorts by date (newest first)
|
||||
[~, sortedIndices]=sort(datenum({files(strncmp(mpFiles.name, 'MasterPlate_', 12)).date}), 'descend');
|
||||
sortedFiles=mpFiles{sortedIndices};
|
||||
@@ -182,7 +188,9 @@ if ~exist(drugMediaFile, 'file') || isempty(drugMediaFile)
|
||||
% Try to find the DrugMedia file automatically (newest created first)
|
||||
files=dir(matDir)
|
||||
dmFiles={files(strncmp(files.name, 'DrugMedia_', 10)).name};
|
||||
isempty(dmFiles) && throw (MException('MATLAB:dir', 'No DrugMedia_ files in directory'))
|
||||
if isempty(dmFiles)
|
||||
throw (MException('MATLAB:dir', 'No DrugMedia_ files in directory'));
|
||||
end
|
||||
% this sorts by date (newest first)
|
||||
[~, sortedIndices]=sort(datenum({files(strncmp(dmFiles.name, 'DrugMedia_', 10)).date}), 'descend');
|
||||
sortedFiles=dmFiles{sortedIndices};
|
||||
@@ -204,7 +212,9 @@ if ~exist(drugMediaFile, 'file') || isempty(drugMediaFile)
|
||||
dirToScan=uigetdir();
|
||||
files=dir(dirToScan)
|
||||
dmFiles={files(strncmp(files.name, 'DrugMedia_', 10)).name};
|
||||
isempty(dmFiles) && throw (MException('MATLAB:dir', 'No DrugMedia_ files in directory'))
|
||||
if isempty(dmFiles)
|
||||
throw (MException('MATLAB:dir', 'No DrugMedia_ files in directory'));
|
||||
end
|
||||
% this sorts by date (newest first)
|
||||
[~, sortedIndices]=sort(datenum({files(strncmp(dmFiles.name, 'DrugMedia_', 10)).date}), 'descend');
|
||||
sortedFiles=dmFiles{sortedIndices};
|
||||
|
||||
Reference in New Issue
Block a user