Project

General

Profile

First-time autoscreening setup » History » Revision 2

Revision 1 (Anchi Cheng, 02/28/2022 08:24 PM) → Revision 2/17 (Anchi Cheng, 02/28/2022 10:44 PM)

h1. Smart-leginon multi-grid autoscreening 

 Automated square and hole finders are added to leginon to use Ptolemy (https://arxiv.org/abs/2112.01534) to determine optimal targets using computer vision algorithm and Convolutional Neural Network trained on user target selections accumulated at Simons Electron Microscopy Center at New York Biology Center (SEMC@NYSBC. 

 This implementation requires Ptolemy which has a separate license. For this release, the communication is through command line interface and rely on shared file system. 

 * At SEMC@NYSBC, Ptolemy, which was tested on python 3.9, runs in anaconda environment on the same CentOS7 computer where the main leginon process is. 

 h2. Square finding localization (localization and classification using MosaicExternalScoreFinder classification) 

 (node alias Square Finding) 

 h3. Setting up: 

 h4. Install Ptolemy according to its instruction 

 h4. Create a shell script to run Ptolemy lowmag_cli.py 

 * Within Leginon MosaicExternalScoreFinder instance defines, for each incoming gr image: 
 ** the shell script to run Ptolemy (user set it in *Blobs settings*) settings) 
 ** the mrc file path of the gr image leginon is currently processing as ptolemy input (leginon decides this for you) 
 ** the output json file path leginon will later look for the result. (leginon decision based on the imageid of the input mrc file.) decision) 

 Here is an example how we write this shell script sq_finding.sh 

 <pre> 
 #!/bin/sh -f 
 # Local runs 
 source /usr/local/anaconda3/etc/profile.d/conda.sh 
 conda activate /opt/condaenvs/ptolemy_env 
 # variable 1 is the outputname without json extension. 
 # variable 2 is the input mrc path 
 echo $1 
 echo $2 
 mrc_path=$2 
 python /home/your_name/packages/ptolemy/lowmag_cli.py /home/your_name/site-packages/ptolemy/lowmag_cli.py -f json $2 > $1 
 conda deactivate 
 # mv the result to leginon session rawdata directory 
 mv $1 ${mrc_path%%rawdata/*}rawdata/$1.json 
 echo ${mrc_path%%rawdata/*}rawdata/$1.json 
 </pre> 

 Test example, assuming you have /data/leginon/22feb28a/rawdata/22feb28a_00001gr.mrc, you can test ptolemy with 
 <pre> 
 ./sq_finding.sh test_1 /data/leginon/22feb28a/rawdata/22feb28a_00001gr.mrc 
 </pre> 
 Output test_1.json should end up in /data/leginon/22feb28a/rawdata/ 

 h3. Upload MSI-Ptolemy application into leginon database 

 Follow the instruction in [[Applications|web application tools]] 
 * Note: If your system needs two Leginon client opened, each on a different pc, use MSi-Ptolemy2.xml 

 If you have your own application you can do the following replacement by [[Use_the_Application_Editor_to_create_Leginon_applications|editing your application]] : 

 Square Targeting Node : MosaicClickTargetFinder class => MosaicScoreTargetFinder 
 Exposure Targeting Node: JAHCFinder => ScoreTargetFinder 

 h3.    Define target area size sampling in Leginon 

 Do this in the settings next to "acquisition" target panel.    Enter 

 # Maximal number of squares to select 
 # Number of target group to sample 

 For example, total of 12 squares selected in 3 groups means the program divided out all blob squares with valid area range into 3 size group (small, medium,and large).    It then choose 4 blob squares in each group with highest score given by Ptolemy as the output square targets.    High score in Ptolemy result means it is more likely to be a good square. 

 h4. Set the limits of square area range 

 This is set in "Thresholded" settings.    However, it is easier to set by select examples once you acquire your first grid atlas in this node.