Geotechlab The site of the Geotechnical Lab

How to

General software troubleshooting tips

1) Avoid spaces and punctuations in file names… many times they are not allowed.

2) Most of the codes use the English numerals notation: . (dot) as decimal point and, (comma) to separate each group of three digits. Please modify the international options of your OS before starting to use any kind of program.

This is a list of my popular  “How to…” classified by program:


A collection of the popular FAQ:


  • How to save xy image coordinates from selected points?
    open ImageJ, open the selected image, press the “Point or Multi-point selection” button, press and hold down the Shift key and click on the image. Select Analyze -> Measure (sometimes is necessary to check the measurements properties in Analyze -> Set Measurements and disable all options). Edit -> Select All and paste in Excel (check the international options for the floating-point conversions)
  • How to save xy image coordinates from a selected polyline?
    Prepare the macro List XY Coordinates as:
macro "List XY Coordinates" {
     getSelectionCoordinates(x, y);
     for (i=0; i<x.length; i++)
         print(i+" "+x[i]+" "+y[i]);
  • and save it as a txt file.
    open ImageJ, open the selected image, and select the icon “segmented lines”. Select the line on the Image. Plugins -> Macro  -> Run… and select the previous file. You can also save the polyline as a ROI. Analyze -> Tools -> ROI Manager… -> Add it (or simply press “t”)  then More>> Save… and save the ROI as a txt file. The same ROI can be imported using Analyze -> Tools -> ROI Manager… More>> Load…
    Check the option “Show All” for multiple ROIs.
  • How to save xy image coordinates from selected points in a stack?
    open the images as a stack: File -> Import-> Image Sequence; press the “Point or Multi-point selection” button, press and hold down the Shift key and click on the image.
    To scroll the stack use “<” “>” or the scroll wheel of your mouse.
    Select Analyze -> Measure (sometimes is necessary to check the measurements properties in Analyze -> Set Measurements and disable all options).
    In the table, Edit -> Select All and paste in Excel (check the international options for the floating-point conversions).
    The last column in the table reports the number of the slice.
  • How to create a gif movie from a sequence of images?
    open the images as a stack: File -> Import-> Image Sequence;
    File -> Save as…-> Animated gif;
    (to change the frame rate select Image -> Stacks -> Tools -> Animation Options)


  • How to crop/rename/resize images in batch mode?
    open IrfanView, File -> Rename/conversion in batch…  On the right Add the photos to elaborate; on the left select the function that you want to use. Option and Advanced for image resizing and cropping.
  • How to crop an image with a fixed aspect ratio?
    Draw the rectangular selection on the image or go to Edit -> Create Custom selections…  Holding the CTRL key, expand/reduce the selection to the size that you want, and move it with the right mouse button. Then crop the image.


  • How to crop a video?
    open the movie. Video -> Filters… -> Add… -> null transform ->Ok -> Cropping…. Then select the cropping offsets -> Ok
    File -> Save as AVI
  • How to crop a video? (2)
    open the movie. Select the starting frame and click on “Mark in”. Select the final frame and click on “Mark out”.
    Edit -> Crop to selection
    File -> Save as…
  • How to save the image sequence?
    open the movie. File -> Export -> Image Sequence…


  • What is the best plugin/tool to insert citations and references in a WordPress site?
    I think Zotero. It is a really open-source tool. Install ZotPress (the Plugin of the Zotero tool) and follow the instructions for the login.
  • How to insert inline citations?
    somewhere in the text, simply insert a shortcode like [\zotpressInText item="{XQ7K4YAQ}" etal="yes"]
    without \ after the [. For more options see the menu Zotpress -> Help
  • How to insert references of inline citations at the end of the page
    at the end of the page insert the shortcode [\zotpressInTextBib style="apa" sortby="date"]
    without \ after the [. For more options see the menu Zotpress -> Help
  • What is the best plugin/tool to insert latex math expression in your WordPress web page?
    I think MathJax-LaTeX. It is open-source. To install the plugin: unzip the downloaded .zip archive to the /wp-content/plugins/ directory and then activate the plugin through the ‘Plugins’ menu in WordPress. In order to use it, you have to simply use shortcode like $ latex d \left ( s , V \right ) = \frac{ s }{ 2 } \left ( -1 + \sqrt{ 1 + \frac{ 2 V }{ \pi R s^2} } \right) $
    /without space between $ and latex to obtain:
    $latex d \left ( s , V \right ) = \frac{ s }{ 2 } \left ( -1 + \sqrt{ 1 + \frac{ 2 V }{ \pi R s^2} } \right) $

Power Point

  • How to change the Language settings of all slides at once
    Use this macro
 Sub ChangeProofingLanguageToEnglish()
    Dim j, k, m, scount, fcount, gcount As Integer
    scount = ActivePresentation.Slides.Count
    For j = 1 To scount
        fcount = ActivePresentation.Slides(j).Shapes.Count
        For k = 1 To fcount
            If ActivePresentation.Slides(j).Shapes(k).HasTextFrame Then
                ActivePresentation.Slides(j).Shapes(k) _
                .TextFrame.TextRange.LanguageID = msoLanguageIDEnglishUS
            End If
            If ActivePresentation.Slides(j).Shapes(k).Type = msoGroup Then
                gcount = ActivePresentation.Slides(j).Shapes(k).GroupItems.Count
                For m = 1 To gcount
                    If ActivePresentation.Slides(j).Shapes(k).GroupItems.Item(m).HasTextFrame Then
                    ActivePresentation.Slides(j).Shapes(k).GroupItems.Item(m) _
                    .TextFrame.TextRange.LanguageID = msoLanguageIDEnglishUS
            End If
                Next m
            End If
        Next k
    Next j
End Sub

GNU Wget

GNU Wget is the best free software package for retrieving files using HTTP, HTTPS, FTP and FTPS.


ScreenToGif is one of the best tools for making gifs.


ExifTool is a popular opensource tool to manipulate image and video metadata like EXIF (Camera model, resolution, aperture, original date and time,…).

Some examples:

if you want to set all dates and time (original, creation,..) from the filename (e.g. “IMG-20190914-WA0010” and you want to store the date 2019-09-14).

exiftool "-alldates<filename" c:\images

See FAQ to understand how it works.

If you want to modify all dates to (2020-12-25) and keep the time:

exiftool "-DateTimeOriginal<2020:12:25 ${DateTimeOriginal;s/.* //}" "-CreateDate<2020:12:25 ${CreateDate;s/.* //}" "-ModifyDate<2020:12:25 ${ModifyDate;s/.* //}" DIR

To modify only the original time and for filenames like: “1983-11 test.jpg” or “2011-10-24 test2.jpg” (without day and time) try this:

exiftool "-DateTimeOriginal<${filename;s/ .*//} 01 00:00:00" DIR

Sometimes, you should try single quotes (or double quotes, it depends on the operating system).


FFmpeg is a free and open-source software project for handling any kind of video, audio, and multimedia files. Some examples:

Getting audio/video file information

ffmpeg -i video.mp4

Convert video files to different formats preserving the quality

ffmpeg -i input.wkv -qscale 0 output.mp4

To cut a video:

ffmpeg -i input.mp4 -ss start_seconds -t duration_seconds output.mp4
ffmpeg -i input.mkv -ss start_seconds -to end_seconds output.mp4

To extract frames from a video in a specified interval (without interpolation)

ffmpeg -ss 09:20.243 -to 14:07.321 -i source_video.mp4 frames/frame_%05d.png

To extract frames by index (no interpolation)

ffmpeg -i source_video.mp4 -vf trim=start_frame=n:end_frame=m frames/frame_%05d.png

To extract frames exactly every 10 seconds with a filter.

Please note that -qscale is the quality. You can also set -qscale:v 1 but you need to set also -qmin 1 . If you still need more quality use a lossless format such as *.png.

ffmpeg -i source_video.mp4 -vf -qscale:v 2 "select=bitor(gte(t-prev_selected_t\,10)\,isnan(prev_selected_t))" -vsync 0 frame_%09d.jpg

To extract frames of depth image from multitrack Matroska (*.mkv) video container obtained with a Kinect Azure DK:

ffmpeg -i output.mkv -map 0:1 -vsync 0 depth%04d.png

The -map 0:1 parameter will extract track index 1, which for most recordings will be depth. If the recording doesn’t contain a color track, -map 0:0 would be used.

The -vsync 0 parameter forces ffmpeg to extract frames as-is instead of trying to match a framerate of 30 fps, 15 fps, or 5 fps.

For more commands see the documentation on the official ffmpeg website


JSXGraph is a wonderful JavaScript library for interactive geometry, function plotting, charting, and data visualization in the web browser.

Here is an example I created to build an interactive webtool for the design of anchored meshes.

Here is a compact manual.

Apps Script Google

How to send a recurrent email with Gmail?

Open Apps Script with your account and create a new function like this:

function sendEmails() {
  var emailAddress = ',';
  var subject = 'Subject';
  var message = "Hello <br> bla bla <br> Bye";
  MailApp.sendEmail(emailAddress, subject, message, {
    htmlBody: message,
    cc : ','

Add triggering to this function.

How to send a spreadsheet as a pdf email attachment?

Create a function like this:

function sendReport() {
  var message = {
    to: "",
    subject: "Bla Bla",
    body: "Hi \n\nPlease find the bla bla attached.\n\nThank you,\nBye",
    name: "MyName",
    attachments: [SpreadsheetApp.getActiveSpreadsheet().getAs(MimeType.PDF).setName("Bla Bla")]

Add triggering to this function.

How to send a confirmation email after form submission and an email with a pdf certificate with your responses

Create a function like this:

function submitForm() {

  record_array = [];

  // open form by ID (in the URL of google module)
  var form = FormApp.openById('');  // Form ID
  // load all responses (the last one is the interesting one)
  var formResponses = form.getResponses();
  // numbero fo responses
  var lastResponse = formResponses.length;
  // load form title
  var formTitle = form.getTitle();
  // load the date
  var date = Utilities.formatDate(new Date(), "GMT+1", "yyyy_MM_dd");
  // load the last submitted form
  var formResponse = formResponses[lastResponse - 1];
  // load all responses
  var itemResponses = formResponse.getItemResponses();
  // load the email of the submitter (if present)
  //var emailRespondent = formResponse.getRespondentEmail();

  // load each response and store in vector array
  for (var j = 0; j < itemResponses.length; j++) {
    var itemResponse = itemResponses[j];
    var title = itemResponse.getItem().getTitle();
    var answer = itemResponse.getResponse();


  // send an email to the form submitter
                  to: record_array[0],  // Email Address of form submitter
                  subject: record_array[1] + record_array[2] +" Confirmation",
                  name: "Name and Surname of my account",
                  htmlBody: "<CENTER><H2>TITLE</H2></CENTER>"+
                  "<br/>" +"<br/>" +"<FONT SIZE=+0.5>"+
                  "<CENTER><b>TITLE2</b>"+ "</CENTER>"+"<br/>" +                 
                  "<br/>" +
                  "<br/>" +
                  "Bla bla <b>" + record_array[3] + " " +record_array[4] +"</b>\n"});

  //if you want to send a pdf file based on a template

  //open the template document by ID
  //the document ID is in the URL
  var templateDoc = DriveApp.getFileById('');
  //create a copy of the template
  var newTempFile = templateDoc.makeCopy();
  //open the new template document for editing
  var openDoc = DocumentApp.openById(newTempFile.getId());
  var body = openDoc.getBody();

  //find the text in the template doc and replace it with the Form response
  //items[0].getResponse() is the first response in the Form
  body.replaceText('{Email}', record_array[0]);  
  body.replaceText('{Name}', record_array[1]);
  body.replaceText('{Surname}', record_array[2]);
  body.replaceText('{DateOfBirth}', record_array[3]);
  body.replaceText('{PlaceOfBirth}', record_array[4]);

  //Save and Close the open document and set the name
  newTempFile.setName('Certificate_' + record_array[1] + '-' + record_array[2])

  // convert the new document to PDF and mail it
  var message = {
    to: record_array[1],
    subject: "Certificate by" + record_array[1] + '-' + record_array[2],
    body: "Bla bla",
    name: "name of the sender",
    cc : '',
    attachments: [DocumentApp.openById(newTempFile.getId()).getAs(MimeType.PDF).setName(date+"_Certificate")]

  // delete the doc file form Drive

Google Forms

How to auto-fill Google Form fields with predefined values from an Excel sheet?

By reconstructing the form URL with pre-filled values. In the Google Form, each question is named internally with “entry.”. For each of the question, you need to find the entry number and assign them the right values and add it to the URL parameters.

Look at this link


A fantastic online tool for plotting 3d fracture orientations.


A wonderful regular expression library with an online tester.


Floating point numbers with signs:


Matches a number using normalised scientific ‘E’ notation


If you want to build and debug your RegExp use this other wonderful online tool

Azure Kinect Recorder

Record data streams from the sensor SDK to a file *.mkv, WFOV non-binned (1MP), RGB 3072p at 15 fps without IMU, for 10 seconds.

k4arecorder.exe -d WFOV_UNBINNED -c 3072p -r 15 -l 10 --imu OFF output.mkv

For more info click here


To create a square buffer around a list of points

#select the active layer
layer = iface.activeLayer()

#build ad array of the features
feats = [feat for feat in layer.getFeatures()]

# set the size of the buffer
buffer_size = 3000

#get the coordinate system of the layer
epsg =

#prepare the content of the new layer
uri = "Polygon?crs=epsg:" + str(epsg) + "&field=id:integer&field=x:real&field=y:real&field=point_id:integer""&index=yes"

#create the new vector layer
mem_layer = QgsVectorLayer(uri,

#connect to the new database
prov = mem_layer.dataProvider()

#loop over features
for i, feat in enumerate(feats):
    #get point geometry
    point = feat.geometry().asPoint()
    #create a new feature
    new_feat = QgsFeature()
    #set the attributes
    new_feat.setAttributes([i, point[0], point[1],])
    #create the buffer geometry
    tmp_feat = feat.geometry().buffer(buffer_size, -1).boundingBox().asWktPolygon()
    #assign the buffer geometry
    #write the new features

#add the new layer to the project

How to export multiple maps centered on a list of points:

Have a look at Atlas and this link

MS Access

How to share a database? Have a look to this page: link


Coherent Pdf (cpdf) is a powerful, free tool (for non-commercial users) to manipulate PDF files (merge, split, extract,..) from the command line

How to split/extract pages from a pdf file and create multiple pdf files?

Prepare a batch file (e.g. test.cmd) like this and run it:

@echo off

set mylist=10-17,20-21,22-25,26-35
setlocal EnableDelayedExpansion

set k=0
for %%i in (%mylist%) do (
  echo %%i
  set /A k+=1
  echo !k! REM this is only to get the index
  cpdf input.pdf %%i -o %%i.pdf

For advanced commands see the manual here