forked from erhanbas/mouse2syglass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyglassrun.m
More file actions
executable file
·81 lines (73 loc) · 3.02 KB
/
syglassrun.m
File metadata and controls
executable file
·81 lines (73 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function syglassrun(sample_path, output_folder, do_rerun, do_use_cluster)
% inputs:
% samplepath: name of the sample folder
% outfolder: target folder to create syglass files
% rerun: binary flag to recreate output of ls file. This will save
% time if you want to use the result of "ls" from a previous
% session
% example run:
% sample = '2018-07-02-raw_new';
% samplepath = fullfile('/nrs/mouselight/SAMPLES/',sample);
% outfolder = fullfile(samplepath,'syglass-ch0');
% rerun = 0;
% syglassrun(samplepath,outfolder,rerun)
% if nargin<1
% sample = '2018-08-15';
% samplepath = fullfile('/nrs/mouselight/SAMPLES/',sample);
% outfolder = fullfile(samplepath,'syglass-ch0');
% rerun = 0;
% else
if ~exist('do_rerun', 'var') || isempty(do_rerun) ,
do_rerun = true ;
end
if ~exist('do_use_cluster', 'var') || isempty(do_use_cluster) ,
do_use_cluster = true ;
end
[~, sample_name] = fileparts(sample_path) ;
if do_rerun ,
unix(sprintf('rm -rdf ./tmpfiles'));
mkdir('./tmpfiles');
end
if ~exist(fullfile('./tmpfiles',sample_name),'dir'),
mkdir('./tmpfiles',sample_name);
end
this_file_path = mfilename('fullpath') ;
this_folder_path = fileparts(this_file_path) ;
python_path = fullfile(this_folder_path, 'anaconda3/envs/syglass/bin/python2') ;
script_path = fullfile(this_folder_path, 'singleThreadedCacher.py') ;
%addpath(genpath('./common'))
opt = configparser(fullfile(sample_path,'/transform.txt'));
maxlevel = opt.nl-1 ;
%maxlevel = 3 ;
maxlevel
%clear opt
for level=0:maxlevel
mysh = sprintf('./syglassrun-%d-ch0.sh',level);
file_list_file_name = fullfile('./tmpfiles', sample_name, sprintf('filelist-%d.txt',level));
inputfolder = sample_path;
if ~exist(file_list_file_name, 'file') ,
recdir_custom(file_list_file_name, inputfolder, '*.0.tif', level) ;
end
file_list_fid=fopen(file_list_file_name,'r');
myfiles = textscan(file_list_fid,'%s');
myfiles = myfiles{1};
fclose(file_list_fid);
bash_script_fid = fopen(mysh,'w');
for ii=1:length(myfiles)
infold = [fileparts(myfiles{ii}),'/'];
relativepath = infold(length(sample_path)+1:end);
outfold = fullfile(output_folder,relativepath) ;
if length(relativepath)>2 && strcmp(relativepath(1:3),'ktx') % skip any ktx files
continue
end
if ~exist(outfold,'dir')
mkdir(outfold)
unix(sprintf('chmod g+rwx %s',outfold));
end
myarg = sprintf('bsub -P mouselight -n1 -We 1 -J t-%d-%05d -o /dev/null ''%s %s %s %s''\n',level,ii,python_path,script_path,infold,outfold);
fwrite(bash_script_fid,myarg);
end
fclose(bash_script_fid);
unix(sprintf('chmod g+rwx %s',mysh));
end
end