-
Notifications
You must be signed in to change notification settings - Fork 1
/
SliceFinder.m
69 lines (57 loc) · 1.84 KB
/
SliceFinder.m
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
function SliceFinder(varargin)
%SliceFinder Multi-species histology slice alignment program
%% add subfolders
if ~isdeployed
%check version
PF_AssertVersion();
%disable buttons
global sUPF_ChooseGui %#ok<TLEV>
UPF_DisableButtons(sUPF_ChooseGui);
%add folders
strFullpath = mfilename('fullpath');
strPath = fileparts(strFullpath);
sDir=dir([strPath filesep '**' filesep]);
%remove git folders
sDir(contains({sDir.folder},[filesep '.git'])) = [];
cellFolders = unique({sDir.folder});
for intFolder=1:numel(cellFolders)
addpath(cellFolders{intFolder});
end
%enable buttons
UPF_EnableButtons(sUPF_ChooseGui);
end
%% try using Acquipix variables
try
sRP = RP_populateStructure();
strDefaultPath = sRP.strProbeLocPath;
catch
sRP = struct; %#ok<NASGU>
strDefaultPath=cd();
end
%% ask for folder & meta data (if any)
sSliceData = SH_LoadSlicePath(strDefaultPath);
if isempty(sSliceData),return;end
%% load atlas
sAtlasParams = PF_getAtlasIni();
%select which atlas to use
cellAtlases = {sAtlasParams.name};
[intSelectAtlas,boolContinue] = listdlg('ListSize',[200 100],'Name','Atlas Selection','PromptString','Select Atlas:',...
'SelectionMode','single','ListString',cellAtlases);
if ~boolContinue,return;end
%load atlas
strAtlasName = sAtlasParams(intSelectAtlas).name; %#ok<NASGU>
strPathVar = sAtlasParams(intSelectAtlas).pathvar;
fLoader = sAtlasParams(intSelectAtlas).loader;
%get path
strAtlasPath = PF_getIniVar(strPathVar);
%load & prep atlas
sAtlas = feval(fLoader,strAtlasPath);
if isempty(sAtlas),return;end
if isfield(sAtlasParams(intSelectAtlas),'downsample') && ~isempty(sAtlasParams(intSelectAtlas).downsample)
sAtlas.Downsample = round(sAtlasParams(intSelectAtlas).downsample);
else
sAtlas.Downsample = 1;
end
%% run slice aligner
SF_GenSliceFinderGUI(sAtlas,sSliceData);
end