Skip to content

Commit

Permalink
cleaning up headers and adding apidocs (pydicom#214)
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch authored Sep 10, 2022
1 parent 6dd9c7e commit 3278136
Show file tree
Hide file tree
Showing 78 changed files with 1,535 additions and 1,144 deletions.
File renamed without changes.
43 changes: 43 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Update Docs

on:
push:
branches: [master]

jobs:
generate-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: "gh-pages"

- name: Create conda environment
run: conda create --quiet -c conda-forge --name deid

- name: Install deid
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
root=$PWD
source activate deid
cd /tmp
git clone -b add/api-docs https://github.com/pydicom/deid
cd deid
pip install -e .
cd ./docs
pip install -r api_docs/requirements.txt
/bin/bash ./apidoc.sh
cd ../
mv $root/.git ./docs/api_docs/.git
rm -rf $root
mv ./docs/api_docs $root
cd $root
ls -a
git add .
git status
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git config --global pull.rebase true
git commit -a -m "Adding changed documentation files"
git status
git push origin gh-pages
File renamed without changes.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ deid.egg-info
build
pypi.sh
env
_build

private
.vscode
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017-2022 Vanessa Sochat
Copyright (c) 2016-2022 Vanessa Sochat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
50 changes: 13 additions & 37 deletions deid/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,15 @@
"""
DeidRecipe
Copyright (c) 2017-2022 Vanessa Sochat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The functions below assume a configuration file called deid, although the
user can specify a custom name.
"""

from deid.config.utils import load_deid, get_deid, load_combined_deid
from deid.config.standards import actions, sections, formats
__author__ = "Vanessa Sochat"
__copyright__ = "Copyright 2016-2022, Vanessa Sochat"
__license__ = "MIT"

from deid.config.standards import actions, formats, sections
from deid.config.utils import get_deid, load_combined_deid, load_deid
from deid.logger import bot


class DeidRecipe:
"""Create a deid recipe to filter and perform operations on a dicom header.
"""
Create a deid recipe to filter and perform operations on a dicom header.
Usage typically looks like:
Expand All @@ -51,7 +25,6 @@ class DeidRecipe:
(later in the list overrides earlier loaded).
base: if True, load a default base (default_base) before custom
default_base: the default base to load if "base" is True
"""

def __init__(self, deid=None, base=False, default_base="dicom"):
Expand Down Expand Up @@ -102,7 +75,8 @@ def get_format(self):
return self._get_section("format")

def _get_named_section(self, section_name, name=None):
"""Get a named section from the deid recipe.
"""
Get a named section from the deid recipe.
a helper function to return an entire section, or if a name is
provided, a named section under it. If the section is not
Expand Down Expand Up @@ -146,7 +120,8 @@ def _get_actions(self, action=None, field=None, section="header"):
return header

def get_actions(self, action=None, field=None):
"""Get deid actions to perform on a header, or a subset based on a type
"""
Get deid actions to perform on a header, or a subset based on a type
A header action is a list with the following:
{'action': 'REMOVE', 'field': 'AssignedLocation'},
Expand Down Expand Up @@ -194,7 +169,8 @@ def ls_fieldlists(self):
# Init

def _init_deid(self, deid=None, base=False, default_base="dicom"):
"""Initialize a recipe.
"""
Initialize a recipe.
initialize the recipe with one or more deids, optionally including
the default. This function is called at init time. If you need to add
Expand Down
26 changes: 3 additions & 23 deletions deid/config/standards.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
"""
Copyright (c) 2017-2022 Vanessa Sochat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
__author__ = "Vanessa Sochat"
__copyright__ = "Copyright 2016-2022, Vanessa Sochat"
__license__ = "MIT"

# Supported formats
formats = ["dicom"]
Expand Down
50 changes: 14 additions & 36 deletions deid/config/utils.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,25 @@
"""
Copyright (c) 2017-2022 Vanessa Sochat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The functions below assume a configuration file called deid, although the
user can specify a custom name.
"""
__author__ = "Vanessa Sochat"
__copyright__ = "Copyright 2016-2022, Vanessa Sochat"
__license__ = "MIT"

# pylint: skip-file

from deid.logger import bot
from deid.utils import read_file, get_installdir
from deid.data import data_base
import os
import re
import sys
from collections import OrderedDict

from deid.config.standards import (
formats,
actions,
sections,
filters,
groups,
formats,
group_actions,
groups,
sections,
)
from collections import OrderedDict
import os
import re
import sys
from deid.data import data_base
from deid.logger import bot
from deid.utils import get_installdir, read_file


def load_combined_deid(deids):
Expand Down
34 changes: 10 additions & 24 deletions deid/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
"""
__author__ = "Vanessa Sochat"
__copyright__ = "Copyright 2016-2022, Vanessa Sochat"
__license__ = "MIT"

"""
Simple loading functions for datasets
from deid.data import get_dataset
Copyright (c) 2017-2022 Vanessa Sochat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""


from deid.utils import get_installdir
from deid.logger import bot
import os

from deid.logger import bot
from deid.utils import get_installdir

data_base = os.path.dirname(os.path.abspath(__file__))


def get_dataset(dataset=None):
"""get_dataset will return some data provided by the application,
"""
Get a dataset by name.
get_dataset will return some data provided by the application,
based on a user-provided label. In the future, we can add https endpoints
to retrieve online datasets.
"""
Expand Down
11 changes: 3 additions & 8 deletions deid/dicom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
from .header import (
get_identifiers,
replace_identifiers,
remove_private_identifiers,
)

from .utils import get_files
from .fields import extract_sequence
from .pixels import has_burned_pixels, DicomCleaner
from .header import get_identifiers, remove_private_identifiers, replace_identifiers
from .pixels import DicomCleaner, has_burned_pixels
from .utils import get_files
2 changes: 1 addition & 1 deletion deid/dicom/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .jitter import jitter_timestamp, jitter_timestamp_func
from .uids import basic_uuid, dicom_uuid, suffix_uuid, pydicom_uuid
from .uids import basic_uuid, dicom_uuid, pydicom_uuid, suffix_uuid

# Function lookup
# Functions here must take an item, field, and value
Expand Down
32 changes: 6 additions & 26 deletions deid/dicom/actions/jitter.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
"""
Copyright (c) 2017-2022 Vanessa Sochat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
__author__ = "Vanessa Sochat"
__copyright__ = "Copyright 2016-2022, Vanessa Sochat"
__license__ = "MIT"

from deid.logger import bot
from deid.utils import get_timestamp
from deid.utils import parse_keyvalue_pairs
from deid.utils import get_timestamp, parse_keyvalue_pairs

# Timestamps

Expand All @@ -45,7 +24,8 @@ def jitter_timestamp_func(item, value, field, **kwargs):


def jitter_timestamp(field, value):
"""Jitter a timestamp "field" by number of days specified by "value"
"""
Jitter a timestamp "field" by number of days specified by "value"
The value can be positive or negative. This function is grandfathered
into deid custom funcs, as it existed before they did. Since a custom
Expand Down
30 changes: 6 additions & 24 deletions deid/dicom/actions/uids.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
"""
__author__ = "Vanessa Sochat"
__copyright__ = "Copyright 2016-2022, Vanessa Sochat"
__license__ = "MIT"

Copyright (c) 2022 Vanessa Sochat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
import uuid

from deid.utils import parse_keyvalue_pairs
from pydicom.uid import generate_uid as pydicom_generate_uid

from deid.logger import bot
import uuid
from deid.utils import parse_keyvalue_pairs


def basic_uuid(item, value, field, **kwargs):
Expand Down
Loading

0 comments on commit 3278136

Please sign in to comment.