source: trunk/src/script_delete_PCO.m

Last change on this file was 1161, checked in by sommeria, 3 months ago

filter_tps modified to avoid possible bugs in case of few vectors, subpixel interpolation slightly modified in civ

File size: 5.3 KB
Line 
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
7RootDir='1_DATA'
8%RootFolder=fullfile('/fsnet/project/coriolis/2018/18JEVERB',RootDir);
9%RootFolder=fullfile('/fsnet/project/edt/2021/21CORIOFARM',RootDir)
10RootFolder=fullfile('/fsnet/project/coriolis/2024/24PLUME',RootDir)
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    check_PCOA(ilist)=0;
29    check_PCOB(ilist)=0;
30    SubFolder=fullfile(RootFolder,ListNames{ilist});
31    ListStructSub=dir(SubFolder); % get structure of the Root directory
32    index_dir=find(strcmp('isdir',fieldnames(ListStructSub)));%detect folder info in structure ListStruct
33    ListCellsSub=struct2cell(ListStructSub);% transform dir struct to a cell arrray
34    check_dir=cell2mat(ListCellsSub(index_dir,:));% =1 for directories, =0 for files
35    ListCellsSub=ListCellsSub(:,check_dir);
36    ListCellsSub(:,1:2)=[];
37    ListNamesSub=ListCellsSub(1,:);
38    ind_rdvision=[];
39
40    for isub=1:numel(ListNamesSub)% loop on data folders of the current experiment
41        ListStructSubSub=dir(fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub})); % get structure of the Root directory
42        index_dir=find(strcmp('isdir',fieldnames(ListStructSubSub)));%detect folder info in structure ListStruct
43        ListCellsSubSub=struct2cell(ListStructSubSub);% transform dir struct to a cell arrray
44        check_dir=cell2mat(ListCellsSubSub(index_dir,:));% =1 for directories, =0 for files
45        ListCellsSubSub=ListCellsSubSub(:,check_dir);
46        ListCellsSubSub(:,1:2)=[];
47        ListNamesSubSub=ListCellsSubSub(1,:);
48        ind_rdvision=[];
49        for isubsub=1:numel(ListNamesSubSub)
50            % look for raw PCO folder (no extension .png)
51            if ~isempty(regexp(ListNamesSubSub{isubsub},'^PCO', 'once'))&& isempty(regexp(ListNamesSubSub{isubsub},'.png', 'once'))
52                ListNamesSubSub{isubsub};%raw PCO folder
53                TifFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{isubsub});
54                DirPCORaw=dir(TifFolder);
55                DirPCORawCells=struct2cell(DirPCORaw);
56                CheckTif=regexp(DirPCORawCells(1,:),'.tif$');
57                IndexTif=find(~cellfun('isempty',CheckTif));
58                ListTif=DirPCORawCells(1,IndexTif);
59                try
60                    Info=imfinfo(fullfile(TifFolder,ListTif{1}));
61                    RecordLength=numel(Info);%Number of frames in fullfile(TifFolder,FileName)
62                    Info=imfinfo(fullfile(TifFolder,ListTif{end}));
63                    NumberOfFrames=numel(Info)+(numel(ListTif)-1)*RecordLength%Number of frames in fullfile(TifFolder,FileName)
64                catch ME
65                    disp(ME.message)
66                    List2check=[List2check;TifFolder];
67                end
68                ind_png=find(strcmp([ListNamesSubSub{isubsub} '.png'],ListNamesSubSub)); %index of the .png folder corresponding to the raw PCO folder
69                if isempty(ind_png)
70                    List2extract=[List2extract;TifFolder];
71                else
72                    PngFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{ind_png})
73                    if exist(PngFolder,'dir')
74                        DirPng=dir(PngFolder);
75                        if numel(DirPng)==NumberOfFrames+6
76                            PngCells=struct2cell(DirPng(7:end));
77                            mm=cell2mat(PngCells(4,:));% check the sizes of extracted images
78                            sizemax=max(mm)
79                            sizemin=min(mm(3:end))
80                            disp(['max size(Mbytes)=' num2str(sizemax/1000000)]);
81                            if min(mm(3:end))<0.9*sizemax
82                                status=['WARNING' 'min size(Mbytes)=' num2str(sizemin/1000000)];
83                                List2check=[List2check;PngFolder];
84                            else
85                                List2delete=[List2delete;TifFolder];% approve deletion of the source multitif files
86                            end
87                        else
88                            status=['extraction not finished,' num2str(numel(DirPng)-6) ' images extracted'];
89                            List2check=[List2check;PngFolder];
90                        end
91                    end
92                end
93            end
94        end
95    end
96end
97
98
99
100List2extract
101List2check
102List2delete
103if ~isempty(List2delete)
104    Answer = questdlg('delete listed folders(Y/N)');
105    if strcmp(Answer,'Yes')
106        for ifolder=1:numel(List2delete)
107            rmdir(List2delete{ifolder},'s')
108        end
109    end
110end
111'END'
Note: See TracBrowser for help on using the repository browser.