Commit 3bdcc0ad authored by Turnhout, M.C. van's avatar Turnhout, M.C. van
Browse files

copy parsepath from biaxlab (git.tue.nl/STEM/biaxlab)

parent 3de80ad8
function [datapath, filename] = DMA_parsepath(filepath)
% [datapath, filename] = bux_parsepath(filepath)
%
% Parses the string filepath for an experiment folder in order to split into
% the main (absolute) datapath and the experiment specific folder in that
% path (filename).
% The input string filepath can be an absolute or relative path.
%
% See also DMA_tracedroplet
% strip trailing (back)slashes
if regexp(filepath(end), '[/\\]'), filepath = filepath(1:end-1); end
% get datapath & filename from full filename
if ~isempty(regexp(filepath, '\', 'once'))
% sigh...
idx = regexp(filepath, '\');
if strcmp(filepath(idx(1) - 1), ':')
% this is an absolute path
datapath = filepath(1:idx(end)-1);
filename = filepath(idx(end)+1:end);
else
% this is a relative nested path
datapath = fullfile(pwd, filepath(1:idx(end)-1));
filename = filepath(idx(end)+1:end);
end
elseif ~isempty(regexp(filepath, '/', 'once'))
% this is a proper OS
idx = regexp(filepath, '/');
if idx(1) == 1
% this is an absolute path
datapath = filepath(1:idx(end)-1);
filename = filepath(idx(end)+1:end);
else
% this is a relative nested path
datapath = fullfile(pwd, filepath(1:idx(end)-1));
filename = filepath(idx(end)+1:end);
end
else
% relative path, not nested, easy
datapath = pwd;
filename = filepath;
end
% part of DMAlab: https://gitlab.tue.nl/STEM/DMAlab
end
......@@ -5,22 +5,16 @@ if nargin < 3,
param = DMA_labconfig;
end
if nargin < 2, drop = 0; end
if nargin > 0
% parse fully qualified image name for directory separators
if isempty(regexp(fqin, '/', 'once'))
% sigh ...
ddrop = regexp(fqin, '\');
else
ddrop = regexp(fqin, '/');
end
% get directory and image name
param.dir = fqin(1:ddrop(end));
imname = fqin(ddrop(end)+1:end);
end
if nargin == 0
% pick file interactively
[imname, param.dir] = uigetfile('*.tif', 'Pick your fight!');
fqin = fullfile(param.dir, imname);
else
% get absolute directory and image name
[param.dir, imname] = DMA_parsepath(fqin);
end
% fully qualified image name
fqin = fullfile(param.dir, imname);
if nargin < 3
% pick up local settings
if exist(fullfile(param.dir, 'DMAlab_param.m'), 'file')
......
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