|
| 1 | +# ImageDePHI Demo |
| 2 | + |
| 3 | +This walkthrough will guide you through using the ImageDePHI program. |
| 4 | + |
| 5 | +## Getting the demo data |
| 6 | + |
| 7 | +In order to get the demo data, you will need to have installed ImageDePHI and run the following command: |
| 8 | + |
| 9 | +```bash |
| 10 | +imagedephi demo-data |
| 11 | +``` |
| 12 | + |
| 13 | +This will create a new directory in the location it is run called `demo_files` and download several whole slide images into that directory. These images contain fake PHI, which we will redact with ImageDePHI. |
| 14 | + |
| 15 | +## Redacting with the Graphical User Interface (GUI) |
| 16 | +ImageDePHI allows redaction of whole slide images through either a graphical user interface, accessible through a web browser, or a command line interface. First, let's take a look at the redaction workflow using the graphical user interface. |
| 17 | + |
| 18 | +#### 1. Starting the program |
| 19 | +In order to start the program, install ImageDePHI and run: |
| 20 | + |
| 21 | +```bash |
| 22 | +imagedephi gui |
| 23 | +``` |
| 24 | + |
| 25 | +This will start the program, which will be accessible at a random port, and open up a browser at the correct address. |
| 26 | + |
| 27 | +By default, this command will select a random port to serve the application from. You can specify a port if you'd like by using the `--port` flag, e.g: |
| 28 | + |
| 29 | +```bash |
| 30 | +imagedephi gui --port 8888 |
| 31 | +``` |
| 32 | + |
| 33 | +#### 2. Looking at the UI |
| 34 | +If your browser is not already open to ImageDePHI, open up your browser and go to `127.0.0.1:<port>` where `<port>` is either the random port picked by the command above or the number you supplied to the `--port` flag if you used that option to start the server. |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +You should be greeted by the initial UI screen. On the left hand side there are several options for specifying which files should be redacted and how they should be redacted. We will go over each step individually. |
| 39 | + |
| 40 | +#### 3. Select Files to be Redacted |
| 41 | + |
| 42 | +The first thing you'll need to do is select files for redaction. |
| 43 | + |
| 44 | + |
| 45 | +Click the button in Step 1 to open up a file browser. |
| 46 | + |
| 47 | + |
| 48 | +Navigate your computer's file system until you come to the directory where you downloaded your demo files, then click "Select." |
| 49 | + |
| 50 | +#### 4. Select Output Destination |
| 51 | + |
| 52 | +Next, select a location for redacted images. ImageDePHI does not modify your original images. Instead, it creates new, redacted images saved into the location selected here. |
| 53 | + |
| 54 | + |
| 55 | +For this demo, select the directory that is the parent of your `demo_files/` directory. A new directory will be created at this location for the redacted images. |
| 56 | + |
| 57 | +#### 5. Preview Redaction Changes |
| 58 | + |
| 59 | +After selecting your input directory, you will see a table previewing the redaction that is about to happen. For each file in the input directory, you'll see a row containing the file name, a thumbnail, the redaction status, and the metadata tags. |
| 60 | + |
| 61 | +Looking at the metadata tags, you'll see that, for example, the "Date" tag is red with strikethrough. This indicates that this field will be removed and not present in the redacted output file. Scrolling over, you'll see tags like "AppMag" and "BitsPerSample" have no special styling, indicating that they will be included in the output file. |
| 62 | + |
| 63 | +Most importantly, you'll see that there's an issue in the "Redaction Status" column for the image "SEER_Mouse_1_17158543_demo.svs". If you hover over the red icon you'll see the message "1 tag(s) missing redaction rules." Below that you'll see "55500: 55500," indicating that this image contains a metadata tag with the number "55500" that ImageDePHI doesn't know how to redact. |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +#### 6. Creating a Custom Rule Set |
| 68 | + |
| 69 | +The base rule set provided by ImageDePHI is used every time images are redacted. User-defined rule sets can be used to supplement or modify the behavior defined by the base rules. |
| 70 | + |
| 71 | +The base rule set does not contain a rule for tag `55500`, so in order to redact the demo images, the program will need to be supplied a ruleset that knows what to do with tag `55500`. |
| 72 | + |
| 73 | +Let's create that ruleset now. Create a new file called `custom_rules.yaml` and add the following: |
| 74 | + |
| 75 | +```yaml |
| 76 | +--- |
| 77 | +name: Custom Rules |
| 78 | +description: Custom ruleset used for the ImageDePHI demo. |
| 79 | +svs: |
| 80 | + metadata: |
| 81 | + '55500': |
| 82 | + action: delete |
| 83 | +``` |
| 84 | +
|
| 85 | +If you'd like to know the default behavior of ImageDePHI, take a look at the [base rules](../imagedephi/base_rules.yaml). |
| 86 | +
|
| 87 | +#### 7. Using Your Custom Ruleset |
| 88 | +
|
| 89 | +Now that you've created a rule to complete redaction of the demo images, let's use that rule set. |
| 90 | +
|
| 91 | +Click the folder icon in Step 3 (Rulesets) to open the file navigator. |
| 92 | +
|
| 93 | + |
| 94 | +
|
| 95 | +Navigate to the custom rule set you created in step 6 and select it. The rule set you select in this step will be composed with the base rule set provided by ImageDePHI. If a tag appears in both the base rules and the custom rule set, the custom rule will be applied instead of the base rule. |
| 96 | +
|
| 97 | +The table should update to reflect that the program now knows how to redact tag `55500`, and each image should have a green checkmark icon in the "Redaction Status" column. |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +#### 8. Redact the Demo Images |
| 102 | + |
| 103 | +All that's left to do is click redact! Click the button that says "De-PHI Images." You'll see a progress bar that indicates how much time is left in the redaction process. |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | +Once that succeeds, you'll see a toast notification at the bottom of the screen indicating that the images have been redacted successfully. |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +You'll find a new directory in the location you selected as your output directory. This new directory will have a name starting with "Redacted_" and ending with a timestamp of when you started redacting images. It will contain redacted images. Adjacent to that directory will be a manifest file mapping input file names to output file names. If there were any issues during redaction, those would be reported in the manifest file as well. |
| 112 | + |
| 113 | +## Using the CLI |
| 114 | + |
| 115 | +If you would prefer to use the CLI to redact the images, follow this section to walk through the same example using that tool instead of the UI. Make sure the follow the instructions at the top of this guide to get the demo data. |
| 116 | + |
| 117 | +#### 1. Use the `plan` command |
| 118 | + |
| 119 | +The `plan` command is one way to determine if the files you want to redact are able to be redacted. If not, the output of the `plan` command will help you discover what you'll need to do in order to redact your images. After obtaining the test data, run the following command: |
| 120 | + |
| 121 | +```bash |
| 122 | +imagedephi plan demo_files |
| 123 | +``` |
| 124 | + |
| 125 | +You'll see in the output of that command that one of the files cannot be redacted. In order to find out why, you can run: |
| 126 | + |
| 127 | +```bash |
| 128 | +imagedephi plan demo_files/SEER_Mouse_1_17158543_demo.svs |
| 129 | +``` |
| 130 | + |
| 131 | +Running the `plan` command on a single image will provide a detailed report of exactly how that particular image is redacted. To see this level of detail for all images in a directory, use the `-v` (verbose) option. |
| 132 | + |
| 133 | +The ouput of the `plan` command for that particular image reveals that it contains a metadata item with tag `55500` with no corresponding rule. |
| 134 | + |
| 135 | +#### 2. Create an override rule set |
| 136 | + |
| 137 | +In order to redact the demo images, we'll need to give the program a rule it can use for tag `55500`. The mechanism we can use to do this is with an override, or custom, rule set. |
| 138 | + |
| 139 | +ImageDePHI comes with a base set of rules that covers most commonly seen metadata tags for SVS and DICOM images. If your images contain metadata not covered by the base rules, you'll need a custom rule set. |
| 140 | + |
| 141 | +For this demo, create a file called `custom_rules.yaml` add add the following: |
| 142 | + |
| 143 | +```yaml |
| 144 | +--- |
| 145 | +name: Custom Rules |
| 146 | +description: Custom ruleset used for the ImageDePHI demo. |
| 147 | +svs: |
| 148 | + metadata: |
| 149 | + '55500': |
| 150 | + action: delete |
| 151 | +``` |
| 152 | + |
| 153 | +We now have a ruleset to supplement the base rules and enable redaction of the demo images. |
| 154 | + |
| 155 | +#### 4. Use the `plan` command with the override rule set |
| 156 | + |
| 157 | +First, let's verify that our custom rule set works as intended. Run the following command: |
| 158 | + |
| 159 | +```bash |
| 160 | +imagedephi plan -R custom_rules.yaml demo_files |
| 161 | +``` |
| 162 | + |
| 163 | +Note the message "3 images able to be redacted" in the output. This means all of the demo files can now be redacted. |
| 164 | + |
| 165 | +#### 5. Use the `run` command to redact the images |
| 166 | + |
| 167 | +The `run` command is very similar to `plan`, except it also needs to be told where to save the redacted files. This is done using the `-o` option. Run the following: |
| 168 | + |
| 169 | +```bash |
| 170 | +mkdir ./output_files |
| 171 | +imagedephi run -R custom_rules.yaml -o ./output_files demo_files |
| 172 | +``` |
| 173 | + |
| 174 | +After that command finishes, you'll see a new directory in `./output_files` called `Redacted_<timestamp>` containing the redacted files. |
| 175 | + |
| 176 | +You'll also see a file next to that directory called `Redacted_<timestamp>_manifest.csv`. This will contain a mapping of input file names to output file names, as well as any errors that may have occurred during redaction. |
| 177 | + |
| 178 | +## Next Steps |
| 179 | + |
| 180 | +For more information about the ImageDePHI rules system, be sure to check out the [documention](../README.md). |
| 181 | + |
| 182 | +## Demo Data Citation |
| 183 | +‘NCI SRP Mouse Tissue Whole Slide Images with Fake PHI/PII' data set, Version 1.0. Generated: December 29, 2021; Scanner: Leica Microsystems, Aperio AT2; Provided by: The National Cancer Institute (NCI) Surveillance Research Program (SRP). |
0 commit comments