Changeset 1181 for trunk/src


Ignore:
Timestamp:
May 21, 2025, 6:14:05 PM (11 days ago)
Author:
sommeria
Message:

image rescale included in civ_series input

Location:
trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r1180 r1181  
    192192                % update the detected index series
    193193                if ~isnan(ref_i)&&~isnan(ref_j)
    194                     if ref_i*ref_j>100000
    195                         disp('warning: inapropriate file name indexing: too large indices for scanning')
     194                    if ref_i*ref_j>1000000
     195                        disp('warning: inapropriate file name indexing: too large values for index scanning')
    196196                        ref_i_list(ifile)=i1_input;
    197197                        if isempty(j1_input)
     
    244244            NomType=regexprep(NomType,['^' NomTypePref],'');
    245245            %% update the file type if the input file does not exist (pb of 0001)
    246             if isempty(FileInfo.FileType)
     246            if isempty(FileInfo.FileName)
    247247                [FileInfo,MovieObject]=get_file_info(fullfile(FilePath,ListFiles{ifile_min}));
    248248            end
  • trunk/src/get_file_info.m

    r1180 r1181  
    1 %'get_file_info': determine info about a file (image, multimage, civdata,...) .
     1%'gext_file_info': determine info about a file (image, multimage, civdata,...) .
    22%------------------------------------------------------------------------
    33% [FileInfo,VideoObject]=get_file_info(fileinput)
     
    55% OUTPUT:
    66% FileInfo: structure containing info on the file (case of images or video), in particular
    7 %      .FileType: type of file, needed as input of read_field.m
    8 %               ='figure': Matlab figure
     7%     .FileName: confirms the file name, ='' if the file is not detected 
     8%     .FileType: type of file, needed as input of read_field.m
     9%               ='': unknown format
     10%               ='bin': binary file without specific organisation
     11%               ='dat': text file for data
     12%               ='figure': Matlab figure file, ext .fig
    913%               ='mat': Matlab data file
     14%               ='netcdf': generic netcdf file
    1015%               ='xml': xml file
    1116%               ='xls': Excel file
    12 %               ='dat': text file for data,
     17%               ='civdata': netcdf files provided by civ_series
     18%               ='pivdata_fluidimage': PIV data from software 'fluidimage'
     19%   different image and movie formats:
    1320%               ='image': image format recognised by Matlab
    1421%               ='multimage': image format recognised by Matlab with  multiple frames
     
    1623%               ='mmreader': video from old versions of Matlab (<2009)
    1724%               ='rdvision': images in binary format from company rdvision
    18 %               ='image_DaVis': images from softwar DaVis (company LaVision)
     25%               ='image_DaVis': images from softwar DaVis (company LaVision), requires specific conditions of Matlab version and computer system
    1926%               ='cine_phantom': images from fast camera Phantom
    20 %               ='bin': binary file without specific organisation
    21 %               ='netcdf': netcdf file
    22 %               ='civdata': netcdf files provided by civ_series
    23 %               ='civx': netcdf files provided by the obsolete program civx (in fortran)
    24 %               ='pivdata_fluidimage': PIV data from software 'fluidimage'
     27%               ='telopsIR': Infrared images from  company Telops
    2528%      .FieldType='image' for all kinds of images and movies, =FileType  else
    26 %      .FileIndexing='on'/'off', for data files (when series of indexed files are  expected)
     29%      .FileIndexing='on'/'off', = 'on' for series of indexed files or frames to scan
    2730%      .Height: image height in pixels
    2831%      .Width:  image width in pixels
     
    3033%      .ColorType: 'greyscale' or 'color'
    3134%      .NumberOfFrames: defined for images or movies
    32 %      .FrameRate: nbre of frames per second, =[] for images
     35%      .FrameRate: nbre of frames per second, =[] if not documented
    3336% VideoObject: in case of video
    3437%
     
    5760
    5861VideoObject=[];
    59 FileInfo.FileType='';% input file does not exist
     62FileInfo.FileName='';% file doe not exist, defautlt
     63FileInfo.FileType='';% input file type not detected
    6064FileInfo.FieldType=''; %default output
    6165if ~ischar(fileinput)
    6266    return
    6367end
    64 % check the existence (not possible for OpenDAP data)
     68
     69%% check the existence (not possible for OpenDAP data)
    6570if ~isempty(regexp(fileinput,'^http://','once'))|| exist(fileinput,'file')
    6671    FileInfo.FileName=fileinput;
    67     FileInfo.FileType='txt'; %default
     72%     FileInfo.FileType='txt'; %default
    6873else
    6974    return %input file does not exist.
     
    7176[~,~,FileExt]=fileparts(fileinput);%get the file extension FileExt
    7277
     78%% look according to file extension
    7379switch FileExt
    74     case '.fig'
     80    case '.fig'% Matlab figure assumed
    7581        FileInfo.FileType='figure';
    76     case '.mat'
     82    case '.mat'% Matlab data format
    7783        FileInfo.FileType='mat';
     84    case {'.txt','.log','.stdout','.stderr','.sh'}
     85        FileInfo.FileType='txt';
    7886    case {'.xml','.xls','.dat','.bin'}
    7987        FileInfo.FileType=regexprep(FileExt,'^.','');% eliminate the dot of the extension;
    80     case {'.seq','.sqb'}
     88    case {'.seq','.sqb'}% data from rdvision
    8189        [~,FileInfo]=read_rdvision(fileinput,[]);
    82     case '.im7'
     90    case '.im7'% data from LaVision (DaVis), requires specific conditions of Matlab version and computer system
    8391        try
    8492            Input=readimx(fileinput);
     
    98106            end
    99107        catch ME
    100             msgbox_uvmat('ERROR',{ME.message;'reading image from DaVis is possible only with Matlab version 2013 or earlier'})
     108            msgbox_uvmat('ERROR',{ME.message;'reading image from DaVis is not possible with this Matlab version and system'})
    101109            return
    102110        end
    103     case '.h5'
     111    case '.h5'% format hdf5, used for specific case of PIV data from 'Fluidimage'
    104112        hinfo=h5info(fileinput);
    105113        FileInfo.CivStage=0;
     
    127135        FileInfo.BitDepth=BitmapInfoHeader.biBitCount;
    128136        FileInfo.TimeName='video';
    129     case '.hcc'
     137    case '.hcc' % infrared camera Telops
    130138        installToolboxIRCAM
    131139        [~,InfoArray]=readIRCam(fileinput,'HeadersOnly',true);
     
    273281end
    274282
    275 if ismember (FileInfo.FileType,{'mat','image','image_DaVis','multimage','mmreader','cine_phantom','video','netcdf','civdata'})
    276     FileInfo.FileIndexing='on'; % allow to detect file index for scanning series
    277 else
    278     FileInfo.FileIndexing='off';
    279 end
    280283FileInfo.FieldType=FileInfo.FileType;%default
    281284switch FileInfo.FileType
    282285    case {'image','multimage','video','mmreader','rdvision','image_DaVis','cine_phantom','telopsIR'}
    283286        FileInfo.FieldType='image';
    284     case {'civx','civdata','pivdata_fluidimage'}
     287    case {'civdata','pivdata_fluidimage'}
    285288        FileInfo.FieldType='civdata';
    286289end
    287290
     291if strcmp(FileInfo.FieldType,'image') || ismember (FileInfo.FileType,{'mat','netcdf','civdata'})
     292    FileInfo.FileIndexing='on'; % allow to detect file index for scanning series
     293else
     294    FileInfo.FileIndexing='off';
     295end
     296
     297
  • trunk/src/nc2struct.m

    r1162 r1181  
    2727%  additional arguments:
    2828%       -no additional arguments: all the variables of the NetCDF file are read.
    29 %       - empty argument []: the field structure with the names of variables is read, without their values
     29%       - empty argument []: the output field structure is limited to the names of variables, without their values
    3030%       -a cell array, ListVarName, made of  char strings {'VarName1', 'VarName2',...} )
    3131%         if ListVarName=[] or {}, no variable value is read (only global attributes and list of variables and dimensions)
     
    3636%       - the string 'TimeVarName', a string (the name of the variable considered as time), an integer or vector with integer values
    3737%            representing time indices to select for each variable, the cell of other input variable names.
    38 %       - the string 'TimeDimName', a string (the name of the dimension considered as time), an integer or vector with integer values
    39 %            representing time indices to select for each variable, the cell of other input variable names.
     38
    4039
    4140%=======================================================================
     
    291290                end
    292291            end
     292%            tstart = tic;
     293          % disp(VarName)
    293294            Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1,ind_vec,ind_size); %read the variable data
     295%              telapsed = toc(tstart)
    294296            Data.(VarName)=squeeze(Data.(VarName));%remove singeton dimension
     297
    295298        else
    296299            Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data
    297300        end
    298         if xtype(var_index(ivar))==5
     301        if xtype(var_index(ivar))==5% indicate single precision variable
    299302            Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision
    300303        end
  • trunk/src/script_readnc.m

    r1131 r1181  
    1 DataFolder='.fsnet/project/coriolis/2024/24PLUME/VectorsEyemotion';
    2 fileinput={'Tore_a8b40_T22s_N047_A1cm.png.civ.mproj.tfilter_1'}
     1DataFolder='.fsnet/project/coriolis/2024/24PLUME/1_DATA/EXP27/JAI';
     2fileinput_1='/im.sback.civ2.mproj.tfilter/img_1-19991.nc';
     3fileinput_2='/im.sback.civ2.mproj.tfilter/img_1-19991.nc';
    34fileinput=uigetfile_uvmat('pick an input file',DataFolder);
    45Data=nc2struct(fileinput);
  • trunk/src/series/check_data_files.m

    r1164 r1181  
    176176            end
    177177        else
    178             datnum=datnum(datnum);%keep the non zero values corresponding to existing files
    179             filefound=filefound(datnum);
     178            datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     179            filefound=filefound(datnum~=0);
    180180            [first,ind]=min(datnum);
    181181            [last,indlast]=max(datnum);
  • trunk/src/series/civ_input.m

    r1180 r1181  
    9191if isfield(SeriesData,'FileInfo')
    9292    FileType=SeriesData.FileInfo{1}.FileType;% info on the first input file series
    93     FieldType=SeriesData.FileInfo{1}.FieldType;% info on the first input file series
     93    %FieldType=SeriesData.FileInfo{1}.FieldType;% info on the first input file series
    9494else
    9595    set(hhseries.REFRESH,'BackgroundColor',[1 0 1])% indicate that the file input in series needs to be refreshed
     
    207207    set(handles.TimeSource,'String',Param.IndexRange.TimeSource);
    208208else
     209    msgbox_uvmat('WARNING','timing not defined (check xml file), default values used')
    209210    set(handles.TimeSource,'String',''); %xml file not used for timing
    210211    TimeUnit='frame';
     
    377378%% list the possible index pairs, depending on the option set in ListPairMode
    378379ListPairMode_Callback([], [], handles)
    379 
     380if isfield(Param,'ActionInput')&& isfield(Param.ActionInput,'PairIndices')
     381    if isfield(Param.ActionInput.PairIndices,'ListPairCiv1')
     382        PairChoiceCiv1=find(strcmp(Param.ActionInput.PairIndices.ListPairCiv1,get(handles.ListPairCiv1,'String')));
     383        if ~isempty(PairChoiceCiv1)
     384            set(handles.ListPairCiv1,'Value',PairChoiceCiv1)
     385        end
     386    end
     387    if isfield(Param.ActionInput.PairIndices,'ListPairCiv2')
     388        PairChoiceCiv2=find(strcmp(Param.ActionInput.PairIndices.ListPairCiv2,get(handles.ListPairCiv2,'String')));
     389        if ~isempty(PairChoiceCiv2)
     390            set(handles.ListPairCiv2,'Value',PairChoiceCiv2)
     391        end
     392    end
     393end
     394 
    380395%% set the GUI to modal: wait for OK to close
    381396set(handles.civ_input,'WindowStyle','modal')% Make the GUI modal
     
    810825%reproduce by default the chosen pair in the checkciv2 menu
    811826set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))%civ2 selection the same as civ1 by default
    812 ListPairCiv2_Callback(hObject, eventdata, handles)
    813 
    814 %------------------------------------------------------------------------
    815 % --- Executes on selection change in ListPairCiv2.
    816 function ListPairCiv2_Callback(hObject, eventdata, handles)
    817 %------------------------------------------------------------------------
     827%ListPairCiv2_Callback(hObject, eventdata, handles)
     828
     829% %------------------------------------------------------------------------
     830% % --- Executes on selection change in ListPairCiv2.
     831% function ListPairCiv2_Callback(hObject, eventdata, handles)
     832% %------------------------------------------------------------------------
    818833
    819834%------------------------------------------------------------------------
     
    15271542    set(obj,'Visible','off')
    15281543end
     1544set(handles.ConfigSource,'String','NEW')
     1545set(handles.OK,'BackgroundColor',[1 0 1])
     1546
     1547
     1548%------------------------------------------------------------------------
     1549% --- Executes on button press in CheckRescale.
     1550function CheckRescale_Callback(hObject, eventdata, handles)
     1551%------------------------------------------------------------------------
     1552huipanel=get(hObject,'parent');
     1553obj(1)=findobj(huipanel,'Tag','num_Maxtanh');
     1554obj(2)=findobj(huipanel,'Tag','title_Maxtanh');
     1555if get(hObject,'Value')% if chck box has been selected
     1556    set(obj,'Visible','on')
     1557else
     1558    set(obj,'Visible','off')
     1559end
     1560set(handles.ConfigSource,'String','NEW')
     1561set(handles.OK,'BackgroundColor',[1 0 1])
     1562
     1563%------------------------------------------------------------------------
     1564% --- synchronise the image threshold for civ1 and civ2
     1565function num_MaxIma_Callback(hObject, eventdata, handles)
     1566MaxIma_string=get(hObject,'String');
     1567set(handles.num_MaxIma,'String',MaxIma_string);
     1568set(handles.num_MaxIma,'Visible','on');
     1569set(handles.title_Threshold,'Visible','on');
     1570set(handles.CheckThreshold,'Value',true);
     1571
     1572set(handles.ConfigSource,'String','NEW')
     1573set(handles.OK,'BackgroundColor',[1 0 1])
     1574
     1575%------------------------------------------------------------------------
     1576% --- synchronise the image rescaling threshold for civ1 and civ2
     1577function num_Maxtanh_Callback(hObject, eventdata, handles)
     1578Maxtanh_string=get(hObject,'String');
     1579set(handles.num_Maxtanh,'String',Maxtanh_string);
     1580set(handles.num_Maxtanh,'Visible','on');
     1581set(handles.title_Maxtanh,'Visible','on');
     1582set(handles.CheckRescale,'Value',true);
     1583
    15291584set(handles.ConfigSource,'String','NEW')
    15301585set(handles.OK,'BackgroundColor',[1 0 1])
     
    19522007
    19532008
    1954 function edit108_Callback(hObject, eventdata, handles)
    1955 % hObject    handle to edit108 (see GCBO)
    1956 % eventdata  reserved - to be defined in a future version of MATLAB
    1957 % handles    structure with handles and user data (see GUIDATA)
    1958 
    1959 % Hints: get(hObject,'String') returns contents of edit108 as text
    1960 %        str2double(get(hObject,'String')) returns contents of edit108 as a double
    1961 
    1962 
    19632009% --- Executes on button press in CheckBackground.
    19642010function CheckBackground_Callback(hObject, eventdata, handles)
  • trunk/src/series/civ_series.m

    r1180 r1181  
    6969    Data.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    7070    Data.FieldName='on';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    71     Data.FieldTransform = 'on';%can use a transform function
     71    Data.FieldTransform = 'off';%can use a transform function
    7272    Data.ProjObject='off';%can use projection object(option 'off'/'on',
    7373    Data.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
     
    258258CheckRelabel=isfield(Param,'FileSeries' );%=true for index relabeling (PCO)
    259259
    260 %% introduce input image transform
    261 transform_fct=[];%default, no transform
    262 if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
    263         currentdir=pwd;
    264     cd(Param.FieldTransform.TransformPath)
    265     transform_fct=str2func(Param.FieldTransform.TransformName);
    266     cd (currentdir)
    267 end
     260% %% introduce input image transform
     261% transform_fct=[];%default, no transform
     262% if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
     263%         currentdir=pwd;
     264%     cd(Param.FieldTransform.TransformPath)
     265%     transform_fct=str2func(Param.FieldTransform.TransformName);
     266%     cd (currentdir)
     267% end
    268268
    269269%%%%% MAIN LOOP %%%%%%
     
    445445        end
    446446
    447 
    448         %% user defined image transform
    449         if ~isempty(transform_fct)
    450                par_civ1 =transform_fct(par_civ1,Param);
     447 % case of image luminosity rescaling
     448      if par_civ1.CheckRescale &&~isempty(par_civ1.Maxtanh)
     449               par_civ1.ImageA =par_civ1.Maxtanh*tanh(double(par_civ1.ImageA)/par_civ1.Maxtanh);
     450               par_civ1.ImageB=par_civ1.Maxtanh*tanh(double(par_civ1.ImageB)/par_civ1.Maxtanh);
    451451        end
    452452       
     
    672672        end
    673673       
    674                 %% user defined image transform
    675         if ~isempty(transform_fct)
    676                par_civ2 =transform_fct(par_civ2,Param);
    677         end
    678        
     674%                 %% user defined image transform
     675%         if ~isempty(transform_fct)
     676%                par_civ2 =transform_fct(par_civ2,Param);
     677%         end
     678         %% case of image luminosity rescaling
     679      if par_civ2.CheckRescale &&~isempty(par_civ2.Maxtanh)
     680               par_civ2.ImageA =par_civ2.Maxtanh*tanh(double(par_civ2.ImageA)/par_civ2.Maxtanh);
     681               par_civ2.ImageB=par_civ2.Maxtanh*tanh(double(par_civ2.ImageB)/par_civ2.Maxtanh);
     682        end
    679683       
    680684        % get the guess from patch1 or patch2 (case 'CheckCiv3')
  • trunk/src/series/filter_time_singlefile.m

    r1158 r1181  
    1 %'filter_time_single': apply a a sliding filter in a time series, put the time series in a single netcdf file (problematic...)
    2 %------------------------------------------------------------------------
     1%'filter_time_single': apply a a sliding filter to a time series and concatene the result in a single netcdf file
    32% function ParamOut=filter_time(Param)
    43%
     
    149148
    150149%%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    151 disp('loop for filtering started')
    152 tstart = tic;
    153  telapsed(zeros,1,NbField)       
     150disp('loop for filtering started') 
     151 ncid=[];
    154152for index=1:NbField
    155153    index
    156    
    157     Field= read_field(filecell{1,index},'netcdf',Param.InputFields);
    158    
     154   
     155    [Field,~,errormsg]= read_field(filecell{1,index},'netcdf',Param.InputFields);
     156    if ~isempty(errormsg)
     157        disp(errormsg)
     158        if ~isempty(ncid)
     159        netcdf.close(ncid)
     160        end
     161        return
     162    end
    159163    %%%%%%%%%%% MAIN RUNNING OPERATIONS  %%%%%%%%%%%%
    160164    if index==1 %first field, initialisation output data
    161165        DataOut.ListGlobalAttribute= {'Conventions'};
    162166        DataOut.Conventions='uvmat';
    163         DataOut.ListVarName={'Time','coord_y','coord_x','Ufilter','Vfilter'};
    164         DataOut.VarDimName={'Time','coord_y','coord_x',{'Time','coord_y','coord_x'},{'Time','coord_y','coord_x'}};
    165167        npy=numel(Field.coord_y);
    166168        npx=numel(Field.coord_x);
    167169        ListDimName={'Time','coord_y','coord_x'};
    168170        DimValue=[NbField npy npx];
    169         VarDimIndex={1,2,3,[1 2 3],[1 2 3]};
     171        ListFields=Param.InputFields.FieldName;
     172        DataOut.ListVarName=[{'Time','coord_y','coord_x'} ListFields'];
     173        %DataOut.VarDimName={'Time','coord_y','coord_x',{'Time','coord_y','coord_x'},{'Time','coord_y','coord_x'}};
     174        DataOut.VarDimName={'Time','coord_y','coord_x'};
     175        VarDimIndex={1,2,3};
     176        for ifield=1:numel(ListFields)
     177            DataOut.VarDimName{ifield+3}={'coord_y','coord_x','Time'};
     178            Field_varid(ifield)=ifield+2;
     179            VarDimIndex{ifield+3}=[2 3 1];
     180        end
     181
     182%         VarDimIndex={1,2,3,[1 2 3],[1 2 3]};
     183
    170184        DataOut.coord_x=Field.coord_x;
    171185        DataOut.coord_y=Field.coord_y;
    172186        DataOut.Time=0;
    173         DataOut.Ufilter=0;
    174         DataOut.Vfilter=0;
     187        for ifield=1:numel(ListFields)
     188            DataOut.(ListFields{ifield})=0;
     189        end
    175190        [errormsg,ncid]=struct2nc(ncfile_out,DataOut,'keep_open',ListDimName,DimValue,VarDimIndex);
    176191        netcdf.putVar(ncid,0,0,1,0)
    177192        netcdf.putVar(ncid,1,0,npy,Field.coord_y)
    178193        netcdf.putVar(ncid,2,0,npx,Field.coord_x)
    179         Uvarid=3;
    180         Vvarid=4;
     194%         Uvarid=3;
     195%         Vvarid=4;
    181196        TimeBlock=zeros(Param.ActionInput.WindowLength,1);
    182         Ublock=zeros(Param.ActionInput.WindowLength,npy,npx);
    183         Vblock=zeros(Param.ActionInput.WindowLength,npy,npx);
    184     end
     197        Fieldblock=zeros(numel(ListFields),Param.ActionInput.WindowLength,npy,npx);
     198        %Vblock=zeros(Param.ActionInput.WindowLength,npy,npx);
     199    end
     200
    185201    TimeBlock=circshift(TimeBlock,[-1 0 ]);
    186     Ublock=circshift(Ublock,[-1 0 0]); %shift U by ishift along the first index
    187     Vblock=circshift(Vblock,[-1 0 0]); %shift U by ishift along the first index
    188202    TimeBlock(end)=Field.Time;
    189     Ublock(end,:,:)=Field.U;
    190     Vblock(end,:,:)=Field.V;
    191203    sumindex=min(index,Param.ActionInput.WindowLength)-1;
    192204    Timefilter=mean(TimeBlock(end-sumindex:end,:,:));%mid time
    193     Ufilter=squeeze(mean(Ublock(end-sumindex:end,:,:),1,'omitnan'));
    194     Vfilter=squeeze(mean(Vblock(end-sumindex:end,:,:),1,'omitnan'));
     205    Fieldblock=circshift(Fieldblock,[0 -1 0 0]); %shift U by ishift along the first index
     206   % Vblock=circshift(Vblock,[-1 0 0]); %shift U by ishift along the first index
     207    for ifield=1:numel(ListFields)
     208    Fieldblock(ifield,end,:,:)=Field.(ListFields{ifield});
     209    end
     210    %Vblock(end,:,:)=Field.V;
     211    Fieldfilter=squeeze(mean(Fieldblock(:,end-sumindex:end,:,:),2,'omitnan'));
     212%     Ufilter=squeeze(mean(Ublock(end-sumindex:end,:,:),1,'omitnan'));
     213%     Vfilter=squeeze(mean(Vblock(end-sumindex:end,:,:),1,'omitnan'));
     214%     Uerror=Ufilter-Ublock(end-floor(sumindex/2),:,:);
     215%     Verror=Ufilter-Vblock(end-floor(sumindex/2),:,:);
    195216    %updating output the netcdf file
     217     tstart = tic;
    196218    netcdf.putVar(ncid,0,(index-1),Timefilter)
    197     netcdf.putVar(ncid,Uvarid,[(index-1) 0 0],[1 npy npx],Ufilter)
    198     netcdf.putVar(ncid,Vvarid,[(index-1) 0 0],[1 npy npx],Vfilter)
    199 
    200  telapsed(index) = toc(tstart);
     219    for ifield=1:numel(ListFields)
     220        netcdf.putVar(ncid,Field_varid(ifield),[ 0 0 (index-1)],[npy npx 1],squeeze(Fieldfilter(ifield,:,:)))
     221    end
     222%     netcdf.putVar(ncid,Uvarid,[ 0 0 (index-1)],[npy npx 1],Ufilter)
     223%      netcdf.putVar(ncid,Vvarid,[0 0 (index-1)],[npy npx 1],Vfilter)
     224
     225 telapsed = toc(tstart)% time for writting the field
    201226    % writing the result file as netcdf file
    202227    %     i1=i1_series{1}(index)-ceil(NpTime/2);
     
    212237figure
    213238plot(telapsed)
     239ylabel('time lapsed computation')
    214240'END'
  • trunk/src/transform_field/FFT2_detrend.m

    r1168 r1181  
    8585        spec2 = spec2(Iy,Ix);
    8686        spec2 = spec2(ss,:);
    87         DataOut.(VarName) = log10(spec2);% take the log10 of spectrum
    88         %DataOut.(VarName) = spec2;
     87        %DataOut.(VarName) = log10(spec2);% take the log10 of spectrum
     88        DataOut.(VarName) = spec2;
    8989%         spec_sum=sum(sum(spec2));
    9090%         kx_mean=sum(sum(spec2.*kx))/spec_sum;
  • trunk/src/uvmat.m

    r1180 r1181  
    19461946[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    19471947FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    1948 CheckAbort=false;
    1949 if strcmp(get(handles.MenuRelabelFrames,'checked'),'off')% if the option is selected
    1950     if strcmp(FileExt,'.tif') && ~isempty(regexp(RootFile,'^im', 'once'))% case of PCO images, document <FileSeries> in the xml file
    1951         FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    1952         FileInfo=get_file_info(FileName);
    1953         XmlFile=fullfile(RootPath,[SubDir '.xml']);
    1954         [XmlData,errormsg]=imadoc2struct(XmlFile);
    1955         if ~isempty(errormsg)
    1956             disp(['a file ' XmlFile ' is needed to document the timing'])
    1957             CheckAbort=true;
    1958         elseif ~isfield(XmlData,'FileSeries')% fill the FleSeries if does not exist
    1959             FileSeries.Convention='PCO';
    1960             FileSeries.FileName{1,1}='im.tif';
    1961             FileSeries.FileName{2,1}='im@0001.tif';
    1962             FileSeries.NbFramePerFile=FileInfo.NumberOfFrames;
    1963             [checkupdate,xmlfile,errormsg]=update_imadoc(RootPath,SubDir,'FileSeries',FileSeries);
    1964             if isempty(errormsg)
    1965                 disp([xmlfile 'updated with FileSeries'])
    1966             else
    1967                 disp(errormsg)
    1968                 CheckAbort=true;
    1969             end
    1970         end
    1971     end
    1972     if ~CheckAbort
    1973     set(handles.MenuRelabelFrames,'checked','on')
    1974     end
    1975 else
     1948CheckRelabel=false;
     1949% if the option is selected from previous 'off' state
     1950if strcmp(get(handles.MenuRelabelFrames,'checked'),'off')
     1951    if strcmp(FileExt,'.seq')
     1952        XmlFile=regexprep(FileName,'.seq$','.xml');
     1953    else
     1954    XmlFile=fullfile(RootPath,[SubDir '.xml']);
     1955    end
     1956    [XmlData,errormsg]=imadoc2struct(XmlFile);
     1957    if isempty(XmlData) || isempty(XmlData.Time)
     1958        msgbox_uvmat('ERROR',['the timing needs to be documented in the file ' XmlFile])
     1959        return
     1960    end
     1961    FileInfo=get_file_info(FileName);
     1962    switch FileInfo.FileType
     1963        case 'multimage'
     1964            if strcmp(FileExt,'.tif') && ~isempty(regexp(RootFile,'^im', 'once'))% case of PCO images, document <FileSeries> in the xml file
     1965                FileSeries.Convention='PCO';
     1966                FileSeries.FileName{1,1}='im.tif';
     1967                FileSeries.FileName{2,1}='im@0001.tif';
     1968                FileSeries.NbFramePerFile=FileInfo.NumberOfFrames;
     1969                [checkupdate,xmlfile,errormsg]=update_imadoc(RootPath,SubDir,'FileSeries',FileSeries);
     1970                if isempty(errormsg)
     1971                    disp([xmlfile 'updated with FileSeries'])
     1972                    CheckRelabel=true;
     1973                else
     1974                    disp(errormsg)
     1975                end
     1976            end
     1977        case 'rdvision'
     1978            check_time_rdvision(FileName,XmlData)
     1979    end
     1980    if CheckRelabel
     1981        set(handles.MenuRelabelFrames,'checked','on')
     1982        errormsg=update_series(handles,RootPath,SubDir,FileName,FileInfo,false,1);
     1983    end
     1984else % option set to 'off'
    19761985    set(handles.MenuRelabelFrames,'checked','off')%if the option was chcked, uncheck it
    1977 end
    1978 if ~CheckAbort
    1979     errormsg=display_file_name(handles,FileName,1);
    1980     if ~isempty(errormsg)
    1981         disp(errormsg)
    1982     end
    1983 end
    1984 
     1986    errormsg=update_series(handles,RootPath,SubDir,FileName,FileInfo,false,1);
     1987end
     1988if ~isempty(errormsg)
     1989    disp(errormsg)
     1990end
     1991
     1992% ---------------------------------------
     1993function check_time_rdvision(FileName,XmlData)
     1994s=ini2struct(FileName);
     1995    SeqData=s.sequenceSettings;
     1996    SeqData.width=str2double(SeqData.width);
     1997    SeqData.height=str2double(SeqData.height);
     1998    SeqData.bytesperpixel=str2double(SeqData.bytesperpixel);
     1999    SeqData.nb_frames=str2double(s.sequenceSettings.numberoffiles);
     2000    if isempty(SeqData.binrepertoire)%used when binrepertoire empty, strange feature of rdvision
     2001        SeqData.binrepertoire=regexprep(s.sequenceSettings.bindirectory,'\\$','');%tranform Windows notation to Linux
     2002        SeqData.binrepertoire=regexprep(SeqData.binrepertoire,'\','/');
     2003        [tild,binrepertoire,DirExt]=fileparts(SeqData.binrepertoire);
     2004        SeqData.binrepertoire=[SeqData.binrepertoire DirExt];
     2005    end
     2006   
     2007    %% reading the .sqb file
     2008     SqbFile=regexprep(FileName,'.seq$','.sqb');
     2009    m = memmapfile(SqbFile,'Format', { 'uint32' [1 1] 'offset'; ...
     2010        'uint32' [1 1] 'garbage1';...
     2011        'double' [1 1] 'timestamp';...
     2012        'uint32' [1 1] 'file_idx';...
     2013        'uint32' [1 1] 'garbage2' },'Repeat',SeqData.nb_frames);
     2014   
     2015    %%%%%%%BRICOLAGE in case of unreadable .sqb file: remplace lecture du fichier
     2016    %         ind=[111 114:211];%indices of bin files
     2017    %         w=1024;%w=width of images in pixels
     2018    %         h=1024;%h=height of images in pixels
     2019    %         bpp=2;% nbre of bytes per pixel
     2020    %         lengthimage=w*h*bpp;% lengthof an image record on the binary file
     2021    %         nbimages=32; %nbre of images of each camera in a bin file
     2022    %         for ii=1:32*numel(ind)
     2023    %             data(ii).offset=mod(ii-1,32)*2*lengthimage+lengthimage;%Dalsa_2
     2024    %             %data(ii).offset=mod(ii-1,32)*2*lengthimage;%Dalsa_1
     2025    %             data(ii).file_idx=ind(ceil(ii/32));
     2026    %             data(ii).timestamp=0.2*(ii-1);
     2027    %         end
     2028    %         m.Data=data;
     2029    %%%%%%%
     2030    timestamp=zeros(1,numel(m.Data));
     2031    for ii=1: numel(m.Data)
     2032        timestamp(ii)=m.Data(ii).timestamp;
     2033    end
     2034    difftime=XmlData.Time(2:end,2:end);
     2035    difftime=timestamp'-reshape(difftime,[],1);
     2036    disp(['time from xml and timestamp differ by ' num2str(max(max(abs(difftime))))])
     2037    if max(abs(difftime))>0.01
     2038       figure(1)
     2039       plot(timestamp,difftime)
     2040       xlabel('time(s)')
     2041       ylabel('timestamp-XmlData.Time(s)')
     2042    end
     2043   
     2044        %% checking consistency with the xml file
     2045    if ~isequal(SeqData.nb_frames,numel(timestamp))
     2046        disp_uvmat('ERRROR',['inconsistent number of images ' num2str(SeqData.nb_frames) ' with respect to the xml file: ' num2str(numel(timestamp))] ,checkrun);
     2047        return
     2048    end   
     2049   
     2050    disp ('max time difference xml and timestamps (IN SEC.)')
     2051    max(abs(difftime))
    19852052%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    19862053% MenuRun Callbacks
     
    21772244
    21782245%% case of isolated input files without series
    2179 switch FieldType
    2180     case ''
    2181         msgbox_uvmat('ERROR','invalid input file type')
    2182         return
    2183     case 'txt'
    2184         edit(fileinput)
    2185         return
    2186     case 'figure'                           %display matlab figure
    2187         hfig=open(fileinput);
    2188         set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
    2189         set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
    2190         set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
    2191         return
    2192     case 'xml'                % edit xml files
    2193         t=xmltree(fileinput);
    2194         % the xml file marks a project or project link, open datatree_browser
    2195         if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir')
    2196             datatree_browser(fileinput)
    2197         else % other xml file, open the xml editor
     2246if strcmp(FileInfo.FileIndexing,'off')
     2247    switch FieldType
     2248        case 'txt'
     2249            edit(fileinput)
     2250        case 'figure'                           %display matlab figure
     2251            hfig=open(fileinput);
     2252            set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
     2253            set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
     2254            set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
     2255        case 'xml'                % edit xml files
     2256            t=xmltree(fileinput);
     2257            % the xml file marks a project or project link, open datatree_browser
     2258            if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir')
     2259                datatree_browser(fileinput)
     2260            else % other xml file, open the xml editor
     2261                editxml(fileinput);
     2262            end
     2263        case 'xls'% Excel file opended by editxml
    21982264            editxml(fileinput);
    2199         end
    2200         return
    2201     case 'xls'% Excel file opended by editxml
    2202         editxml(fileinput);
    2203         return
     2265        otherwise
     2266            msgbox_uvmat('ERROR',['inputfile type ' FileInfo.FileType ' not implemented in uvmat'])
     2267
     2268    end
     2269    return
    22042270end
    22052271
     
    22642330    set(handles.j2,'String',num2stra(j2,NomType));
    22652331    if isfield(FileInfo,'MaskFile')
    2266         if exist(FileInfo.MaskFile)
     2332        if exist(FileInfo.MaskFile,'file')
    22672333            set(handles.CheckMask,'Value',1)
    22682334        else
     
    23372403set(handles.MenuTools,'Enable','on')
    23382404
    2339 % initiate input file series and inputfilerefresh the current field view:
     2405%% analyse the input file series, then refresh the current field view:
    23402406update_rootinfo(handles,RootPath,SubDir,[FileName FileExt],FileInfo, MovieObject,input_line);
    23412407
     
    23602426
    23612427set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])% paint back button to red to indicate update is finished
    2362 set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrow
     2428set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrowCheckIndexing
    23632429
    23642430
     
    23692435function errormsg=update_rootinfo(handles,RootPath,SubDir,FileName,FileInfo,VideoObject,input_line)
    23702436%------------------------------------------------------------------------
    2371 errormsg=''; %default error msg
    2372 
    2373 %% define the relevant handles depending on the input_line (1=first file series, 2= second file series)
    2374 if ~exist('input_line','var')
    2375     input_line=1;
    2376 end
    2377 if input_line==1
    2378     handles_Fields=handles.FieldName;
    2379 elseif input_line==2
    2380     handles_Fields=handles.FieldName_1;
    2381 end
     2437
    23822438set(handles.FixVelType,'Value',0); %desactivate fixed veltype by default
    23832439
     
    23852441XmlFileName=find_imadoc(RootPath,SubDir);% search the appropriate ImaDoc xml file
    23862442[~,XmlName]=fileparts(XmlFileName);
    2387 warntext='';%default warning message
    2388 NbSlice=1;%default
    2389 TimeUnit='';%default
    2390 TimeName='';%default
    2391 XmlData=[];
     2443
     2444CheckIndexing=false;% test for virtual indexing of frames different from the file name index, false by default
    23922445if isempty(XmlFileName) %no ImaDoc xml file detected
    23932446    set(handles.view_xml,'Visible','off')
     
    24022455    end
    24032456    if ~isempty(XmlData)
    2404         if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
    2405             TimeUnit=XmlData.TimeUnit;
    2406         end
    2407         if isfield(XmlData,'Time')&& ~isempty(XmlData.Time)
    2408             TimeName='xml';%Time possibly documented by the xml file (but priority to the opened file if available)
    2409 %             if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1
    2410 %                 sizDti=size(XmlData.Time,1)-1;%size of the time vector explicitly defined in the xml file
    2411 %                 ind_start=1;
    2412 %             else
    2413 %                 sizDti=size(XmlData.Time,1);% case starting with index 0
    2414 %                 ind_start=0;
    2415 %             end
    2416             if isfield(XmlData,'FileSeries')&& ~strcmp(XmlName,SubDir)
     2457        if isfield(XmlData,'FileSeries')
     2458             if strcmp(XmlName,SubDir)% xml file directly at the level of the current data file (not up in the data tree)
     2459                 CheckIndexing=true;%  virtual indexing of frames different from the file name index
     2460             else % xml file not used to document index relabeling
    24172461                  XmlData=rmfield(XmlData,'FileSeries');%desactivate file indexing option for derived file series (e.g. images.png)
    2418             end
     2462             end
    24192463        end
    24202464    end
     
    24262470    end
    24272471end
     2472if CheckIndexing
     2473set(handles.MenuRelabelFrames,'checked','on')% activate the relabel tool by default
     2474else
     2475    set(handles.MenuRelabelFrames,'checked','off')
     2476end
    24282477XmlData.FileInfo=FileInfo;
     2478errormsg=update_series(handles,RootPath,SubDir,FileName,XmlData,CheckIndexing,input_line);
     2479
     2480%--------------------------------------------------------
     2481function errormsg=update_series(handles,RootPath,SubDir,FileName,XmlData,CheckIndexing,input_line)
     2482errormsg=''; %default error msg
     2483warntext='';%default warning message
     2484NbSlice=1;%default
     2485TimeUnit='';%default
     2486TimeName='';%default
    24292487
    24302488%% get the file series
    24312489MovieObject=[];
    2432 if strcmp(get(handles.MenuRelabelFrames,'checked'),'on') && isfield(XmlData,'FileSeries') && isfield(XmlData.FileSeries,'FileName')
    2433     CheckIndexing=true;
     2490if CheckIndexing
    24342491    NomType='*';
    24352492    i1_series=[];
     
    24392496    nbfield=[];
    24402497    nbfield_j=[];
    2441 
    2442     %     if iscell(XmlData.FileSeries.FileName)
    2443     %         [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(XmlData.FileSeries.FileName{1});
    2444     %     else
    2445     %     [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(XmlData.FileSeries.FileName);
    2446     %     end
    2447     if strcmp(TimeName,'xml') %&& CheckIndexing% get the image series info from the xml file
    2448         [nbfield,nbfield_j]=size(XmlData.Time);
    2449         nbfield=nbfield-1; %remove the possible index 0
    2450         nbfield_j=nbfield_j-1; %remove the possible index 0
    2451         i1_series=zeros(nbfield,nbfield_j,1);
    2452         i1_series(:,:,1)=(1:nbfield)'*ones(1,nbfield_j);
    2453         i2_series=i1_series;
    2454         if nbfield_j==1
    2455             j1_series=[];
    2456         else
    2457             j1_series(:,:,1)=ones(nbfield,1)*(1:nbfield_j);
    2458         end
    2459         j2_series=j1_series;
    2460     end
    2461     set(handles.i1,'String','1')
     2498    FileInfo=XmlData.FileInfo;
     2499    %     if iscell(XmlData.FileSeries.FileName)(handles.i1,'String','1')
     2500    set(handles.i1,'String','1')% the index does not correspond to file name index anymore
    24622501    set(handles.j1,'String','1')
    24632502else % scan the input folder to get the list of existing files and NomType
    2464     CheckIndexing=false;
    24652503    [~,~,~,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject]=...
    24662504        find_file_series(fullfile(RootPath,SubDir),FileName);
     
    24752513    if ~isempty(j1_series)&& ~strcmp(NomType,'*')% the j index is used to label the frame in multimage series
    24762514        set(handles.j1,'String','1')
     2515    elseif strcmp(FileInfo.FieldType,'image') && ~isequal(FileInfo.NumberOfFrames,1)
     2516        set(handles.i1,'String','1')
    24772517    end
    24782518end
     
    25032543UvData.NewSeries=1; %flag for REFRESH: begin a new series
    25042544UvData.FileName_1='';% name of the current second field (used to detect a  constant field during file scanning)
    2505 %UvData.FileType{input_line}=FileInfo.FileType;
    25062545UvData.FileInfo{input_line}=FileInfo;
    25072546UvData.MovieObject{input_line}=MovieObject;
     
    25142553%% read timing and total frame number from the current file (e.g. movie files)
    25152554ColorType='falsecolor'; %default
     2555if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
     2556            TimeUnit=XmlData.TimeUnit;
     2557end
     2558if isfield(XmlData,'Time')&& ~isempty(XmlData.Time)
     2559            TimeName='xml';%Time possibly documented by the xml file (but priority to the opened file if available)
     2560end
     2561
    25162562if ~CheckIndexing && isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data)
    25172563    TimeUnit='s';
     
    25192565        XmlData.Time=zeros(FileInfo.NumberOfFrames+1,2);
    25202566        XmlData.Time(:,2)=(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate)';
     2567        set(handles.i1,'String','1')% set the frame index to 1 to start the movie
    25212568    else
    25222569        XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate);
     
    26422689if ~isequal(warntext,'')
    26432690    msgbox_uvmat('WARNING',warntext);
     2691end
     2692
     2693%% define the relevant handles depending on the input_line (1=first file series, 2= second file series)
     2694if ~exist('input_line','var')
     2695    input_line=1;
     2696end
     2697if input_line==1
     2698    handles_Fields=handles.FieldName;
     2699elseif input_line==2
     2700    handles_Fields=handles.FieldName_1;
    26442701end
    26452702
     
    32183275    i2=[];j2=[];
    32193276else
    3220     [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used
     3277    [~,~,~,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used
    32213278    if isempty(i1)% no i index set by the input file name
    32223279        i1=str2double(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
     
    32283285if sub_value % a second input file has been entered
    32293286    [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles);
    3230     [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_1
     3287    [~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_1
    32313288    if isempty(i1_1)
    32323289        i1_1=str2double(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
     
    47574814        YName='';
    47584815        ZName='';
     4816        if isfield(GetFieldData,'FieldOption')
    47594817        switch GetFieldData.FieldOption
    47604818            case 'vectors'
     
    48104868                    set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
    48114869                   % set(handles.NomType,'String','*')
    4812                     set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
     4870                    set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% put file index in the root name
     4871                    set(handles.NomType,'String','')
    48134872                    set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix)
    48144873                    MaxIndex_i=get(handles.MaxIndex_i,'String');
     
    48434902            REFRESH_Callback(hObject, eventdata, handles)
    48444903        end
    4845 
     4904        end
    48464905    case 'image'
    48474906        %% look for image corresponding to civ data
Note: See TracChangeset for help on using the changeset viewer.