From 6d58c6e3e6f8b0d684696daea094f5f3b72f5f58 Mon Sep 17 00:00:00 2001 From: Paul Wiggins Date: Wed, 5 Sep 2018 10:05:48 -0700 Subject: [PATCH] Modified Internal/isRightNameFormat.m to fix zero padding if it is screwed up. --- Internal/isRightNameFormat.m | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Internal/isRightNameFormat.m b/Internal/isRightNameFormat.m index 4b866fa..9d25275 100644 --- a/Internal/isRightNameFormat.m +++ b/Internal/isRightNameFormat.m @@ -43,5 +43,36 @@ rightNames = false; end + +%% fix the padding if required +contents = dir([dirname,filesep,'*.tif*']); + +num_im = numel(contents); +pad = []; + +for i = 1:num_im; + nameInfo = ReadFileName( contents(i).name ); + pad = [pad, nameInfo.npos(1,4)]; +end + +if 1 ~= numel( unique( pad ) ) + + maxpad = max( pad ); + + ind = find( pad < maxpad ); + + for i = ind + nameInfo = ReadFileName( contents(i).name ); + + nameInfo.npos(1,4) = maxpad; + + movefile( [dirname,filesep,contents(i).name], ... + [dirname,filesep,MakeFileName(nameInfo)] ); + end +end + + + + end