source: trunk/src/batch_extract_rdvision.m @ 1134

Last change on this file since 1134 was 1053, checked in by sommeria, 6 years ago

bed_scan added

File size: 3.2 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
5function batch_extract_rdvision(RootDir)
6
7RootFolder=fullfile('/fsnet/project/coriolis/2018/18ADDUCE',RootDir);
8ParamFile=fullfile(RootFolder,'extract_param.xml');
9XmlFile=fullfile(RootFolder,'im.xml');
10Param=xml2struct(ParamFile);
11switch RootDir
12    case 'TOP_View'
13        XmlFile='';
14        Param.OutputRootFile='Falcon';
15    case 'SCANSIDE'
16        XmlFile='im.xml';
17        Param.OutputRootFile='im';
18end
19ListStruct=dir(RootFolder); % get structure of the Root directory
20ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
21ListNames=ListCells(1,:);%list of file names
22index_dir=find(strcmp('isdir',fieldnames(ListStruct)));%detect folders
23check_dir=cell2mat(ListCells(index_dir,:));% =1 for directories, =0 for files
24ListDir=ListNames(check_dir);
25ind_bad=[find(strcmp('.',ListDir)) find(strcmp('..',ListDir))];
26ListDir(ind_bad)=[];
27
28%NbFolders=1%5; %totql number of folders to process
29% first=9;% #3 is the first folder in the list (#1='.', #2='..')
30% disp('first folder')
31% dd(first).name
32% last=15;%19;
33% disp('last folder')
34% dd(last).name
35
36%for ilist=first:first+NbFolders-1
37for ilist=1:numel(ListDir)
38    disp([ListDir{ilist} ' opened'])
39    ddd=dir(fullfile(RootFolder,ListDir{ilist}));
40    dddCells=struct2cell(ddd);% transform dir struct to a cell arrray
41    dddNames=dddCells(1,:);%list of file names
42    checkdone=false;
43    checkrdvision=0;
44    for iname=1:numel(dddNames)
45        checkdone=~isempty(regexp(dddNames{iname},'.extract$'));
46        if checkdone
47            disp('already extracted')
48            break
49        end
50        checkrdvision=checkrdvision+isequal(regexp(dddNames{iname},'^2018-'),1)
51    end
52    if ~checkdone
53        if checkrdvision==0
54            disp('no rdvision folder')
55        elseif checkrdvision>1
56            disp('multiple rdvision folders, no extraction')
57        else
58            Param.InputTable{1}=fullfile(RootFolder,ListDir{ilist});%folder exp
59            Param.InputTable{2}=ddd(3).name;
60            DataFolder=fullfile(Param.InputTable{1},Param.InputTable{2});
61            ExtractFolder=fullfile(Param.InputTable{1},[Param.InputTable{2} '.extract']);
62            mkdir(ExtractFolder)
63            if ~isempty(XmlFile)
64                copyfile(XmlFile,fullfile(DataFolder,[Param.OutputRootFile '.xml']));
65            end
66            seqname=fullfile(DataFolder,[Param.InputTable{3} Param.InputTable{5}]);
67            [A,FileInfo,timestamps,errormsg]=read_rdvision(seqname,[]);
68            Param.IndexRange.last_i=str2num(FileInfo.numberoffiles);
69            Param.OutputSubDir=Param.InputTable{2};
70            Param.ActionInput.LogPath= DataFolder;
71            extract_rdvision(Param)% apply the function used in series
72            disp([ListDir{ilist} ' extracted'])
73        end
74    end
75end
76'PROGRAM END'
77%%%%% COMMAND CLUSTER
78%oarsub -l "walltime=10:00:00" /fsnet/project/coriolis/2018/18ADDUCE/SCANSIDE/extract.sh -E /fsnet/project/coriolis/2018/18ADDUCE/SCANSIDE/error -O /fsnet/project/coriolis/2018/18ADDUCE/SCANSIDE/stdout
Note: See TracBrowser for help on using the repository browser.