Commit dd874428 authored by myron's avatar myron

automatisation of the double flat field

parent 0098ea75
......@@ -5296,7 +5296,7 @@ void CCspace_preprocess_chunk(CCspace * self , int sn, int ntok, int ntokt ,
// #pragma omp parallel for private(i,j) num_threads (ncpus)
for(i=0; i<Size0; i++) {
for(j=0; j< Size1; j++) {
Rawptr[i*Size1 +j] = Rawptr [i*Size1 +j] - DFptr[ (i+Pos0)*gdim1 +(j+Pos1 ) ];
Rawptr[i*Size1 +j] = Rawptr [i*Size1 +j] + DFptr[ (i+Pos0)*gdim1 +(j+Pos1 ) ];
}
}
}
......@@ -5861,7 +5861,13 @@ void CCspace_InterleavedReadingPreProcessing_chunk(CCspace * self ,int sn,int
// for (i = 0; i < self->nprocs; i++) nelems_total += self->ff2_nels_process[i];
for(i=0; i<Size0*Size1; i++) self->ff2_globalmean[i] /= self->params.nprojs_span; // TODO: running mean
// Write this in edf
write_data_to_edf(self->ff2_globalmean, Size0, Size1, "projectionsmean.edf");
{
char name[10000];
sprintf(name,"%s/projectionsmean.edf", dirname(self->params.OUTPUT_FILE) ) ;
write_data_to_edf(self->ff2_globalmean, Size0, Size1, name);
}
if (self->params.verbosity >= 10) puts("wrote projectionsmean.edf");
float sigma = self->params.FF2_SIGMA;
......@@ -5959,9 +5965,15 @@ void CCspace_InterleavedReadingPreProcessing_chunk(CCspace * self ,int sn,int
for (i = 0; i < Size0*Size1; i++) self->ff2_globalmean[i] = ff2_projmean_old[i] - (self->ff2_globalmean)[i]; //self->ff2_globalmean[i] -= ff2_projmean_old[i];
// Write
write_data_to_edf(self->ff2_globalmean, Size0, Size1, "projectionsmean_filt.edf");
// write_data_to_edf(ff2_gaussian, 1, gsize, "gaussian.edf");
if (self->params.verbosity >= 10) puts("wrote projectionsmean_filt.edf");
{
char name[10000];
sprintf(name,"%s/projectionsmean.edf", dirname(self->params.OUTPUT_FILE) ) ;
write_data_to_edf(self->ff2_globalmean, Size0, Size1, name);
if (self->params.verbosity >= 10) puts("wrote projectionsmean.edf");
}
free(ff2_projmean_old);
free(ff2_gaussian);
......
......@@ -939,8 +939,9 @@ class Parameters:
after FF correction. The origin of this residual error can be the effect of
several causes, for example a detector non-linearity.
If let to zero, no correction is done. If set to a string ("filename" with quotes)
then one image is read from the double-ff EDF file indicated in the string.
If let to zero, no correction is done. If set to 1 then
one image is read from the double-ff EDF file name projectionsmean.edf residing in the same directory as the output file.
If the file is not there, it is generated first and then used for the reconstruction
The image must contain the logarithm of the correction factor. The data is
subtracted from the treated projection.
"""
......@@ -950,7 +951,6 @@ class Parameters:
This parameter is similar to DOUBLEFFCORRECTION, but the double flat field is computed on the fly.
Mind that if DOUBLEFFCORRECTION_ONTHEFLY > 0, then we should have DOUBLEFFCORRECTION = 0.
In the current version, this parameter does not work for helical tomography.
If DOUBLEFFCORRECTION_ONTHEFLY is not zero, all the projections are averaged.
A file "projectionsmean.edf" is generated.
This file is used as a double flat-field correction.
......@@ -2049,6 +2049,19 @@ Units are pixels per projection.
exec(s)
DOUBLERUN4DFF=0
if DOUBLEFFCORRECTION:
dname = os.path.dirname(OUTPUT_FILE)
dd_path = os.path.join( dname,"projectionsmean.edf")
if not os.path.exists(dd_path):
DOUBLEFFCORRECTION = 0
DOUBLEFFCORRECTION_ONTHEFLY = 1
DOUBLERUN4DFF = 1
END_VOXEL_3 = START_VOXEL_3
else:
DOUBLEFFCORRECTION = dd_path
if LT_KNOWN_REGIONS_FILE != "":
ZEROOFFMASK=0
......@@ -2957,7 +2970,7 @@ def create_arrays_space_as_dictionary(proj_reading_dict):
ffcorr =numpy.zeros([ P.NUM_IMAGE_2, P.NUM_IMAGE_1 ],"f")
if( Parameters.TAKE_LOGARITHM):
ffcorr[:] = numpy.exp(ffcorr)
ffcorr[:] = numpy.exp(-ffcorr)
......
......@@ -481,14 +481,21 @@ def callpyhst(inputfile):
if SCHEDULER_TYPE != "SLURM":
args= [mpi_extra,rshagent, machinefile_name, nprocs, "pyhst_2_"+myversion ] + [inputfile]+sys.argv[2:]
seguito = " %s "*len(sys.argv[1:])
comando = ("mpirun %s --mca mpi_warn_on_fork 0 --mca orte_rsh_agent %s -machinefile %s -n %d %s "+seguito) % tuple(args)
comando = ("mpirun %s --mca mpi_warn_on_fork 0 --mca orte_rsh_agent %s -machinefile %s -n %d %s "+seguito) % tuple(args)
print( comando +" " +gpus_string)
os.system( "for nvar in `awk 'BEGIN{for(v in ENVIRON) print v}' | grep MPI` ; do unset $nvar ; done ; " + comando+" " +gpus_string)
if P.DOUBLERUN4DFF:
print(" SECOND RUN FOR DOUBLE FF ")
os.system( "for nvar in `awk 'BEGIN{for(v in ENVIRON) print v}' | grep MPI` ; do unset $nvar ; done ; " + comando+" " +gpus_string)
else:
args= [nprocs, "pyhst_2_"+myversion ] + [inputfile]+sys.argv[2:]
seguito = " %s "*(len(args)-2)
comando = ("mpirun -n %d %s "+seguito) % tuple(args)
os.system( comando+" " +gpus_string)
if P.DOUBLERUN4DFF:
print(" SECOND RUN FOR DOUBLE FF ")
os.system( comando+" " +gpus_string)
if(sys.argv[0][-12:]!="sphinx-build"):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment