source: trunk/src/script_delete_rdvision.m @ 1159

Last change on this file since 1159 was 1159, checked in by sommeria, 5 months ago

script delete rdvision updated, bug correctred in geometry_calib (case of color images)

File size: 6.9 KB
RevLine 
[1123]1
2%%% extract a series of image folders from RDvision
3% to run on the cluster, edit the file extract.sh in the folder TOP_view or SCANSIDE,
4% Then oarsub -l "walltime=20:00:00" /fsnet/project/coriolis/2018/18ADDUCE/TOP_View/extract.sh
5%%%%%%%%%%%%%%  CHOOSE THE ROOT FOLDER %%%%%%%%%%
6
[1159]7RootDir='1_DATA'
[1123]8%RootFolder=fullfile('/fsnet/project/coriolis/2018/18JEVERB',RootDir);
[1159]9%RootFolder=fullfile('/fsnet/project/edt/2021/21CORIOFARM',RootDir)
10RootFolder=fullfile('/fsnet/project/coriolis/2024/24PLUME',RootDir)
[1123]11%ParamFile=fullfile(RootFolder,'extract_param.xml');
12%Param=xml2struct(ParamFile);
13
14ListStruct=dir(RootFolder); % get structure of the Root directory
15index_dir=find(strcmp('isdir',fieldnames(ListStruct)));%detect folder info in structure ListStruct
16ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
17check_dir=cell2mat(ListCells(index_dir,:));% =1 for directories, =0 for files
18ListCells=ListCells(:,check_dir);
19ListCells(:,1:2)=[];
20ListNames=ListCells(1,:);
21List2extract={};
22List2delete={};
23List2check={};
24
25%% loop on experiments
26for ilist=1:numel(ListNames)%loop on experiments
27    ListNames{ilist}
28    SubFolder=fullfile(RootFolder,ListNames{ilist});
29    ListStructSub=dir(SubFolder); % get structure of the Root directory
30    index_dir=find(strcmp('isdir',fieldnames(ListStructSub)));%detect folder info in structure ListStruct
31    ListCellsSub=struct2cell(ListStructSub);% transform dir struct to a cell arrray
32    check_dir=cell2mat(ListCellsSub(index_dir,:));% =1 for directories, =0 for files
33    ListCellsSub=ListCellsSub(:,check_dir);
34    ListCellsSub(:,1:2)=[];
35    ListNamesSub=ListCellsSub(1,:);
36    ind_rdvision=[];
37    for isub=1:numel(ListNamesSub)% loop on data folders of the current experiment
38        ListStructSubSub=dir(fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub})); % get structure of the Root directory
39        index_dir=find(strcmp('isdir',fieldnames(ListStructSubSub)));%detect folder info in structure ListStruct
40        ListCellsSubSub=struct2cell(ListStructSubSub);% transform dir struct to a cell arrray
41        check_dir=cell2mat(ListCellsSubSub(index_dir,:));% =1 for directories, =0 for files
42        ListCellsSubSub=ListCellsSubSub(:,check_dir);
43        ListCellsSubSub(:,1:2)=[];
44        ListNamesSubSub=ListCellsSubSub(1,:);
45        ind_rdvision=[];
46        for isubsub=1:numel(ListNamesSubSub)
[1159]47            if ~isempty(regexp(ListNamesSubSub{isubsub},'^2024-'))
[1123]48                ind_rdvision=[ind_rdvision isubsub];%detect rdvision folders
49            end
50        end
51
52        %% extract the rdvision image series if it was not done
53        if numel(ind_rdvision)==1%
54            DataFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{ind_rdvision});
55            if isempty(regexp(DataFolder,'.extract$'))% if the detected folder is not .extract
56                %     ExtractFolder=fullfile(Param.InputTable{1},[Param.InputTable{2} '.extract']);
57                %     mkdir(ExtractFolder)
58                % %     if ~isempty(XmlFile)
59                % %     copyfile(fullfile(RootFolder,XmlFile),fullfile(DataFolder,[Param.OutputRootFile '.xml']));
60                % %     end
61                %     seqname=fullfile(DataFolder,[Param.InputTable{3} Param.InputTable{5}]);
62                %     [A,FileInfo,timestamps,errormsg]=read_rdvision(seqname,[]);
63                %     Param.IndexRange.last_i=str2num(FileInfo.numberoffiles);
64                %     Param.OutputSubDir=Param.InputTable{2};
65                %     Param.ActionInput.LogPath= DataFolder;
66                %     extract_rdvision(Param)% apply the function used in series
67                %     [ListNames{ilist} ' extracted']
68                List2extract=[List2extract;DataFolder];
69            end
70        end
71
72        %% delete the rdvision source if the extraction has been done
73        Checkdelete=0;
74        ExtractFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub});
75        status='';
76        if numel(ind_rdvision)==2
77            for irdvision=1:2
78                CheckExtract(irdvision)=isempty(regexp(fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{irdvision}), '.extract$'));
79            end
80            status='extract missing';
81            if numel(find(CheckExtract))==1
82                ExtractFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{find(CheckExtract)});
83                PngFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},'im');
84                status='image folder not created';
85                if exist(ExtractFolder,'dir') && exist(PngFolder,'dir')
86                    filename_seq=fullfile(ExtractFolder,'im.seq');
[1159]87                    try
[1123]88                    s=ini2struct(filename_seq);
89                    FileInfo=s.sequenceSettings;
90                    if isfield(s.sequenceSettings,'numberoffiles')
91                        NumberOfFrames=str2double(s.sequenceSettings.numberoffiles);
92                    else
93                        status='bad seq file';
94                    end
[1159]95                    catch ME
96                        disp(['error in ' filename_seq])
97                    end
[1123]98                    DirPng=dir(PngFolder);
99                    if numel(DirPng)==NumberOfFrames+2
100                        Checkdelete=1;
101                    else
102                        status=['extraction not finished,' num2str(numel(DirPng)-2) ' images extracted'];
103                    end
104                end
105            end
106            %
107            %
108            %     Param.InputTable{1}=fullfile(RootFolder,ListDir{ilist});%folder exp
109            %     ddd=dir(Param.InputTable{1});
110            %     Param.InputTable{2}=ddd(3).name;
111            %     DataFolder=fullfile(Param.InputTable{1},Param.InputTable{2});
112            %     ExtractFolder=fullfile(Param.InputTable{1},[Param.InputTable{2} '.extract']);
113            %     mkdir(ExtractFolder)
114            %     if ~isempty(XmlFile)
115            %     copyfile(fullfile(RootFolder,XmlFile),fullfile(DataFolder,[Param.OutputRootFile '.xml']));
116            %     end
117            %     seqname=fullfile(DataFolder,[Param.InputTable{3} Param.InputTable{5}]);
118            %     [A,FileInfo,timestamps,errormsg]=read_rdvision(seqname,[]);
119            %     Param.IndexRange.last_i=str2num(FileInfo.numberoffiles);
120            %     Param.OutputSubDir=Param.InputTable{2};
121            %     Param.ActionInput.LogPath= DataFolder;
122            %     extract_rdvision(Param)% apply the function used in series
123        end
124        if Checkdelete
125            List2delete=[List2delete;ExtractFolder];
126            %rmdir(ExtractFolder,'s')
127        elseif ~isempty(status)
128            List2check=[List2check;[ExtractFolder ' ' status]];
129        end
130    end
131end
132List2extract
133List2check
134List2delete
135if ~isempty(List2delete)
136    Answer = questdlg('delete listed folders(Y/N)');
137    if strcmp(Answer,'Yes')
138        for ifolder=1:numel(List2delete)
139            rmdir(List2delete{ifolder},'s')
140        end
141    end
142end
Note: See TracBrowser for help on using the repository browser.