Usage

Information on how to combine one or more anonapi commands to do things like resetting jobs, working with multiple jobs. For more detailed step-by-step instructions on performing a specific task, see Tutorials

Starting a command prompt

Anonapi commands are given from a command line or command prompt:

Windows

To start a command prompt: press the windows start menu -> type cmd press enter

opening a command prompt in windows

To start a command prompt in a specific folder: find the folder in windows explorer, then shift + right-click on that folder -> Open command prompt here (Dutch: Opdrachtvenster hier openen).

opening a command prompt in a specific folder in windows A command line in windows opened in a specific folder
Linux

This varies between distributions. Common ways are pressing Meta+t, Konsole on ubuntu, or Terminal. For more info see here

Getting info on commands

All CLI commands have the following form:

$ anon <command-group> <command> <arguments>   # General form
$ anon job info 1234                           # Example: get info for job '1234'
$ anon server activate server2                 # Example: Activate the server named 'server2'

A list of commands for any command group can be printed this way:

$ anon job                # Shows all commands for command group 'job'
$ anon settings           # Shows all commands for command group 'settings'
$ anon <command-group>    # General form. Shows all commands for any command group

Detailed help on commands is often available directly from the command line by adding --help to any command. For example:

$ anon job info --help                         # Shows detailed help for job info
$ anon server activate --help                  # Shows detailed help for server activate

Information about jobs

$ anon server jobs    # shows last 100 jobs on server
$ anon job info 123   # shows details for job with id 123

Tip

see Job status codes for more information on job status

Cancel or restart jobs

$ anon job reset 123   # reset job with id 123
$ anon job cancel 123  # cancel job with id 123

Multiple jobs at once (batch)

More information on job batches: batch

$ cd C:/myfolder            # any folder you want. One folder can only contain one batch.
$ anon batch init           # initialises an empty batch
$ anon batch add 10 11 13   # add three job ids to this batch
$ anon batch add 20-35      # add fifteen job ids: 20 through to 35
$ anon batch status         # print info for all jobs in batch
$ anon batch                # see other commands including reset and cancel all

Creating jobs

The general procedure for creating a jobs is as follows:

  1. open a terminal

  2. create a mapping using the map init command

  3. edit the mapping to suit your needs. Most commands for this are in the map command group

  4. based on the mapping, run the create from-mapping command

  5. monitor your jobs progress with the batch status command

Two specific cases are shown below:

Anonymize files from PACS

In this example we want to retrieve and anonymize studies from PACS

Quick example

  • Create a folder for your project (will hold a record of jobs created)

  • Open a command prompt in this folder

  • Then type the following:

$ anon map init            # create a mapping at the source of the data
$ anon map edit            # set correct paths, add studyUIDs or accession numbers
$ anon create from-mapping # create jobs on anonymization server
$ anon batch status        # monitor the progress of your jobs

Detailed example

For this example we want to retrieve and anonymize the following studies from PACS:

  • A study with AccessionNumber 123456.1234567

  • A study with AccessionNumber 123456.2234568

  • A study with StudyInstanceUID 123.1232.23.24

To do this, follow these steps:

$ anon map init
> Initialised example mapping in anon_mapping.csv

$ anon map edit    # opens mapping for editing

Now edit the mapping until it looks like this:

## Description ##
Mapping created February 12 2020

## Options ##
project,          Wetenschap-Algemeen
destination_path, \\server\share\myoutput

## Mapping ##
source,                            patient_id, patient_name, description
accession_number:123456.1234567,   001,        Patient2,     Test PACS project
accession_number:123456.2234568,   002,        Patient2,     Test PACS project
study_instance_uid:123.1232.23.24, 003,        Patient3,     Test PACS project

Now close the editor and run anon create from-mapping:

$ anon create from-mapping
> This will create 3 jobs on p01, for projects '['Wetenschap-Algemeen']' etc..
> Done

To monitor the status of your created jobs, use anon batch status:

$ anon batch status

Anonymize files from a share

In this example we will anonymize data from three folders on a share

Quick example

  • Create a folder for your project (will hold your mapping and record of jobs created)

  • Open a command prompt in this folder

  • Then type the following

$ anon map init            # create a new mapping, make it active
$ anon map edit            # set correct paths, remove example rows

# now add three folders to the mapping
$ anon map add-study-folders patient1/study patient2/study patient3/study_fixed

$ anon map edit            # now set the anonymized names for the added studies
$ anon create from-mapping # create jobs on anonymization server

$ anon batch status        # monitor the progress of your jobs

Tip

If you already have a csv or excel file containing paths, you can use the –file option on the add-study-folders command to add them all in one command

Detailed example

In this example we will anonymize three studies that are on a share \\server1\share. The data folder looks like this:

\\server1\share\data
                 |--patient1
                 |   |--raw
                 |   |   |--raw1.dcm
                 |   |   |--raw2.dcm
                 |   |--study1           <- this should become 'anon1'
                 |       |--file1
                 |       |--file2
                 |--patient2
                 |   |--raw
                 |   |   |--raw1.dcm
                 |   |   |--raw2.dcm
                 |   |--study1          <- this should become 'anon2'
                 |       |--file1
                 |       |--file2
                 |       |--notes.txt
                 |--patient3
                 |   |--study1
                 |   |   |--file1
                 |   |   |--file2
                 |   |--study1_fixed    <- this should become 'anon3'
                 |       |--file1
                 |       |--file2

For each patient, we want to to anonymize the data from the study folder. Except for patient3, where we want to get the data from the study1_fixed folder. To do this take the following steps:

$ cd \\server\share\data   # Or use a drive letter or mount. Will be made UNC later
$ anon map init            # create a mapping at the source of the data
$ anon map edit            # opens mapping for editing

The mapping needs to be edited in two ways:

  • the root_source_path parameter needs to be changed into a UNC path for the anonymization server to be able to find the data.

    Tip

    To find out the UNC path for a windows drive letter or a linux mount, see Finding a UNC path

  • initially the mapping contains several rows with example data. These can be removed

  • The destination_path parameter will probably need to be changed

After making these changes, the mapping file should look like this:

## Description ##
Mapping created February 12 2020

## Options ##
root_source_path  \\server\share\data           <= changed
project,          Wetenschap-Algemeen
destination_path, \\server\share\myoutput       <= changed

## Mapping ##
source,                            patient_id, patient_name, description

Now we will add each of the studies we want to anonymize. Make sure you close the editor before doing this:

$ anon map add-study-folders patient1/study patient2/study patient3/study_fixed

All DICOM files in these folders have now been selected and added as rows in the mapping. Now edit the rows to suit your needs, setting the patient ID and name you want.

$ anon map edit                 # edit patientID, name etc. Save
$ anon create from-mapping      # create anonymization jobs