source: trunk/src/index2filename.m

Last change on this file was 1180, checked in by sommeria, 3 weeks ago

various bugs repaired,Relabeling frames installed for multitif

File size: 2.8 KB
Line 
1% get the file name and frame index from a set of multimage files (e.g. from PCO camera)
2%------------------------------------------------------------------------
3% [RootFile,FileIndexString,FrameIndex]=index2filename(FileSeries,i1,j1,NbField_j)
4%
5% OUTPUT:
6% RootFile, FileIndexString: name of the multimage file = [RootFile FileIndexString FileExt]
7% FrameIndex: index in the multimage file     
8%
9% INPUT:
10% FileSeries: structure read from the xml file, defining the the multifile organisation of images 
11% i1: global frame index i, or  single concatenated index vector (then no further input j1 and NbField_j
12% j1: j index
13% NbField_j: nbre of j indices in the index matrix
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 [FileName,FrameIndex]=index2filename(FileSeries,i1,j1,NbField_j)
34FileName='';
35% FileIndexString='';
36FrameIndex=1;
37if isfield(FileSeries,'FileName')
38    if exist('j1','var')&&~isnan(NbField_j)
39        if isempty(j1)
40            j1=1;
41        end
42        i_vector=(i1-1)*NbField_j+j1;%frames labeld with two indices i and j
43    else
44        i_vector=i1;% frames labelled with a single concatenated index vector
45    end
46    if ischar(FileSeries.FileName)
47        FileSeries.FileName={FileSeries.FileName};
48    end
49    [~,~,RootFile,i1,~,~,~,FileExt,NomType]=fileparts_uvmat(FileSeries.FileName{end});
50    FileIndex=floor((i_vector-1)/FileSeries.NbFramePerFile)+1;
51    if FileIndex>numel(FileSeries.FileName)
52        FileIndex=FileIndex-numel(FileSeries.FileName)+i1;
53        FileName=fullfile_uvmat('','',RootFile,FileExt,NomType,FileIndex);
54    else
55        FileName=FileSeries.FileName{FileIndex};
56    end
57
58    % switch FileSeries.Convention
59    %     case 'PCO'
60    %         RootFile=FileSeries.RootName;
61    %         FileIndex=floor(i_vector/FileSeries.NbFramePerFile);
62    %         if FileIndex>0
63    %             RootFile=[RootFile '@'];
64    %            FileIndexString=num2str(FileIndex,'%04d');
65    %         end
66    FrameIndex=mod(i_vector-1,FileSeries.NbFramePerFile)+1;
67end
68
69
70
Note: See TracBrowser for help on using the repository browser.