From 2bfc0be4a981c75bd57ac2e316f99526bcdca7bd Mon Sep 17 00:00:00 2001 From: Andrew Jewett Date: Sat, 11 Sep 2021 13:11:15 -0700 Subject: [PATCH] fixed a minor bug in the -save-progress and -load-progress arguments. Updated some documentation. --- bin/filter_mrc/filter_mrc.cpp | 4 +-- bin/filter_mrc/handlers.cpp | 2 +- bin/filter_mrc/settings.cpp | 6 ++++ doc/doc_filter_mrc.md | 59 ++++++++++++++++++++--------------- lib/mrc_simple/mrc_simple.cpp | 4 +-- 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/bin/filter_mrc/filter_mrc.cpp b/bin/filter_mrc/filter_mrc.cpp index c0231c6..ab8402c 100644 --- a/bin/filter_mrc/filter_mrc.cpp +++ b/bin/filter_mrc/filter_mrc.cpp @@ -29,8 +29,8 @@ using namespace std; string g_program_name("filter_mrc"); -string g_version_string("0.29.17"); -string g_date_string("2021-9-10"); +string g_version_string("0.29.18"); +string g_date_string("2021-9-11"); diff --git a/bin/filter_mrc/handlers.cpp b/bin/filter_mrc/handlers.cpp index 2143255..c10fe42 100644 --- a/bin/filter_mrc/handlers.cpp +++ b/bin/filter_mrc/handlers.cpp @@ -1711,7 +1711,7 @@ HandleTV(const Settings &settings, } } } - cerr << " -- sorting ALL voxels by ridge saliency --\n" << endl; + cerr << " -- sorting all voxels by ridge saliency --\n" << endl; vector saliencies(n_voxels); size_t i = 0; for (int iz=0; iz < image_size[2]; iz++) { diff --git a/bin/filter_mrc/settings.cpp b/bin/filter_mrc/settings.cpp index 9062cc0..ecf41ee 100644 --- a/bin/filter_mrc/settings.cpp +++ b/bin/filter_mrc/settings.cpp @@ -280,6 +280,9 @@ Settings::ParseArgs(vector& vArgs) // Now save all the current command line arguments into the INFO file. fstream f; f.open(save_intermediate_fname_info, ios::out); + if (! f) + throw VisfdErr("Error: Unable to open \"" + + save_intermediate_fname_info +"\" for writing.\n"); for (int j = 1; j < vArgs.size(); j++) { if ((j == i) || (j == i+1)) continue; // omit the "-save-progress filename" arguments @@ -324,6 +327,9 @@ Settings::ParseArgs(vector& vArgs) // Now load the arguments that were in the INFO file. fstream f; f.open(load_intermediate_fname_info, ios::in); + if (! f) + throw VisfdErr("Error: Unable to open \"" + + load_intermediate_fname_info +"\" for reading.\n"); vector new_args; string line; while (getline(f, line, '\n')) diff --git a/doc/doc_filter_mrc.md b/doc/doc_filter_mrc.md index b38339e..6ab0b44 100644 --- a/doc/doc_filter_mrc.md +++ b/doc/doc_filter_mrc.md @@ -195,16 +195,45 @@ filter_mrc -in tomogram.rec \ -connect 1.0e+09 -connect-angle 15 \ -select-cluster 1 -normals-file largest_membrane_pointcloud.ply ``` -Note: +This will generate a new file ("largest_membrane_pointcloud.ply") +containing a list of points located on the largest surface. +You can use +[*SSDRecon*](https://github.com/mkazhdan/PoissonRecon) +to load this file and close the holes in the surface. (See below.) + +**Note:** Here I assumed that the user has already followed the instructions in [example 1](#Example-1). (Consequently, to save time, we used the ["-load-progress"](#-load-progress-FILENAME) to argument to skip over the time consuming process of detecting the membrane again.) -This will generate a new file ("largest_membrane_pointcloud.ply") -containing a list of points located on the largest surface. You can use -[*SSDRecon*](https://github.com/mkazhdan/PoissonRecon) -to load this file and close the holes in the surface: + +**Note:** +All of these parameters make reasonably good +defaults for membrane detection except the +["**-connect**"](#-connect-threshold) +parameter ("1.0e+09" in the example). +It must be chosen carefully because it will vary from image to image. +Strategies for choosing this parameter are discussed +[below](#determining-the--connect-threshold-parameter). +Repeat the step above with different parameters until the resulting +"membranes_clusters.rec" shows that the different surface fragments +have merged into larger surfaces correctly. +(Verify this by opening the file in 3dmod, clicking on different portions +of the dark surface that you care about, pressing the "F" key each time, +and checking that the resulting ID numbers match.) +If a suitable parameter can not be found that merges the membrane +fragments togethe, you can also use the +["**-must-link**"](#-must-link-FILE) +argument to manually force connections between +disconnected surface fragments. (See below.) +You can also *modify* the image to erase or mask problematic regions (using the +[-draw-spheres](#-draw-spheres-filename), or +[-mask-rect-subtract](#-mask-rect-subtract-xmin-xmax-ymin-ymax-zmin-zmax), and +[-mask-sphere-subtract](#-mask-sphere-subtract-x0-y0-z0-r) arguments). + +Now use [*SSDRecon*](https://github.com/mkazhdan/PoissonRecon) +to load the PLY file we just created and close the holes in the surface: ``` SSDRecon --in largest_membrane_pointcloud.ply \ --out largest_membrane.ply --depth 12 --scale 2.0 @@ -251,26 +280,6 @@ filter_mrc -i segmented.rec -o segmented_interior.rec -erosion 50.0 to see what works best.) - -**Note:** -All of these parameters make reasonably good -defaults for membrane detection except the -["**-connect**"](#-connect-threshold) -parameter ("1.0e+09" in the example). -It must be chosen carefully because it will vary from image to image. -Use the "-load-progress FILENAME" argument to save time -while experimenting with different thresholds. -Strategies for choosing this parameter are discussed -[below](#determining-the--connect-threshold-parameter). -If a suitable parameter can not be found, you can also use the -["**-must-link**"](#-must-link-FILE) -argument to manually force connections between -disconnected regions. (See below.) -You can also *modify* the image to erase or mask problematic regions (using the -[-draw-spheres](#-draw-spheres-filename), or -[-mask-rect-subtract](#-mask-rect-subtract-xmin-xmax-ymin-ymax-zmin-zmax), and -[-mask-sphere-subtract](#-mask-sphere-subtract-x0-y0-z0-r) arguments). - Note: If the resulting surface is *not closed*, then try increasing the "--scale" parameter. diff --git a/lib/mrc_simple/mrc_simple.cpp b/lib/mrc_simple/mrc_simple.cpp index cd62c84..bf96d68 100644 --- a/lib/mrc_simple/mrc_simple.cpp +++ b/lib/mrc_simple/mrc_simple.cpp @@ -182,7 +182,7 @@ void MrcSimple::Read(string in_file_name, fstream mrc_file; mrc_file.open(in_file_name, ios::binary | ios::in); if (! mrc_file) - throw MrcfileErr("Error: unable to open \""+ in_file_name +"\" for reading.\n"); + throw MrcfileErr("Error: Unable to open \""+ in_file_name +"\" for reading.\n"); // Try to infer signed-vs-unsigned integers from the file name: //http://www.cgl.ucsf.edu/pipermail/chimera-users/2010-June/005245.html if ((len_in_file_name > 4) @@ -354,7 +354,7 @@ void MrcSimple::Write(string out_file_name) { fstream mrc_file; mrc_file.open(out_file_name, ios::binary | ios::out); if (! mrc_file) - throw MrcfileErr("Error: unable to open \""+ out_file_name+"\" for writing.\n"); + throw MrcfileErr("Error: Unable to open \""+ out_file_name+"\" for writing.\n"); Write(mrc_file); // You can also use "mrc_file << tomo;" mrc_file.close(); }