-
Notifications
You must be signed in to change notification settings - Fork 1
/
KLTpicker_start.m
102 lines (90 loc) · 3.07 KB
/
KLTpicker_start.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
function KLTpicker_start
%
% KLTpicker_start Start KLT picker processing workflow
%
% KLTpicker_start
% Gather all information required to start the particle picking process out the micrographs.
% This is the first command to be called in any processing workflw.
%
% Amitay Eldar, November 2019.
if ~isdeployed % Only run in a MATLAB session
[basedir,~,~]=fileparts(mfilename('fullpath'));
addpath(fullfile(basedir,'matlab')); % set up MATLAB path
end
micrograph_addr='';
while isempty(micrograph_addr)
micrograph_addr =fmtinput('Enter full path of micrographs MRC file: ','','%s');
% if exist(micrograph_addr,'file')~=7
if isempty(dir([micrograph_addr,'/*.mrc']))
fprintf('MRC file does not exist.\n');
micrograph_addr='';
end
end
output_dir =fmtinput('Enter full path of output directory: ','','%s');
if ~strcmp(output_dir(end),'/')
output_dir = [output_dir,'/'];
end
if ~exist(output_dir,'dir') % Do we need to create directory?
message='Output directory does not exist. Create?';
do_create=multichoice_question(message,{'Y','N'},[ 1, 0],'Y');
if do_create==1
mkdir(output_dir);
end
end
particle_size='';
while isempty(particle_size)
particle_size_str =fmtinput('Enter the particle size in pixels: ','','%s');
particle_size = str2double(particle_size_str);
if mod(particle_size,1)~=0
fprintf('particle size should be a natural number.\n');
particle_size='';
end
if particle_size<0
fprintf('particle size should be a natural number.\n');
particle_size='';
end
end
num_of_particles='';
message='pick all particles?';
do_create=multichoice_question(message,{'Y','N'},[ 1, 0],'Y');
if do_create==1
num_of_particles = -1;
end
while isempty(num_of_particles)
num_of_particles_str =fmtinput('How many particles to pick: ','','%s');
num_of_particles = str2double(num_of_particles_str);
if mod(num_of_particles,1)~=0
fprintf('number of particles to pick should be a natural number.\n');
num_of_particles='';
end
if num_of_particles<0
fprintf('number of particles to pick should be a natural number.\n');
num_of_particles='';
end
end
num_of_noise_images='';
message='Pick noise images?';
do_create=multichoice_question(message,{'Y','N'},[ 0, 1],'N');
if do_create==1
num_of_noise_images=0;
end
while isempty(num_of_noise_images)
num_of_noise_images_str =fmtinput('How many noise images to pick: ','','%s');
num_of_noise_images = str2double(num_of_noise_images_str);
if mod(num_of_noise_images,1)~=0
fprintf('number of noise images to pick should be a natural number.\n');
num_of_noise_images='';
end
if num_of_noise_images<0
fprintf('number of noise images to pick should be a natural number.\n');
num_of_noise_images='';
end
end
message='Do you want to use the GPU?';
do_create=multichoice_question(message,{'Y','N'},[ 1, 0],'Y');
if do_create==1
gpu_use = 1;
else
gpu_use = 0;
end
KLTpickerVer1(micrograph_addr,output_dir,particle_size,num_of_particles,num_of_noise_images,gpu_use)