47 else if (
method==
"dalton_mass")
52 else if (
method==
"aa_mass")
57 else if (
method==
"threshold")
75 <<
"Input file : " <<
fn_vol << std::endl
78 <<
"AA mass : " <<
aa_mass << std::endl
80 <<
"Output mask : " <<
fn_mask << std::endl
82 <<
"Threshold : " <<
threshold << std::endl
83 <<
"Otsu : " <<
otsu << std::endl
85 <<
"Probabilistic: " <<
do_prob << std::endl
97 addParamsLine(
" dalton_mass <mass> <Tm=1> : Mass in daltons");
103 addParamsLine(
" prob <radius=-1> : Probabilistic solvent mask (typical value 3)");
104 addParamsLine(
" : Radius [pix] is used for B.C. Wang cone smoothing");
120 std::cout << std::endl <<
"Derived voxel_mass=" <<
voxel_mass << std::endl;
134 (*V_out)() = (*V_in)();
135 (*V_out)().
threshold(
"below", threshold, threshold);
136 (*V_out)().binarize(threshold);
140 std::cout << threshold << std::endl;
143 save.
write(
"PPP0.vol");
145 save.
write(
"PPP1.vol");
151 aux().initZeros((*V_out)());
157 save.
write(
"PPP2.vol");
170 std::cout << count << std::endl << std::endl;
171 std::cout <<
"Press any key\n";
192 double radius2 = radius * radius;
195 (*V_out)().initZeros((*V_in)());
202 for (
int kp =
k - radius; kp <
k + radius; kp++)
206 for (
int ip =
i - radius; ip <
i + radius; ip++)
210 for (
int jp =
j - radius; jp <
j + radius; jp++)
214 r2 = (kp -
k) * (kp -
k) + (ip -
i) * (ip -
i) + (jp -
j) * (jp -
j);
215 if ((r2 < radius2) && (
A3D_ELEM(mVin, kp, ip, jp) > 0.))
217 weight = 1. -
sqrt(r2 / radius2);
237 double Np, sump, sum2p, Ns, sums, sum2s;
238 double avgp, sigp, avgs, sigs, aux, solv_frac, prot_frac;
239 double p_prot, p_solv;
244 mVout.setXmippOrigin();
246 Np = sump = sum2p = Ns = sums = sum2s = 0.;
263 if (Np > 0. && Ns > 0.)
266 sigs = sum2s / Ns - avgs * avgs;
268 sigp = sum2p / Np - avgp * avgp;
269 prot_frac = Np / (Np + Ns);
270 solv_frac = 1. - prot_frac;
279 double isigs=-1/(2.0*sigs);
280 double isigp=-1/(2.0*sigp);
284 aux = voxelVal - avgs;
285 p_solv = solv_frac * exp(aux * aux * isigs);
286 aux = voxelVal - avgp;
287 p_prot = prot_frac * exp(aux * aux * isigp);
288 A3D_ELEM(mVout,
k,
i,
j) = p_prot / (p_prot + p_solv);
295 double th_min, th_max, val_min=0., val_max=0.;
296 V().computeDoubleMinMax(val_min, val_max);
309 double th_med = (th_min + th_max) * 0.5;
311 std::cout <<
"Threshold= " << th_med
312 <<
" mass of the main piece= " << mass_med << std::endl;
318 if ((th_max - th_min) / (val_max - val_min) < 0.0001)
336 <<
" mass of the main piece= " << mass_med << std::endl;
345 std::cout <<
"Threshold " << th << std::endl;
366 std::cout <<
"Segment: Cannot find an appropriate threshold\n";
double getDoubleParam(const char *param, int arg=0)
#define REPORT_ERROR(nerr, ErrormMsg)
void wang_smoothing(const Image< double > *V_in, Image< double > *V_out, int radius)
void sqrt(Image< double > &op)
void probabilistic_solvent(Image< double > *V_in, Image< double > *V_out)
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
String method
Segmentation method.
FileName fn_mask
Output mask. If not given it is not written.
bool en_threshold
Enable a single threshold measure.
void segment(Image< double > &mask)
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
#define A3D_ELEM(V, k, i, j)
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
void opening3D(const MultidimArray< double > &in, MultidimArray< double > &out, int neig, int count, int size)
void closing3D(const MultidimArray< double > &in, MultidimArray< double > &out, int neig, int count, int size)
const char * getParam(const char *param, int arg=0)
void readParams()
Read arguments.
double EntropyOtsuSegmentation(MultidimArray< double > &V, double percentil, bool binarizeVolume)
double segment_threshold(const Image< double > *V_in, Image< double > *V_out, double threshold, bool do_prob)
Error related to numerical calculation.
double threshold
Threshold.
FileName fn_vol
Input volume.
double aa_mass
Desired mass (in aminoacids). Not necessary if voxel_mass is provided.
double sampling_rate
Sampling rate (in A/pixel). Not necessary if voxel_mass is provided.
void defineParams()
Define parameters.
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
double dalton_mass
Desired mass (in Daltons). Not necessary if voxel_mass is provided.
int wang_radius
radius for B.C. Wang-like smoothing procedure
int labelImage3D(const MultidimArray< double > &V, MultidimArray< double > &label)
int getIntParam(const char *param, int arg=0)
Incorrect value received.
void addParamsLine(const String &line)
bool do_prob
From here on by Sjors.