Ignore:
Timestamp:
Jul 4, 2024, 4:23:43 PM (3 months ago)
Author:
sommeria
Message:

update_xml simlified, bug on civ_series corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_imadoc.m

    r1127 r1152  
    22% take into account the old conventions
    33%-----------------------------------------------------------------------
    4 % function XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt)
     4% function XmlFileName=find_imadoc(RootPath,SubDir)
    55%
    66% OUTPUT:
     
    88%
    99% INPUT:
    10 % RootPath,SubDir,RootFile,FileExt, as given from the input file name by fileparts_uvmat
     10% RootPath: path to the folder containing the image series,
     11% SubDir: name of the folder containing the image series
    1112
    1213%=======================================================================
     
    2829%=======================================================================
    2930
    30 function XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt)
    31 SubDirBase=SubDir;
    32 XmlFileName=fullfile(RootPath,[SubDir '.xml']);
    33 if ~exist (XmlFileName,'file')
    34     dotchar=regexp(SubDir,'\.');
     31function XmlFileName=find_imadoc(RootPath,SubDir)
     32
     33dotchar=regexp(SubDir,'\.');%detect the dots in the folder name
     34if isempty(dotchar)
     35    XmlFileName=fullfile(RootPath,[SubDir '.xml']);
     36else %go upward to the root name, stop if an xml file already exists
    3537    for idot=1:numel(dotchar)
    36         XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1)-1) '.xml']);
     38        SubDir=SubDir(1:dotchar(end-idot+1)-1);
     39        XmlFileName=fullfile(RootPath,[SubDir '.xml']);
    3740        if exist(XmlFileName,'file')
    38             SubDirBase=fullfile(RootPath,SubDir(1:dotchar(end-idot+1)-1));
    3941            break
    40         end
    41     end   
    42 end
    43 if ~exist(XmlFileName,'file')
    44     XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.xml']; % old convention: xml inside the image folder, case of images or new civ files
    45     if ~exist(XmlFileName,'file')
    46         XmlFileName=[fullfile(RootPath,SubDirBase,RootFile) '.civ']; % very old convention: .civ file
    47         if ~exist(XmlFileName,'file') && strcmp(FileExt,'.nc')
    48             XmlFileName=[fullfile(RootPath,RootFile) '.xml'] ; % old convention: xml inside the image folder, old civ file opened
    49             if ~exist(XmlFileName,'file')
    50                 XmlFileName=[fullfile(RootPath,RootFile) '.civ']; % very old convention: .civ file
    51             end
    5242        end
    5343    end
    5444end
    55 if ~exist(XmlFileName,'file')% convention Pierre Augier for 3D images
    56     check3D=find(~isempty(regexp(SubDirBase,'^level')));
    57     if check3D
    58         [RootRootPath,RootDir]=fileparts(RootPath);
    59         XmlFileName=fullfile(RootRootPath,[RootDir '.xml']);
    60         dotchar=regexp(RootDir,'\.');
    61         for idot=1:numel(dotchar)
    62             XmlFileName=fullfile(RootRootPath,[RootDir(1:dotchar(end-idot+1)-1) '.xml']);
    63             if exist(XmlFileName,'file')
    64                 break
    65             end
    66         end
    67     end
    68 end
    69 if exist(XmlFileName,'file')~=2
     45if ~exist(XmlFileName,'file')
    7046    XmlFileName='';
    7147end
     48
     49
     50
Note: See TracChangeset for help on using the changeset viewer.