Skip to content

Anonymiser CLI

Vincent STRAGIER edited this page Mar 12, 2021 · 2 revisions

The script anonymiser.py and associated executable anonymiser.exe are intended to be used as a batch anonymisation tool. To do so, in a Windows console you can write:

C:\Users\vince> .\path\to\anonymiser.exe -h
usage: anonymiser.exe [-h] [-dp DESTINATION_PATH] [-fn] [-y | -n] path

positional arguments:
  path                  path to the dataset to anonymise

optional arguments:
  -h, --help            show this help message and exit
  -dp DESTINATION_PATH, --destination_path DESTINATION_PATH
                        destination of the anonymised dataset (if not set, the dataset will be overwritten)
  -fn, --parent_folder_as_name_field
                        if set, fill the name field with the name of the file's parent folder.
  -y, --yes             if set, the program will start directly
  -n, --no              if set, the program will exit directly

With the above command you get the help of the tool.

N.B.: .\path\to\anonymiser.exe -h and py -3.8 .\path\to\anonymiser.py -h are in fine equivalent command, however the last one needs Python 3.8 and its dependencies to be installed.

The positional argument path must always be provided. Then if you do not want to anonymise the dataset inplace, you must provide the optional argument -dp path/to/anonymised/dataset or --destination_path path/to/anonymised/dataset.

The optional argument -fn or --parent_folder_as_name_field is used to specify if you want to replace the content of the field name with the name of the parent folder in which the file to anonimyse will seat.

And finally you can provide the argument -y, --yes or -n, --no to execute the script directly or to quit it after prompting the parsed arguments.

C:\Users\vince> "D:\Vincent\Bureau\Executables\anonymiser.exe" path/to/dataset -dp path/to/anonymised/dataset -fn -n
The following arguments have been parsed:
path: path/to/dataset
destination_path: path/to/anonymised/dataset
parent_folder_as_name_field: True
yes: False
no: True
C:\Users\vince> "D:\Vincent\Bureau\Executables\anonymiser.exe" E:\dataset\ -dp E:\anonymised_dataset\ -y
The following arguments have been parsed:
path: E:\dataset\
destination_path: E:\anonymised_dataset\
parent_folder_as_name_field: False
yes: True
no: False


Current file (1/491): E:\dataset\PAT_10\012345A-B_0000.EEG --> E:\anonymised_dataset\PAT_10\012345A-B_0000.EEG
From:
Name: "PAT_10                                            "
Surname: "                              "
Date: "          "
Sex: " "
Folder: "                    "
Center: "                                       "
Comment: "                                                                                                                                                                                                                                                               "
To:
Name: "                                                  "
Surname: "                              "
Date: "          "
Sex: " "
Folder: "                    "
Center: "                                       "
Comment: "                                                                                                                                                                                                                                                               "

...

The first command just stops as intended. The second runs till the end. Here, for obvious reasons, the data were already anonymised with the option -fn before. Hence the Name field being PAT_10. You can also notice that the full absolute path of each file and folder is specified to avoid any ambiguity.

Clone this wiki locally