Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
williammadie committed Jun 21, 2024
1 parent 80e0ea6 commit e36ff25
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
4 changes: 4 additions & 0 deletions deidcm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def __new__(cls, recipe_path: str = None, authorized_words_path: str = None) ->
"""
Create a new instance of Config if it does not exist.
Args:
recipe_path: the path of your custom `recipe.json` file.
authorized_words_path: the path of your custom `authorized_words.txt` file
Returns:
Config: The single instance of the Config class.
"""
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,14 @@ B -->|No| Z[Apply the strictest rule: REMOVE];

### Define your own recipe

A `recipe.json` file is already available inside deidcm package. However, it is possible to define your own `recipe.json`.
A `recipe.json` file is already available inside deidcm package. However, it is possible to define your own `recipe.json`. In order to specify a custom recipe, use the [the Config object][deidcm.dicom.deid_mammogram.Config].

!!! warning
The inbuilt `recipe.json` file was created for the [Deep.Piste](https://www.health-data-hub.fr/partenariats/deep-piste){:target="_blank"} study. It was made for mammograms only and you should probably define ***your own file meeting your own needs***.

If you don't define a new `recipe.json` folder, deidcm will show a warning and automatically use its inbuilt referential.

In order to do define your own `recipe.json`, you'll have to create the file `$DP_HOME/data/input/recipe.json` and respect this structure:
In order to do define your own `recipe.json`, you'll have to create the file `recipe.json` and respect this structure :

```json
{
Expand Down
19 changes: 19 additions & 0 deletions docs/pages/deid_mammogram.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,25 @@
show_root_full_path: true
members: None

::: deidcm.config.Config.__new__

??? example
Default Configuration (inbuilt recipe, no authorized words)
```py title="default_config.py" linenums="1"
from deidcm.config import Config

config = Config()
print(config.recipe)
```

Custom Configuration
```py title="custom_config.py" linenums="1"
from deidcm.config import Config

config = Config(recipe_path="/path/to/custom-recipe.json", authorized_words_path="/path/to/authorized_words.txt")
print(config.recipe)
```

::: deidcm.config.Config.load_recipe
options:
show_root_full_path: true
Expand Down
26 changes: 9 additions & 17 deletions docs/pages/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,26 @@ For installing `deidcm` tools, run the following command:
pip install deidcm
```

After that, you'll have to define an environment variable called `DP_HOME`. This
variable is used to locate your **data directory** where you'll:

* put your DICOM files for submitting them to the deidentifier tool
* find the output of the deidentifier tool (deidentified information)
* define referentials used by the package (`recipe.json`, `ocr_deid_words.txt`)

To define this **data directory**, run the following command:

```bash
export DP_HOME=/path/to/folder
```

!!! info
You can set this folder wherever you want. However, keep in mind that this folder is essential for the package and you'll probably open it more than once. So, don't put it somewhere too complicated to access.

## Start working with deidcm

You can start using `deidcm` by importing functions.

Here is an example with the `deidentify_image_png` function. This function takes 3 parameters: an input dicom file, the output directory and the name of the final png file. More details can be found [here][deidcm.dicom.deid_mammogram.deidentify_image_png].

```py title="deidentify_image.py" linenums="1"
from deidcm.config import Config
from deidcm.dicom.deid_mammogram import deidentify_image_png

# Default Configuration (inbuilt-recipe, all words on pixels
# have to be erased)
Config()

deidentify_image_png(
infile="/data/dicoms/1.3.6.1.4.1.9590.100.1.2.16146556.dcm",
outdir="/data/processed",
filename="1.3.6.1.4.1.9590.100.1.2.16146556"
)
```
```

!!! note
If you want to use a custom recipe, use the [the Config object][deidcm.dicom.deid_mammogram.Config].

0 comments on commit e36ff25

Please sign in to comment.