Difference: Matlab (11 vs. 12)

Revision 1212 May 2011 - Main.NicolasCoudray

 
META TOPICPARENT name="TemimpsGroup"

Automation of jeol1230 with iRobot, Leginon and Animated-TEM

Contents

Startup

User manual to use Leginon combined with the Matlab nodes associated to the Animated-TEM Toolbox algorithms at NYSBC: NYSBC-AutoRuns_Protocols_4.doc.

Tracking Developments

Installation

Matlab2009b , Leginon (/usr/lib/python2.4/site-packages/leginon/) and mlabwrap are installed on minotaur (ex-cem12 computer) .
Leginon is also installed on jeol1230.
Databases are installed on cem100. Accessible from minotaur through "/cem100/data/leginon/j1230" or "/cem100data/leginon/j1230".
iRobot is installed on the robot computer.
Leginon can either be totally launched from jeol1230 with any non-Matlab Leginon application, or both from jeol1230 (as client) and minotaur (as main program).

see LeginonUpdate for other details about installation.

Matlab applications under Leginon

  • v0.2 works with target selections at low and medium magnifications using Matlab. The filtering nodes are however useless. The magnifications are the same as in the "Robot MSI-Screen 1st Pass 1.6" application.
  • v0.3:
    • Nodes have new specific names.
    • Filtering nodes removed.
    • High Mag processing added (with a dummy "Very High Mag" node after it to avoid errors).
  • v0.4b:
    • Nodes have new specific names.
    • Focusing added before High magnification

Leginon program modifications

History of files modified: Leginon_File_History.tar.gz.

!! THE FILES MODIFIED HAVE ONLY BEEN UPDATED ON CEM12 SO FAR, AND NOT ON JEOL1230 (as of Feb, 24th) !!

for communication with Matlab

  • original file: matlabtargetfinder.py
    • 1st modif (matlabtargetfinder.py.MODIF_OK_1): convert images to float before sending them to Matlab (initially saved as "int", the mlabwrap interface does not recognize this type and send zeros instead of the true matrix)
    • 2nd modif (matlabtargetfinder.py.MODIF_OK_2): same as version 1, but more complete (works wether the prog is called off-line on a test image or on-line).

to send a new input to Matlab

  • previous vcersion: "matlabtargetfinder.py.MODIF_OK_2" file
    • 3rd modif (matlabtargetfinder.py.MODIF_OK_F2): send image ID to Matlab as well + code to transform from int to float better (from Jim and Anchi's advices)

to modify the GUI of Leginon (Set Parameters) so that a Matlab GUI can be launched to parametrize the algorithms (see http://ami.scripps.edu/redmine/boards/6/topics/884?r=890#message-890)

  • original file: "leginondata.py.ORIG"
    • 1st modif: leginondata.py.MODIF_OK_1; new input declared (parametergui path)
  • and original file: "/gui/wx/MatlabTargetFinder.py.ORIG"
    • 1st modif: "/gui/wx/MatlabTargetFinder.py.MODIF_1_OK": add components to browse the Matlab GUI, and a button to launch it.

autofocusing -- to reduce false correlation peak detection during the autofocusing steps in cross-correlation mode (phase-correlation not corrected)

  • original file: "calibrationclient.py.ORIG"
    • modif: "calibrationclient.py.MODIF_1" The file has been modified to activate a Gaussian smoothing before searching for the peak (in the def measureZ function, shiftinfo = self.measureScopeChange(im1, state2, correlation_type=correlation_type, lp=1) changed to shiftinfo = self.measureScopeChange(im1, state2, correlation_type=correlation_type, lp=1)), and do a median filter for "isolated" pixels with high gray level .

example of command to update a python file of Leginon:

sudo cp /home/ncoudray/Desktop/Matlab_leginon_protocol/matlabtargetfinder.py.MODIF_OK_F2 /usr/lib/python2.4/site-packages/leginon/matlabtargetfinder.py

autofocusing -- Beam-tilt method

  • jeol1230.py, line 333 corrected from "_return Ture_" to "_return True_"
  • Beam tilt for jeol1230 has not been implemented... For the moment, no conversion has been done from radian jeol's decimal value. To see a beam tilt, tilt value should be above 1000. Calibration has been done with 5000. During the run, for the moment, 2000 can be used.

autofocusing -- New method based on Contrast Function * Measure the relative contrast of images taken around current focus and look for defocus at which the contrast function is maximized: cf modification in the file Focuser.py

Animated-TEM-4L

Animated-TEM-4L (ANalysis of IMages for Automatic Targeting and Extraction of Data in TEM - For Leginon) is adapted from Animated-TEM. It does not work as "master" which decides when, where and how images should be acquired. Therefore, "Anim_Scenario.m" previously used to call the different algorithms and program is not used anymore. Instead, it launched by Leginon when needed and outputs its target selection. Algorithms are quite similar (a few adaptations concerning the parameters and the methods have been done). GUI are not longer usable "as they are".

Specific ".m" file have been created for each magnification: these are the files called by Leginon and they link to the required algorithm, embedding it with the required inputs and managing the outputs (saving and sending the appropriate to Leginon):

  • at low magnification algorithm, the intermediate file is called, for the moment (Feb 04), "Test_LowMagTargeting_v0_1.m".
  • at medium magnification algorithm, the intermediate file is called, for the moment (Feb 04), "MedMagTargeting_v0_1.m".

Saving the extracted data:
Also, the way the data were saved had to be changed:

  • initially, one folder was dedicated to images, logfiles and data. In Animated-TEM-4L, we use a mysql database. "SaveLowMagData.m" and "SaveMedMagData.m" have been completed to save data extracted by the algorithm into a new mysql database (One new input "TVersion" tells which way the data must be saved. It has been rewritten so that these two files can be used by both Animated-TEM. "Anim_Scenario.m" has been corrected to include this new "TVersion" input).
  • The database is called "AnimatedTem" (see below for more information).

Management of the parameters:

  • Specific parameters are still located in "AllInitialParameters.m". They have been adapted to suit images acquired so far with the jeol1230.
  • Other user-changeable parameters were previously managed through "AnIm_Param.m" which created a "Acq_Param.txt" file specific for each run according to the settings chosen by the user through the Launcher GUI. Instead, a new strategy has been chosen here: "AnIm_4L_Param.m" file replaces "AnIm_Param.m". Some parameters have been removed (mainly those specific to the command of the microscope), others remain quite similar (those related to the algorithms), other have been added (those related to the databases). Furthermore, instead of saving the current parameters in a text file, a mysql datase called "AnimatedTem" has been created (on cem100, see next point).

GUI:

  • "Anim4L_Calibration.m": replace the launcher to changed the default values for the parameters used by the algorithm. When saved, data are placed at the last row of the RunParameters table of the AnimatedTem database.
  • "Grid_N_Cassette_Overview.m": displays, for a given session, the results saved in the AnimatedTem database.

Some algorithm modifications:

  • Low Mag
    • Jan-Feb 2011: slight auto-threshold adaptation (SortAllSquaresGrayLevels.m file)
    • March 3rd 2011: Pause the run if superposed grids are detected (LowMagnificationSpeed_AnIm.m file)
  • Med Mag
    • Jan-Feb 2011: Adaptation of the parameters for the automated process (AllInitialParameters.m file_: scales used, edge filter) + correction of "parameters checking" in MultiScale_vMP3.m [cf ThreshAlgo variable]
    • Feb 2011: do not restrain research to monolayer. Bi-Layer also included under certain conditions
    • Feb 2011: in MultiScale_vMP3.m , the way to measure
      • the background percentage slightly changed (a second background threshold is included)
      • the non-stacked percentage slightly changed (mono-layer & partly bi-layer)
      • the average rank of each regions slightly changed (option "RankProportional" to include a proportionality of adjust the rank according to the importance of the parameter's value)
    • Mar 2011: in MultiScale_vMP3.m, the way to remove the false edges:
      • Threshold (OPTIONS.Thresh) moved back from 10 to 8 (less edges removed)
      • Do not remove edges iteratively if more than 2000 regions are identified (save processing time)

Matlab database

Database used by Animated-TEM-4L to store its data.

General information:

  • located on cem100
  • name: AnimatedTem
  • user name: usr_object
  • password:
  • driver: com.mysql.jdbc.Driver (must have been installed on the cem12)
  • url: jdbc:mysql://192.168.5.233/

Tables and columns (as of 2011/02/04):

  • RunParameters: store parameters used by the algorithms. Parameters can be changed by the user (see above). By default, the algorithms always consider the last entry of the table as the one which should be used!!!! Name of the columns begin with LM when the parameter is related to the algorithm used at low mag, with MM for the algo used at medium mag, with HM for the algo used at high mag.
DEF_id INT UNSIGNED NOT NULL AUTO_INCREMENT unique identifier incremented automatically
LM_Algorithn TEXT Algorithm used at low magnification default: Grid_Square_Selection
LM_MaxTargetPerFoV INT maximum number of targets per field of view (per images acquired at low mag) default: 2
LM_AreaThreshold INT percentage of the targeted grid which should be seen at low mag default: 80
MM_Algorithn TEXT Algorithm used at medium magnification default: 2D_Crystal_Analysis
MM_TargetMinDiameter DOUBLE min diameter expected of the targeted object (in nm) default: 500
MM_TargetMaxDiameter DOUBLE max diameter expected of the targeted object (in nm) default: 7000
MM_TargetSizeFactor DOUBLE importance of the size of the object when the target is chosen (largest objects will be preferred if this value is large) default: 4
MM_TargetLinearityFactor DOUBLE importance of the linearity of the edges of the object when the target is chosen (objects with linear edges will be preferred if this value is large) default: 4
MM_TargetContrastFactor DOUBLE importance of the contrast of the object when the target is chosen (objects with higher contrast will be preferred if this value is large) default: 8
MM_TargetGrayLevelFactor DOUBLE importance of the gray level of the object when the target is chosen (objects close to the average gray level of objects will be preferred if this value is large) default: 1
MM_NbrTargetMultiR DOUBLE maximum number of target chosen with the multi-resolution method (above parameters are taking into account) default: 3
MM_NbrTargetPED INT maximum number of target chosen with the PED algorithm (above parameters are not taken into account) default: 1
HM_Algorithn TEXT Algorithm used at high magnification default: Diffraction_Spots_Detection
HM_SpotMaxResolution TEXT Maximum resolution (in nm^-1) at wich a diffraction spot is expected default: 2
HM_SpotMinResolution TEXT Minimum resolution (in nm^-1) at wich a diffraction spot is expected default: 15
HM_SpotMinSNR TEXT Signal to Noise Ratio used to identidy diffraction spots default: 3.5
N.B.: For each magnification, the algorithm used can be modified. For the moment, only one algorithm per mag is implemented. If other algorithms need to be implemented, and you want to add it in the toolbox with the "same" phylosophy, then:
    • if other parameters than the ones above are required to set the algorithm:
      • then, the required columns should be added in the database.
      • "AnIm_4L_Param.m" file should be completed so that, when it reads the RunParameters table of the database, the added columns are recognized (once checked, parameters are transmitted to the different algorithm through a structure called "Parameters". To avoid adding additional inputs and outputs, just complete this structure (see code for examples)).
    • to add the algorithm itself:
      • Choose a name and complete the "AnIm_4L_Param.m" file so the name of your algo is recognized (complete the "AcceptedValues" cell with this name for the appropriated magnification).
      • Add the link to your file with the appropriate name chosen above, the appropriate inputs and outputs in the corresponding file (LowMagTargeting_, MedMagTargeting_, or HighMAgAnalysis_; see instructions around "if strcmp...").
    • to save new outputs in the database:
      • Complete one of the tables below and the corresponding m file ("SaveLowMagData.m", "SaveMedMagData" or "SaveHighMagData")

  • GridMag: store the data outputs by the algorithm at low mag
DEF_id INT UNSIGNED NOT NULL AUTO_INCREMENT unique identifier
REF|AcquisitionImageData|image INT unique identifier of the image in the Leginon database
REF|RunParameters|run INT unique identifier of the parameters (in the RunParameters table) used to process this image
X_Target BLOB X-coordinates of the selected targets
Y_Target BLOB Y-coordinates of the selected targets
NbrGoodQuality INT Number of grid squares assessed as good for medium mag analysis
NbrGridSquares INT Number of grids squares observed
PixelSize DOUBLE pixel size in nm
cur_timestamp TIMESTAMP DEFAULT NOW() time at which the process finished
ErrorMessage TEXT message returned if an error occured during the image processing step
InSituProcessing TINYINT(3) 0: if data from image processed off-line only; 1: if on-line only; 2: if on-line, then, modified off-line; 3: unsure

  • MembraneMag: store the data outputs by the algorithm at medium mag
DEF_id INT UNSIGNED NOT NULL AUTO_INCREMENT unique identifier
REF|AcquisitionImageData|image INT unique identifier of the image in the Leginon database
REF|RunParameters|run INT unique identifier of the parameters (in the RunParameters table) used to process this image
Flag INT flag to identify if error occurs during the processing
ErrorMessage TEXT Message received if an error occurred during the processing
PixelSize DOUBLE pixel size
X_Target BLOB X-coordinates of the selected targets
Y_Target BLOB Y-coordinates of the selected targets
SpecimenAreas BLOB areas of the individual objects identified
SpecimenMaxDiameters BLOB max diameters of the individual objects identified
SpecimenMinDiameters BLOB min diameters of the individual objects identified
SpecimenSolidity BLOB solidity of the individual objects identified
AmountLinearEdges BLOB value proportional to the amount of linear edges
AmountCircularEdges BLOB value proportional to the amount of circular edges
AmountOtherEdges BLOB value proportional to the amount of non-linear and non-circular edges
StackAreas BLOB areas of the stacks
StackMaxDiameters BLOB max diameters of the stacks
StackMinDiameters BLOB min diameters of the stacks
StackSolidity BLOB solidity of the stacks
MonoLayerPercent DOUBLE Percentage of foreground being considered as the lowest stacked
ForegroundPercent DOUBLE Percentage of image being considered as foreground
cur_timestamp TIMESTAMP DEFAULT NOW time at which the process finished
InSituProcessing TINYINT(3) 0: if data from image processed off-line only; 1: if on-line only; 2: if on-line, then, modified off-line; 3: unsure
N.B.: BLOB are used to save vectors of data. However, since they are coded on 8 bits only, values are not stored directly but have been coded (in Decimal ASCII values --> value of each digit + 48 stored; and value 32 for spaces)!

  • [Another one should be created if diffraction patterns are analyzed at high magnification]: StructureMag:
DEF_id INT UNSIGNED NOT NULL AUTO_INCREMENT unique identifier
REF|AcquisitionImageData|image INT unique identifier of the image in the Leginon database
REF|RunParameters|run INT unique identifier of the parameters (in the RunParameters table) used to process this image
Flag INT flag to identify if error occurs during the processing
ErrorMessage TEXT Message received if an error occurred during the processing
X_SpotsCoordinates BLOB X-coordinates of the identified diffraction spots
Y_SpotsCoordinates BLOB Y-coordinates of the identified diffraction spots
NbrOfPeaks INT Number of diffraction spots identified
PeakResolution BLOB Resolution of the peaks identified
PixelSize DOUBLE pixel size in nm
cur_timestamp TIMESTAMP DEFAULT NOW() time at which the process finished
InSituProcessing TINYINT(3) 0: if data from image processed off-line only; 1: if on-line only; 2: if on-line, then, modified off-line; 3: unsure

  • Set ALLOWTOPICVIEW =

-- NicolasCoudray - 14 Apr 2011

META FILEATTACHMENT attr="" autoattached="1" comment="" date="1304112581" name="2011_04_28-Leginon_modifications.tar.gz" path="2011_04_28-Leginon_modifications.tar.gz" size="29787" user="Main.NicolasCoudray" version="1"
Changed:
<
<
META FILEATTACHMENT attr="" autoattached="1" comment="" date="1302789708" name="NYSBC-AutoRuns_Protocols_4.doc" path="NYSBC-AutoRuns_Protocols_4.doc" size="1658368" user="Main.NicolasCoudray" version="1"
>
>
META FILEATTACHMENT attachment="NYSBC-AutoRuns_Protocols_4.doc" attr="" comment="" date="1305235850" name="NYSBC-AutoRuns_Protocols_4.doc" path="NYSBC-AutoRuns_Protocols_4.doc" size="3098624" stream="NYSBC-AutoRuns_Protocols_4.doc" user="Main.NicolasCoudray" version="2"
 
META FILEATTACHMENT attr="" autoattached="1" comment="" date="1304112590" name="Leginon_File_History.tar.gz" path="Leginon_File_History.tar.gz" size="70359" user="Main.NicolasCoudray" version="2"
 
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding this intranet, Send feedback