-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
89 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
API | ||
=== | ||
|
||
Documentation for directly using the Python functions. | ||
|
||
.. automodule:: tbpcxr | ||
:members: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Development | ||
=========== | ||
|
||
To setup for development: | ||
|
||
.. code-block:: bash | ||
python -m pip install --editable .[dev] | ||
Git LFS | ||
======= | ||
|
||
Git `Large File Storage <https://git-lfs.github.com>`_ (LFS) is used to store larger files in the repository such as | ||
test images, trained models, and other data ( i.e. not text based code ). Before the repository is cloned, git lfs must | ||
be installed on the system and set up on the users account. The `tool's documentation <https://git-lfs.github.com>`_ | ||
provides details on installation, set up, and usage that is not duplicated here. Once set up the git usage is usually | ||
transparent with operation such as cloning, adding files, and changing branches. | ||
|
||
The ".gitattributes" configuration file automatically places files in the directories "test/data" and "my_pkg/data" to | ||
be stored in Git LFS. | ||
|
||
|
||
Linting | ||
======= | ||
|
||
The linting processes are configured and run with `pre-commit <https://pre-commit.com>`_. Using pre-commit provides | ||
a single file ( ".pre-commit-config.yaml" ) configuration for both execution of CI and local git pre-commit hooks. The | ||
"pre-commit" package does not need to be installed in the projects venv. One initialized for the project, pre-commit | ||
will manage the versions of the tools in a separate environment, that is automatically managed. | ||
|
||
The following is the `quick start guide <https://pre-commit.com/#quick-start>`_. | ||
|
||
The linting process uses both `Black <https://black.readthedocs.io/en/stable/>`_ and | ||
`flake8 <https://flake8.pycqa.org/en/latest/>`_ to ensure uncompromising code formatting and some programmatic problems. | ||
The Black must be used to auto format new code before committing: | ||
|
||
.. code:: bash | ||
python -m black . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
Example | ||
======= | ||
|
||
To classify a single image: | ||
|
||
.. code-block:: python | ||
from tbpcxr.model import Model | ||
from tbpcxr.utilities import read_dcm | ||
outlier_model = Model.load_outlier_pcamodel() | ||
img = read_dcm(path_to_file) | ||
arr = outlier_model.to_observations([img]) | ||
if outlier_model.outlier_predictor(arr)[0] == -1: | ||
print("{} is an outlier".format(path_to_file)) | ||
Multiple images can efficiently be processed by using Python `map` function, which | ||
|
||
.. code-block:: python | ||
from tbpcxr.model import Model | ||
from tbpcxr.utilities import read_dcm | ||
outlier_model = Model.load_outlier_pcamodel() | ||
arr = outlier_model.to_observations(map(read_dcm, image_file_list)) | ||
results = outlier_model.outlier_predictor(arr) | ||
for fn in [fn for fn, o in zip(image_file_list, results) if o == -1]: | ||
print("{} is an outlier".format(fn)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters