source: trunk/src/find_imadoc.m @ 1193

Last change on this file since 1193 was 1191, checked in by sommeria, 2 weeks ago

bugs repaired

File size: 2.1 KB
Line 
1% 'find_imadoc': find the ImaDoc xml file associated with a given input file
2% take into account the old conventions
3%-----------------------------------------------------------------------
4% function {[XmlFileName,Rank]=find_imadoc(RootPath,SubDir)
5%
6% OUTPUT:
7% XmlFileName: name of the xml file, if the SubDir has suffixes marked with
8%        '.', take the first one going backward, ='' isf no xml file is found
9% Rank: = nbre of suffixes in SubDir
10%
11% INPUT:
12% RootPath: path to the folder containing the image series,
13% SubDir: name of the folder containing the image series
14
15%=======================================================================
16% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
17%   http://www.legi.grenoble-inp.fr
18%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
19%
20%     This file is part of the toolbox UVMAT.
21%
22%     UVMAT is free software; you can redistribute it and/or modify
23%     it under the terms of the GNU General Public License as published
24%     by the Free Software Foundation; either version 2 of the license,
25%     or (at your option) any later version.
26%
27%     UVMAT is distributed in the hope that it will be useful,
28%     but WITHOUT ANY WARRANTY; without even the implied warranty of
29%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30%     GNU General Public License (see LICENSE.txt) for more details.
31%=======================================================================
32
33function [XmlFileName,Rank]=find_imadoc(RootPath,SubDir)
34XmlFileName=fullfile(RootPath,[SubDir '.xml']);
35Rank=0;
36if ~exist(XmlFileName,'file')
37    dotchar=regexp(SubDir,'\.');%detect the dots in the folder name
38    if ~isempty(dotchar)
39        for idot=1:numel(dotchar)
40            SubDir=SubDir(1:dotchar(end-idot+1)-1);
41            XmlFileName=fullfile(RootPath,[SubDir '.xml']);
42            if exist(XmlFileName,'file')
43                Rank=idot;
44                break % take the root name after removing all the dot suffixes
45            end
46        end
47    end
48    if ~exist(XmlFileName,'file')
49        XmlFileName='';
50    end
51end
52
53
54
55
Note: See TracBrowser for help on using the repository browser.