Medlea

Docs /Command-Line Client

Command-Line Client: Overview and Installation

The command-line client (climed-client) lets you work with LeaRes from a terminal instead of the web app. It covers loading patients and their CT series, segmenting them (cardiac, lungs, whole body) and downloading the anatomies as STL files, running a virtual spirometry and saving its values, curves and PDF report, and creating projects from STL or VTP files: one at a time, or dozens in a single command. It is meant for the jobs that are slow to do by hand in the browser, such as loading the CT scans of 20 different patients, or loading data from a script.

It runs on your own computer and talks to your LeaRes instance over a secure connection. You do not need access to any server, and it needs no other software of ours.

When to use it

You want to…Use
Load one patient, with a few series, and look at it right awayThe web app (see Uploading and Viewing DICOM Data)
Load one patient from a terminalimport-dicom
Load many patients at once, from a folder of foldersimport-dicom-batch --root
Load many patients from a list you preparedimport-dicom-batch --manifest
Create an engineering project from an STL or VTP file, or many at oncecreate-project, create-project-batch
Add a further geometry to a projectadd-geometry
Segment a patient’s CT (cardiac, lungs, whole body)segment
Save anatomies, one or a whole group, as STL filesdownload-stl
Run a virtual spirometry and save FEV1, FVC, PEF, the curves and the PDF reportvirtual-spirometry, download-spirometry
Run the load unattended (scheduled, or inside a script)Scripting and Automation
Work on your organisation’s own server instead of the cloudSigning In

What you need

  • A LeaRes account that is registered and active (the download is refused to disabled accounts).
  • Python 3.10 or newer on your computer, and a terminal (Windows, macOS or Linux).
  • Your DICOM images, one folder (or ZIP archive) per patient.

Install

  1. In the same browser where you are signed in to LeaRes, open:

    https://leares.net/api/downloads/climed-client/latest

    A file named like climed_client-X.Y.Z-py3-none-any.whl is downloaded. If you are not signed in, or your account is disabled, you get an error instead of the file.

  2. In a terminal, in the folder where the file was saved. A virtual environment keeps your system clean; it is recommended but not required:

    python3 -m venv climed-env
    source climed-env/bin/activate          # Windows: climed-env\Scripts\activate
    pip install ./climed_client-X.Y.Z-py3-none-any.whl   # the exact name of the file you downloaded

    For the PDF report of virtual spirometry, install it with the PDF extra instead: pip install "./climed_client-X.Y.Z-py3-none-any.whl[pdf]". Everything else works without it.

  3. Check that it works:

    climed-client --version
    climed-client --help

    --help lists the commands; adding --help after a command (for example climed-client import-dicom-batch --help) lists its options.

If you closed the terminal, activate the environment again (source climed-env/bin/activate) before using climed-client.

Commands at a glance

CommandWhat it does
loginSign in and remember your instance (Signing In)
statusShow who you are signed in as, and for how long
logoutForget the saved sign-in on this computer
databasesList the databases you can write to
import-dicomCreate one patient and upload one series
import-dicom-batchCreate many patients, one series each
create-projectCreate one project from an STL or VTP file
create-project-batchCreate many projects, one file each
add-geometryAdd a further geometry to a project
patientsList your patients and their CT series
segmentSegment anatomy groups (cardiac, lungs, whole body) on the server
anatomiesList the anatomies of a series
download-stlSave anatomies, single or by group, as STL files
virtual-spirometryRun a virtual spirometry
download-spirometrySave values, curves and the PDF report of virtual spirometry runs

Update and remove

  • Update: download the new file the same way and run pip install --upgrade ./climed_client-X.Y.Z-py3-none-any.whl.
  • Remove: climed-client logout, then pip uninstall climed-client.

Data handling. DICOM files are uploaded as they are, patient identifiers included. The same rules as any other upload apply: see Intended Use and Safety. The STL files, values and reports you download are patient data too (the report carries the patient name): keep them as your institution requires for any export.