Anonymization

Anonymize a folder from Terminal on a Mac

Start a folder anonymization from Terminal on the Mac the app is installed on, on folders you chose in the app.

Desktop app only, 1.6.0 or newerdcmage pro

Problem

You run the same folder anonymization often enough to want it in a small script on your Mac, without opening the dialog each time.

Steps

  1. Choose the folders in the app once. In Anonymize a folder, choose the source folder and a folder for the output. The app keeps access to each folder you choose there. A folder inside one of them is reached too.

  2. Open Terminal and run the app’s own program:

    /Applications/dcmage.app/Contents/MacOS/dcmage --anonymize <source folder> <output folder>

    The output folder has to exist and be empty. Add --help to see every option: --profile, --prefix, --shift-dates and --include-burned-in.

  3. Read the exit code. 0 means every DICOM file was written. 1 means some were not, or a link was found and not followed. 2 means the run did not start, or the folder holds no DICOM file. 3 means dcmage may not reach a folder or could not confirm your purchase.

A file that is not DICOM and an exact duplicate are skipped, and neither changes the exit code.

Limits

  • This is for the Mac the app is installed on, in your own login session. It is not for CI, Docker, SSH or Linux.
  • It reaches only folders you chose in the folder anonymization dialog. It cannot reach a folder you only opened in the app, or one you chose to fix a tag.
  • It takes folders only. It does not read from an archive, take a subject ID table, or keep pseudonyms in the vault.
  • It does not write a signed record.
  • A script has to read the exit code, because a run that leaves files unwritten still ends normally.
  • A killed run can leave a part-written file with a .partial name in the output folder.

Ending the access

Forget all folders in the dialog ends the access for every folder, and removes their paths from the app’s data. Terminal then reaches none of them until you choose one again.

Result

The same output as a run in the app with the same profile, prefix and date setting, and the same pseudonym for each patient. The command’s prefix is ANON unless you pass --prefix, so a run in an app with its own default prefix needs that option to match.

See also