diff --git a/deidcm/config.py b/deidcm/config.py index 6341b22..a97baba 100644 --- a/deidcm/config.py +++ b/deidcm/config.py @@ -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. """ diff --git a/docs/index.md b/docs/index.md index bdc940d..6531bd3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 { diff --git a/docs/pages/deid_mammogram.md b/docs/pages/deid_mammogram.md index ef1b963..87aeeb3 100644 --- a/docs/pages/deid_mammogram.md +++ b/docs/pages/deid_mammogram.md @@ -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 diff --git a/docs/pages/quickstart.md b/docs/pages/quickstart.md index 04f4b4c..62bf8ab 100644 --- a/docs/pages/quickstart.md +++ b/docs/pages/quickstart.md @@ -23,22 +23,6 @@ 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. @@ -46,11 +30,19 @@ 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" ) -``` \ No newline at end of file +``` + +!!! note + If you want to use a custom recipe, use the [the Config object][deidcm.dicom.deid_mammogram.Config]. \ No newline at end of file