tomolog-cli

tomolog-cli is a command-line-interface for publishing tomography experiment data and meta data in a stack of Google slides

project

Installation

First, you must have Conda installed and create a dedicated conda environment:

(base)$ conda create -n tomolog python=3.9

and:

(base)$ conda activate tomolog
(tomolog)$

then install all requirements with:

(tomolog)$ conda install  -c conda-forge python=3.9 dropbox google-api-python-client matplotlib dxchange dxfile python-dotenv opencv matplotlib-scalebar

install meta

(tomolog)$ git clone https://github.com/xray-imaging/meta.git
(tomolog)$ cd meta
(tomolog)$ python setup.py install

and install tomolog

(tomolog)$ git clone https://github.com/xray-imaging/tomolog-cli.git
(tomolog)$ cd tomolog
(tomolog)$ python setup.py install

Requirements

Please install all the packages listed in requirements file.

tomolog also requires access tokens from dropbox and google services.

Dropbox

Go to dropbox developer site , login using your google credentials and select “Create an App”:

project

Take the App key and App secret from the Settings tab:

project

an copy them in a file in your home directory called:

$ ~/.tomologenv

APP_KEY=....
APP_SECRET=....

Set the following permissions:

project

Google

Next step is to authorize tomolog to create slides on the …@gmail.com gmail account.

Open a web browser and login as …@gmail.com then go to google developer site and press “Select a project” to create a new project

project project

Once the project is selected go to the project dashboard:

project

and select API & Services / Credentials

project

select it and then go to Create Credentials / Service account

project

where you enter the service account name, i.e. tomolog

project

Grant this service account access to project: Owner

Grant users access to this service account:

service account user role: Google Account email: ....@gmail.com
service account admin role: Google Account email: ....@gmail.com

Once the service account is selected you need to create the authorization key:

project project

open the json file and copy the authorization token in a file called:

$ ~/tokens/google_token.json

Go back to the project dashboard

project

and select “Go to the API overview”

project

and select “Enable API and Services”

project

search and add the “google slide api”

project project

Now tomolog will be able to create slides in the …@gmail.com user account.

Usage

To publish experiment log information to a google page:

$ tomolog run --file-name /local/data/2022-03/Peters/B4_Pb_03_c_10keV_892.h5 --presentation-url https://docs.google.com/presentation/d/128c8JYiJ5EjbQhAtegYYetwDUVZILQjZ5fUIoWuR_aI/edit#slide=id.p

For help:

$ tomolog run -h
usage: tomolog run [-h] [--file-name PATH] [--PV-prefix PV_PREFIX] [--beamline {None,2-bm,7-bm,32-id}] [--idx IDX] [--idy IDY] [--idz IDZ] [--max MAX] [--min MIN]
                   [--presentation-url PRESENTATION_URL] [--rec-type {recgpu,rec}] [--config FILE] [--config-update] [--double-fov] [--logs-home FILE] [--token-home FILE]
                   [--verbose]

optional arguments:
  -h, --help            show this help message and exit
  --file-name PATH      Name of the hdf file (default: .)
  --PV-prefix PV_PREFIX
                        PV prefix for camera (default: 32idcSP1:)
  --beamline {None,2-bm,7-bm,32-id}
                        Customized the goodle slide to the beamline selected (default: 32-id)
  --idx IDX             Id of x slice for reconstruction visualization (default: -1)
  --idy IDY             Id of y slice for reconstruction visualization (default: -1)
  --idz IDZ             Id of z slice for reconstruction visualization (default: -1)
  --max MAX             Maximum threshold value for reconstruction visualization (default: 0.0)
  --min MIN             Minimum threshold value for reconstruction visualization (default: 0.0)
  --presentation-url PRESENTATION_URL
                        Google presention url (default: None)
  --rec-type {recgpu,rec}
                        Specify the prefix of the recon folder (default: recgpu)
  --config FILE         File name of configuration file (default: /home/beams/FAST/logs/tomolog.conf)
  --config-update       When set, the content of the config file is updated using the current params values (default: False)
  --double-fov          Set to true for 0-360 data sets (default: False)
  --logs-home FILE      Log file directory (default: /home/beams/FAST/logs)
  --token-home FILE     Token file directory (default: /home/beams/FAST/tokens)
  --verbose             Verbose output (default: False)

For other options:

$ tomolog -h
usage: tomolog [-h] [--config FILE]  ...

optional arguments:
  -h, --help     show this help message and exit
  --config FILE  File name of configuration file

Commands:

    init         Create configuration file
    run          Run data logging to google slides
    status       Show the tomolog status

API reference

tomolog-cli Modules:

tomolog_cli.tomolog

Functions:

TomoLog(args)

Class to publish experiment meta data, tomography projection and reconstruction on a google slide document.

class tomolog_cli.tomolog.TomoLog(args)[source]

Bases: object

Class to publish experiment meta data, tomography projection and reconstruction on a google slide document.

init_slide()[source]
plot_projection(proj, fname)[source]
plot_recon(recon, fname)[source]
publish_descr(presentation_id, page_id)[source]
publish_proj(presentation_id, page_id, proj, resolution=1)[source]
publish_recon(presentation_id, page_id, recon, resolution=1)[source]
read_meta_item(template)[source]
read_raw()[source]
read_recon()[source]
run_log()[source]

tomolog_cli.tomolog_2bm

Functions:

TomoLog2BM(args)

Class to publish experiment meta data, tomography projection and reconstruction on a google slide document.

class tomolog_cli.tomolog_2bm.TomoLog2BM(args)[source]

Bases: TomoLog

Class to publish experiment meta data, tomography projection and reconstruction on a google slide document.

plot_projection(proj, fname)[source]
plot_recon(recon, fname)[source]
publish_descr(presentation_id, page_id)[source]
publish_proj(presentation_id, page_id, proj)[source]
publish_recon(presentation_id, page_id, recon)[source]
read_raw()[source]
read_rec_line()[source]
read_recon()[source]
read_tiff_part(fname, x, y, z_start, z0_start, lchunk)[source]
run_log()[source]

tomolog_cli.tomolog_32id

Functions:

TomoLog32ID(args)

Class to publish experiment meta data, tomography projection and reconstruction on a google slide document.

class tomolog_cli.tomolog_32id.TomoLog32ID(args)[source]

Bases: TomoLog

Class to publish experiment meta data, tomography projection and reconstruction on a google slide document.

plot_projection(proj, fname, scalebar='nano')[source]
plot_recon(recon, fname)[source]
publish_descr(presentation_id, page_id)[source]
publish_proj(presentation_id, page_id, proj)[source]
publish_recon(presentation_id, page_id, recon)[source]
read_raw()[source]
read_rec_line()[source]
read_recon()[source]
run_log()[source]

Credits

Citations

GPU based tomographic reconstruction is available at tomocupy

Cite [A1] if you use tomobank

Cite [A2] if you use tomopy/tomopy cli

Cite [A3] if you use DataExchange

A1

Francesco De Carlo, Doga Gursoy, Daniel Jackson Ching, Kees Joost Batenburg, Wolfgang Ludwig, Lucia Mancini, Federica Marone, Rajmund Mokso, Daniel M. Pelt, Jan Sijbers, and Mark Rivers. Tomobank: a tomographic data repository for computational x-ray science. Measurement Science and Technology, 2017. URL: https://doi.org/10.1088/1361-6501/aa9c19.

A2

Gürsoy D, De Carlo F, Xiao X, and Jacobsen C. Tomopy: a framework for the analysis of synchrotron tomographic data. Journal of Synchrotron Radiation, 21(5):1188–1193, 2014.

A3

De Carlo F, Gursoy D, Marone F, Rivers M, Parkinson YD, Khan F, Schwarz N, Vine DJ, Vogt S, Gleber SC, Narayanan S, Newville M, Lanzirotti T, Sun Y, Hong YP, and Jacobsen C. Scientific data exchange: a schema for hdf5-based storage of raw and analyzed data. Journal of Synchrotron Radiation, 21(6):1224–1230, 2014.

References

B1

Nghia T. Vo, Robert C. Atwood, Michael Drakopoulos, and Thomas Connolley. Data processing methods and data acquisition for samples larger than the field of view in parallel-beam tomography. Opt. Express, 29(12):17849–17874, Jun 2021. URL: http://www.opticsexpress.org/abstract.cfm?URI=oe-29-12-17849, doi:10.1364/OE.418448.