Skip to content

Commit 7201d4c

Browse files
committed
Added all the stuff for stitching
1 parent 04d91b0 commit 7201d4c

File tree

109 files changed

+11630
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+11630
-26
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function tile_index = build_raw_tile_index_for_neighborhood(raw_tile_root_folder_path, center_tile_relative_path, sample_memo_folder_path, do_force_computation)
2+
% Build the full tile index
3+
raw_tile_index = compute_or_read_from_memo(sample_memo_folder_path, ...
4+
'raw-tile-index', ...
5+
@()(build_raw_tile_index(raw_tile_root_folder_path)), ...
6+
do_force_computation) ;
7+
full_tile_index_from_full_tile_ijk1 = raw_tile_index.tile_index_from_tile_ijk1 ;
8+
full_tile_ijk1_from_full_tile_index = raw_tile_index.ijk1_from_tile_index ;
9+
xyz_from_full_tile_index = raw_tile_index.xyz_from_tile_index ;
10+
relative_path_from_full_tile_index = raw_tile_index.relative_path_from_tile_index ;
11+
%full_tile_grid_shape = size(full_tile_index_from_full_tile_ijk1)
12+
%full_tile_count = length(relative_path_from_full_tile_index)
13+
14+
% Get out just the tiles around the center_tile
15+
[tile_index_from_tile_ijk1, ...
16+
tile_ijk1_from_tile_index, ...
17+
xyz_from_tile_index, ...
18+
relative_path_from_tile_index] = ...
19+
extract_tiles_near_tile(full_tile_index_from_full_tile_ijk1, ...
20+
full_tile_ijk1_from_full_tile_index, ...
21+
xyz_from_full_tile_index, ...
22+
relative_path_from_full_tile_index, ...
23+
center_tile_relative_path) ;
24+
%tile_count = length(relative_path_from_tile_index)
25+
26+
% Store the tile subset indices in a single structure
27+
tile_index = struct() ;
28+
tile_index.tile_index_from_tile_ijk1 = tile_index_from_tile_ijk1 ;
29+
tile_index.ijk1_from_tile_index = tile_ijk1_from_tile_index ;
30+
tile_index.xyz_from_tile_index = xyz_from_tile_index ;
31+
tile_index.relative_path_from_tile_index = relative_path_from_tile_index ;
32+
end

common/io/recdir.m

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
function recdir(inputfolder,args,level)
2+
%%
3+
% args.level = opt.level;
4+
% args.ext = opt.ext;
5+
% if exist(opt.seqtemp, 'file') == 2
6+
% % load file directly
7+
% else
8+
% args.fid = fopen(opt.seqtemp,'w');
9+
% recdir(opt.inputfolder,args)
10+
% end
11+
% fid=fopen(opt.seqtemp,'r');
12+
% myfiles = textscan(fid,'%s');
13+
% myfiles = myfiles{1};
14+
% fclose(fid)
15+
16+
% get sequence
17+
if nargin ==0
18+
inputfolder = '/nobackup2/mouselight/cluster/SitchedProbability_GN1/2015-06-19-erhan-GN1-maskProb'
19+
args.level = 5;
20+
args.fid = fopen('paths.txt','w');
21+
args.ext = 'tif'
22+
% try
23+
% recdir(inputfolder,args,level)
24+
% catch
25+
% fclose(args.fid)
26+
% end
27+
end
28+
%%
29+
if nargin <3
30+
level = 0;
31+
end
32+
if args.ext(1) == '.'
33+
args.ext(1) = [];
34+
end
35+
dirinfo = dir(inputfolder);
36+
dirinfo(~[dirinfo.isdir]) = []; %remove non-directories
37+
tf = cellfun(@(x) x(1)=='.',{dirinfo.name}); %remove hidded and parent folders
38+
% ismember( {dirinfo.name}, {'.', '..','.log','.backup'});
39+
dirinfo(tf) = []; %remove current and parent directory.
40+
41+
if isfield(args,'pattern')
42+
matches = regexp({dirinfo(:).name},args.pattern);
43+
keep_these = zeros(1,length(dirinfo));
44+
for ifold = 1:length(matches)
45+
if matches{ifold} & matches{ifold}(1)==1
46+
keep_these(ifold) = 1;
47+
end
48+
end
49+
dirinfo(~keep_these) = []; %remove any folder that doesn't follow pattern
50+
end
51+
%%
52+
if level == args.level
53+
% search file
54+
% get files with argument
55+
myfiles = dir([inputfolder,'/*.',args.ext]);
56+
% append to xls file
57+
for ii=1:length(myfiles)
58+
if 0&exist(fullfile(inputfolder,[myfiles(ii).name(1:end-3),'.tif']),'file')
59+
60+
else
61+
fprintf(args.fid,'%s\n',fullfile(inputfolder,myfiles(ii).name));
62+
end
63+
end
64+
% % append to xls file
65+
% for ii=1:length(myfiles)
66+
% if myfiles(ii).bytes~=789753938
67+
% fprintf(args.fid,'%s\n',fullfile(inputfolder,myfiles(ii).name));
68+
% end
69+
% end
70+
%return
71+
else
72+
% recursion
73+
for idx=1:length(dirinfo)
74+
recdir(fullfile(inputfolder,dirinfo(idx).name),args,level+1)
75+
end
76+
if level == 1
77+
disp(sprintf('Finished %d : %s',level,inputfolder))
78+
end
79+
end
80+
if level==0
81+
fclose(args.fid);
82+
end
83+
84+
end

common/stat/getmod.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function mod = getmod(x)
2+
% assumes x[Nxdim]
3+
if ndims(x) ==1
4+
mod = gtmd(x);
5+
else
6+
if size(x,1)<=size(x,2)
7+
error('input has more columns then rows, use getmod(x'') if input is correct')
8+
end
9+
mod = size(x,2);
10+
for dim = 1:size(x,2)
11+
mod(dim) = gtmd(x(:,dim));
12+
end
13+
end
14+
end
15+
16+
function md = gtmd(x)
17+
[n,edges] = histcounts(x);
18+
[maxn,indmax] = max(n);
19+
md = (edges(indmax)+edges(indmax+1))/2;
20+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.ignore
2+
*.txt
3+
*.asv
4+
*~
5+
*.mex*
Binary file not shown.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Based on code snippet from
3+
* http://java.sun.com/developer/technicalArticles/releases/data/
4+
*
5+
* Copyright © 2008, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.
6+
*/
7+
8+
import java.awt.image.BufferedImage;
9+
import java.awt.datatransfer.*;
10+
11+
public class ImageSelection implements Transferable {
12+
13+
private static final DataFlavor flavors[] =
14+
{DataFlavor.imageFlavor};
15+
16+
private BufferedImage image;
17+
18+
public ImageSelection(BufferedImage image) {
19+
this.image = image;
20+
}
21+
22+
// Transferable
23+
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
24+
if (flavor.equals(flavors[0]) == false) {
25+
throw new UnsupportedFlavorException(flavor);
26+
}
27+
return image;
28+
}
29+
30+
public DataFlavor[] getTransferDataFlavors() {
31+
return flavors;
32+
}
33+
34+
public boolean isDataFlavorSupported(DataFlavor
35+
flavor) {
36+
return flavor.equals(flavors[0]);
37+
}
38+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2014, Oliver J. Woodford, Yair M. Altman
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of the {organization} nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)