Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 55 additions & 5 deletions src/displayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ int DisplayBox::unSelect()
int basisViewerWindow::fillCanvas(int viewer_type, MetaDataTable &MDin, ObservationModel *obsModel, EMDLabel display_label, EMDLabel text_label, bool _do_read_whole_stacks, bool _do_apply_orient,
RFLOAT _minval, RFLOAT _maxval, RFLOAT _sigma_contrast, RFLOAT _scale, RFLOAT _ori_scale, int _ncol, long int max_nr_images, RFLOAT lowpass, RFLOAT highpass, bool _do_class,
MetaDataTable *_MDdata, int _nr_regroup, bool _do_recenter, bool _is_data, MetaDataTable *_MDgroups,
bool do_allow_save, FileName fn_selected_imgs, FileName fn_selected_parts, int max_nr_parts_per_class)
bool do_allow_save, FileName fn_selected_imgs, FileName fn_selected_parts, int max_nr_parts_per_class, bool _show_fourier_amplitudes, bool _show_fourier_phase_angles)
{
// Scroll bars
Fl_Scroll scroll(0, 0, w(), h());
Expand Down Expand Up @@ -332,6 +332,8 @@ int basisViewerWindow::fillCanvas(int viewer_type, MetaDataTable &MDin, Observat
canvas.fn_selected_imgs= fn_selected_imgs;
canvas.fn_selected_parts = fn_selected_parts;
canvas.max_nr_parts_per_class = max_nr_parts_per_class;
canvas.show_fourier_amplitudes = _show_fourier_amplitudes;
canvas.show_fourier_phase_angles = _show_fourier_phase_angles;
canvas.fill(MDin, obsModel, display_label, text_label, _do_apply_orient, _minval, _maxval, _sigma_contrast, _scale, _ncol, _do_recenter, max_nr_images, lowpass, highpass);
canvas.nr_regroups = _nr_regroup;
canvas.do_recenter = _do_recenter;
Expand Down Expand Up @@ -579,6 +581,12 @@ void basisViewerCanvas::fill(MetaDataTable &MDin, ObservationModel *obsModel, EM
if (highpass > 0. && have_optics_group)
highPassFilterMap(img(), highpass, angpix);

if(this->show_fourier_amplitudes)
{
amplitudeOrPhaseMap(img(), img(), AMPLITUDE_MAP);
} else {
if(this->show_fourier_phase_angles) amplitudeOrPhaseMap(img(), img(), PHASE_MAP);
}
// Dont change the user-provided _minval and _maxval in the getImageContrast routine!
RFLOAT myminval = _minval;
RFLOAT mymaxval = _maxval;
Expand All @@ -604,6 +612,11 @@ void basisViewerCanvas::fill(MetaDataTable &MDin, ObservationModel *obsModel, EM
int xcoor = icol * xsize_box;

DisplayBox* my_box = new DisplayBox(xcoor, ycoor, xsize_box, ysize_box, "");
if(this->show_fourier_phase_angles)
{
myminval = -180.0;
mymaxval = 180.0;
}
my_box->setData(img(), MDin.getObject(my_ipos), my_ipos, myminval, mymaxval, _scale, false);
if (MDin.containsLabel(text_label))
{
Expand Down Expand Up @@ -717,15 +730,17 @@ int multiViewerCanvas::handle(int ev)
{ "Show Fourier phase angles (2x)" },
{ "Show helical layer line profile" },
{ "Show particles from selected classes" },
{ "Show Fourier amplitudes (2x) from selected classes" },
{ "Show Fourier phase angles (2x) from selected classes" },
{ "Set selection type" },
{ "Save selected classes" }, // idx = 14; change below when re-ordered!!
{ "Save selected classes" }, // idx = 16; change below when re-ordered!!
{ "Quit" },
{ 0 }
};

if (!do_allow_save)
{
rclick_menu[14].deactivate();
rclick_menu[16].deactivate();
}

const Fl_Menu_Item *m = rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0);
Expand Down Expand Up @@ -759,6 +774,10 @@ int multiViewerCanvas::handle(int ev)
setSelectionType();
else if ( strcmp(m->label(), "Show particles from selected classes") == 0 )
showSelectedParticles(current_selection_type);
else if ( strcmp(m->label(), "Show Fourier amplitudes (2x) from selected classes") == 0 )
showSelectedFourierAmplitudes(current_selection_type);
else if ( strcmp(m->label(), "Show Fourier phase angles (2x) from selected classes") == 0 )
showSelectedFourierPhaseAngles(current_selection_type);
else if ( strcmp(m->label(), "Save selected classes") == 0 )
{
saveBackupSelection();
Expand Down Expand Up @@ -1432,6 +1451,38 @@ void multiViewerCanvas::showSelectedParticles(int save_selected)
std::cout <<" No classes selected. First select one or more classes..." << std::endl;
}

void multiViewerCanvas::showSelectedFourierAmplitudes(int save_selected)
{
MetaDataTable MDpart;
makeStarFileSelectedParticles(save_selected, MDpart);
int nparts = MDpart.numberOfObjects();
if (nparts > 0)
{
basisViewerWindow win(MULTIVIEW_WINDOW_WIDTH, MULTIVIEW_WINDOW_HEIGHT, "Amplitudes in the selected classes");
win.fillCanvas(MULTIVIEWER, MDpart, obsModel, EMDL_IMAGE_NAME, text_label, do_read_whole_stacks, do_apply_orient, 0., 0., 0., boxes[0]->scale, ori_scale, ncol,
multi_max_nr_images, 0, 0, false, MDdata, nr_regroups, do_recenter, false, MDgroups,
do_allow_save, fn_selected_imgs, fn_selected_parts, max_nr_parts_per_class, true);
}
else
std::cout <<" No classes selected. First select one or more classes..." << std::endl;
}

void multiViewerCanvas::showSelectedFourierPhaseAngles(int save_selected)
{
MetaDataTable MDpart;
makeStarFileSelectedParticles(save_selected, MDpart);
int nparts = MDpart.numberOfObjects();
if (nparts > 0)
{
basisViewerWindow win(MULTIVIEW_WINDOW_WIDTH, MULTIVIEW_WINDOW_HEIGHT, "Phase angles in the selected classes");
win.fillCanvas(MULTIVIEWER, MDpart, obsModel, EMDL_IMAGE_NAME, text_label, do_read_whole_stacks, do_apply_orient, 0., 0., 0., boxes[0]->scale, ori_scale, ncol,
multi_max_nr_images, 0, 0, false, MDdata, nr_regroups, do_recenter, false, MDgroups,
do_allow_save, fn_selected_imgs, fn_selected_parts, max_nr_parts_per_class, false, true);
}
else
std::cout <<" No classes selected. First select one or more classes..." << std::endl;
}

void multiViewerCanvas::saveTrainingSet()
{
FileName fn_rootdir = "/net/dstore1/teraraid3/scheres/trainingset/";
Expand Down Expand Up @@ -2778,7 +2829,6 @@ void Displayer::initialise()
if ( (ZSIZE(img()) > 1) || (NSIZE(img()) > 1) )
REPORT_ERROR("Displayer::initialise ERROR: cannot display Fourier maps for 3D images or stacks!");
}

}

int Displayer::runGui()
Expand Down Expand Up @@ -2994,7 +3044,7 @@ void Displayer::run()
basisViewerWindow win(MULTIVIEW_WINDOW_WIDTH, MULTIVIEW_WINDOW_HEIGHT, fn_in.c_str());
win.fillCanvas(MULTIVIEWER, MDin, &obsModel, display_label, text_label, do_read_whole_stacks, do_apply_orient, minval, maxval, sigma_contrast, scale, ori_scale, ncol,
max_nr_images, lowpass, highpass, do_class, &MDdata, nr_regroups, do_recenter, fn_in.contains("_data.star"), &MDgroups,
do_allow_save, fn_selected_imgs, fn_selected_parts, max_nr_parts_per_class);
do_allow_save, fn_selected_imgs, fn_selected_parts, max_nr_parts_per_class, show_fourier_amplitudes, show_fourier_phase_angles);
}
else
{
Expand Down
9 changes: 8 additions & 1 deletion src/displayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class basisViewerWindow : public Fl_Window
RFLOAT _scale, RFLOAT _ori_scale, int _ncol, long int max_nr_images = -1, RFLOAT lowpass = -1.0 , RFLOAT highpass = -1.0,
bool do_class = false, MetaDataTable *MDdata = NULL,
int _nr_regroup = -1, bool do_recenter = false, bool _is_data = false, MetaDataTable *MDgroups = NULL,
bool do_allow_save = false, FileName fn_selected_imgs="", FileName fn_selected_parts="", int max_nr_parts_per_class = -1);
bool do_allow_save = false, FileName fn_selected_imgs="", FileName fn_selected_parts="", int max_nr_parts_per_class = -1, bool _show_fourier_amplitudes = false, bool _show_fourier_phase_angles = false);
int fillSingleViewerCanvas(MultidimArray<RFLOAT> image, RFLOAT _minval, RFLOAT _maxval, RFLOAT _sigma_contrast, RFLOAT _scale);
int fillPickerViewerCanvas(MultidimArray<RFLOAT> image, RFLOAT _minval, RFLOAT _maxval, RFLOAT _sigma_contrast, RFLOAT _scale, RFLOAT _coord_scale,
int _particle_radius, bool do_startend = false, FileName _fn_coords = "",
Expand All @@ -168,6 +168,11 @@ class basisViewerCanvas : public Fl_Widget
int ysize_box;
int xoff;
int yoff;
// Show Fourier amplitudes?
bool show_fourier_amplitudes;

// Show Fourier phase angles?
bool show_fourier_phase_angles;

// To get positions in scrolled canvas...
Fl_Scroll *scroll;
Expand Down Expand Up @@ -277,6 +282,8 @@ class multiViewerCanvas : public basisViewerCanvas
void makeStarFileSelectedParticles(int save_selected, MetaDataTable &MDpart);
void saveSelectedParticles(int save_selected);
void showSelectedParticles(int save_selected);
void showSelectedFourierAmplitudes(int save_selected);
void showSelectedFourierPhaseAngles(int save_selected);
void saveTrainingSet();
void saveSelected(int save_selected);
void saveBackupSelection();
Expand Down
15 changes: 14 additions & 1 deletion src/fftw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1700,14 +1700,27 @@ void amplitudeOrPhaseMap(const MultidimArray<RFLOAT > &v, MultidimArray<RFLOAT >
out.setXmippOrigin();
out.initZeros(XYdim, XYdim);
maxr2 = (XYdim - 1) * (XYdim - 1) / 4;
//Get maximum value for PS log-normalization. The normalisation of the transform is undone.
RFLOAT val_max = -99999;
unsigned long int size = MULTIDIM_SIZE(out);
FOR_ALL_ELEMENTS_IN_FFTW_TRANSFORM2D(Faux)
{
if ( (ip > STARTINGY(out)) && (ip < FINISHINGY(out))
&& (jp > STARTINGX(out)) && (jp < FINISHINGX(out))
&& ((ip * ip + jp * jp) < maxr2) )
{
if(FFTW2D_ELEM(Faux, ip, jp).abs()*size > val_max) val_max = FFTW2D_ELEM(Faux, ip, jp).abs()*size;
}
}
RFLOAT logOfMax = log10f(val_max+1.0f);
FOR_ALL_ELEMENTS_IN_FFTW_TRANSFORM2D(Faux)
{
if ( (ip > STARTINGY(out)) && (ip < FINISHINGY(out))
&& (jp > STARTINGX(out)) && (jp < FINISHINGX(out))
&& ((ip * ip + jp * jp) < maxr2) )
{
if (output_map_type == AMPLITUDE_MAP)
val = FFTW2D_ELEM(Faux, ip, jp).abs();
val = log10f(FFTW2D_ELEM(Faux, ip, jp).abs()*size+1.0f)/logOfMax;
else if (output_map_type == PHASE_MAP)
val = (180.) * (FFTW2D_ELEM(Faux, ip, jp).arg()) / PI;
else
Expand Down